【问题标题】:Cannot run external tool with argument无法使用参数运行外部工具
【发布时间】:2026-02-14 22:55:01
【问题描述】:

我正在尝试在 linux 下配置 Eclipse 以运行带有参数的 .sh 脚本。为此,我正在使用外部工具配置。我能够运行我的脚本,但是一旦我添加了一个参数,我就会在控制台中收到一条消息the input device is not a TTY,并且脚本没有运行。这是我的配置:

这可能是什么情况?我将不胜感激。

编辑:这是脚本:

#!/bin/bash
EDISON_DEVICE="root@192.168.1.202:/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

【问题讨论】:

  • 我做的和你一样,对我来说它有效。你的 shell 脚本的内容是什么?
  • 我已经添加了脚本内容
  • 一旦脚本被揭露,*.com/questions/40536778/…的可能副本

标签: linux eclipse bash shell


【解决方案1】:

如果我只是回显所有应该执行的命令,你的脚本就很好,并且对我有用。问题在于 docker 命令。从 docker 命令中删除 -t,从 here on SO 回答。

“-t”告诉 docker 配置 tty,如果您没有 tty 并尝试附加到容器,这将不起作用(默认情况下,当您不执行“-d”时)。


如果您想使用交互模式并查看输出,您可以通过设置以下内容来启动自己的 shell,它将参数作为命令 (-c) 读取并且是交互的 (-i)。

在主页上将位置设置为:

/usr/bin/sh

在参数上添加:

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

编辑#1:

正如您在评论中所写,它仍然找不到 TTY,请考虑 this answer on superuser。如果没有/etc/inittab,则读取this answer on aksubuntu

只需删除/dev/console

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

编辑/更改/etc/inittab 内容

::askfirst:/bin/sh

到:

ttyS0::askfirst:/bin/sh

【讨论】:

  • 感谢您的回答。将-it 替换为-i 后,我确实没有看到tty 错误,但我也没有看到docker 的任何输出。
  • @Bremen:什么时候你还使用-a stderr -a stdout
  • 运行docker的时候要不要加上这些参数?
  • 是的,这是一个 docker run 参数,请参见此处:docs.docker.com/engine/reference/commandline/run
  • 我做了docker run --rm -i -a stderr -a stdout -v $WORK_DIR:/tmp --workdir /tmp inteliotdevkit/intel-iot-yocto -c "make clean" eclipse还是没有输出