0

我在 AIX (kshell) 上这样做

当我echo $-在本地获得输出时ism,当我远程运行它时ssh test_id@sandbox "echo $-"

$ echo $-
ism

我正在将它从远程服务器运行到另一台 AIX 服务器

ssh test_id@sandbox "echo $-"
himBH

其中哪一个是交互式的,哪一个是非交互式的

4

2 回答 2

1

如果“interactive”表示有一个终端与连接相关联,我以前公司的AIX ksh一般使用这种方法:

if tty -s
then
     do-coding-for-sessions-with-terminal
else
     do-nothing
fi
于 2020-05-11T13:27:23.953 回答
0

如注释所示,变量中存在 ani表示$-shell 是交互式的。要从U&L 的 Tim Kennedy 那里得到答案

case "$-" in
    *i*)
        interactive=1
        ;;
    *)
        not_interactive=1
        ;;
esac

上面的代码使用一个case语句来查看$-变量是否包含一个i

于 2020-05-17T14:50:01.320 回答