gpt4 book ai didi

linux - 在 ssh 中抑制 'Warning: no access to tty'

转载 作者:塔克拉玛干 更新时间:2023-11-03 01:02:12 27 4
gpt4 key购买 nike

我有一个简短的脚本,它编译一个 .c 文件并在运行 tcsh 的远程服务器上运行它,然后将控制权交还给我的机器(这用于学校,我需要我的程序在实验室计算机上正常工作,但想在我的机器上编辑它们等)。它以这种方式运行命令:

ssh -T user@server << EOF
cd cs4400/$dest
gcc -o $efile $file
./$efile
EOF

到目前为止它工作正常,但每次我这样做时它都会发出警告:

Warning: no access to tty (Bad file descriptor).
Thus no job control in this shell.

我知道这在技术上不是问题,但它 super 烦人。我正在尝试做学校作业,检查我的程序的输出等,这让一切变得困惑,我讨厌它。

我在我的机器上运行这个版本的 ssh:

OpenSSH_6.1p1 Debian-4, OpenSSL 1.0.1c 10 May 2012

服务器上的 tcsh 版本:

tcsh 6.17.00 (Astron) 2009-07-10 (x86_64-unknown-linux)

服务器上的这个版本的ssh:

OpenSSH_5.3p1, OpenSSL 1.0.0-fips 29 Mar 2010

最佳答案

消息实际上是由 shell 打印的,在本例中为 tcsh。你可以使用

strings  /usr/bin/tcsh | grep 'no access to tty'

确保它属于tcsh本身。

它与 ssh 的关系非常松散,即 ssh 在这种情况下只是触发器,而不是原因。

您应该改变您的方法而不是使用HERE DOCUMENT。而是将可执行的 custom_script 放入 /path/custom_script 并通过 ssh 运行它。

# this will work
ssh user@dest '/path/custom_script'

或者,只需将复杂的命令作为单行命令运行。

# this will work as well
ssh user@dest "cd cs4400/$dest;gcc -o $efile $file;./$efile"

关于linux - 在 ssh 中抑制 'Warning: no access to tty',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18855989/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com