2017-07-10 68 views
0

我想在linux下配置Eclipse來運行帶有參數的.sh腳本。爲此,我正在使用外部工具配置。我能夠運行我的腳本,但只要我添加一個參數,我會在控制檯收到一條消息the input device is not a TTY,並且腳本不會運行。這是我的配置:不能用參數運行外部工具

enter image description here

什麼可能是這種情況?我將不勝感激所有幫助。

編輯:這是腳本:

#!/bin/bash 
EDISON_DEVICE="[email protected]:/tmp" 
WORK_DIR=$(pwd) 

CLEAN=false 
BUILD=false 
TEST=false 
CREATE_DOC=false 
UPLOAD=false 

#tabs 30 
if [ $# -eq 0 ] 
then 
    echo -e "Options:\n-c, --clean \tClean project\n-b, --build\tBuild project\n-d, --doc\t Create documentation\n-u, --upload\tUpload project to Edison device\n-e, --edison string\tEdison device ip (need to copy output)" 
fi 

while [ $# -gt 0 ] 
do 
key="$1" 

case $key in 
    --help) 
    echo -e "Options:\n-c, --clean \tClean project\n-b, --build\tBuild project\n-d, --doc\t Create documentation\n-u, --upload\tUpload project to Edison device\n-e, --edison string\tEdison device ip (need to copy output)" 
    exit 
    ;; 
    -c|--clean) 
    CLEAN=true 
    ;; 
    -b|--build) 
    BUILD=true 
    ;; 
    -t|--test) 
    TEST=true 
    ;; 
    -d|--doc) 
    CREATE_DOC=true 
    ;; 
    -u|--upload) 
    UPLOAD=true 
    ;; 
    -e|--edison) 
    EDISON_DEVICE="$2" 
    shift # past argument or value 
    ;; 
    *) 
    echo "Unrecognized option $key" # unknown option 
    ;; 
esac 
shift # past argument or value 
done 

# VALIDATION 
if $UPLOAD; then 
    if [ "$EDISON_DEVICE" = "" ] 
    then 
     echo 'Please use option --edison to compile project or fill default EDISON_DEVICE on script' 
     exit 
    fi 
fi 

# EXECUTION 
if $CLEAN; then 
    docker run --rm -it -v $WORK_DIR:/tmp --workdir /tmp inteliotdevkit/intel-iot-yocto -c "make clean" 
fi 

if $BUILD; then 
    docker run --rm -it -v $WORK_DIR:/tmp --workdir /tmp inteliotdevkit/intel-iot-yocto -c "make" 
fi 

if $TEST; then 
    docker run --rm -it -v $WORK_DIR:/tmp --workdir /tmp inteliotdevkit/intel-iot-yocto -c "make test" 
fi 

if $CREATE_DOC; then 
    make docs 
fi 

if $UPLOAD; then 
    echo -e "${COLOR}Copy program-test-python to Edison device${NC}" 
    scp program-test/PythonConnectorEdison.py program-test/_PythonConnectorEdison.so program-test/python_script.py $EDISON_DEVICE 
fi 
+0

我做的和你一樣,對我來說它是有效的。你的shell腳本的內容是什麼? –

+0

我已添加腳本內容 – Bremen

+0

一旦腳本顯示,可能重複的https://stackoverflow.com/questions/40536778/how-to-workaround-the-input-device-is-not-a-tty-when -using-grunt-shell-to-invo – rodrigo

回答

0

你的腳本是罰款和工作對我來說,如果我只是附和應執行的所有命令。問題是關於docker命令。從您的docker命令中刪除-t,從here on SO回答。

「-t」告訴docker配置tty,如果您沒有tty並嘗試附加到容器,則不起作用(默認情況下,當您不執行「-d」 「)。


如果你想使用交互模式,看看輸出,而不是你可以啓動自己的殼被讀取參數作爲命令(-c),是通過設置以下互動(-i)。

在主頁設置地點要:

/usr/bin/sh 

在參數補充:

-ci "/home/lukasz/bitbucket/driver/compile_ubuntu.sh -c" 

編輯#1:

,正如你在評論中寫道它仍然可以找到沒有TTY考慮this answer on superuser。如果沒有/etc/inittabthis answer on aksubuntu

只是刪除/dev/console

cd /dev 
rm -f console 
ln -s ttyS0 console 

編輯/改變/etc/inittab內容

::askfirst:/bin/sh 

到:

ttyS0::askfirst:/bin/sh 
+0

感謝您的回答。在用'-i'替換'-it'後,我確實沒有看到tty錯誤,但是我也沒有看到docker的任何輸出。 – Bremen

+0

@Bremen:你什麼時候也用'-a stderr -a stdout'? –

+0

運行docker時應該添加這些參數嗎? – Bremen