伪终端将不被分配,因为标准输入不是终端 [英] Pseudo-terminal will not be allocated because stdin is not a terminal
问题描述
我试图写一个远程服务器上创建一些目录中的shell脚本,然后使用SCP从我的本地计算机中复制文件远程到。这是我到目前为止有:
I am trying to write a shell script that creates some directories on a remote server and then uses scp to copy files from my local machine onto the remote. Here's what I have so far:
ssh -t user@server<<EOT
DEP_ROOT='/home/matthewr/releases'
datestamp=$(date +%Y%m%d%H%M%S)
REL_DIR=$DEP_ROOT"/"$datestamp
if [ ! -d "$DEP_ROOT" ]; then
echo "creating the root directory"
mkdir $DEP_ROOT
fi
mkdir $REL_DIR
exit
EOT
scp ./dir1 user@server:$REL_DIR
scp ./dir2 user@server:$REL_DIR
每当我运行它,我得到这个消息:
Whenever I run it I get this message:
Pseudo-terminal will not be allocated because stdin is not a terminal.
和脚本只是挂起,直到永远。
And the script just hangs forever.
我的公共密钥被信任的服务器上,我可以运行该脚本只是罚款之外的所有命令。任何想法?
My public key is trusted on the server and I can run all the commands outside of the script just fine. Any ideas?
推荐答案
尝试的ssh -t -t
来迫使伪终端分配,即使标准输入不是终端
Try ssh -t -t
to force pseudo-tty allocation even if stdin isn't a terminal.
参见:<一href=\"http://stackoverflow.com/questions/7085429/terminating-ssh-session-executed-by-bash-script\">Terminating SSH会话通过bash脚本
从SSH手册页:
-T Disable pseudo-tty allocation.
-t Force pseudo-tty allocation. This can be used to execute arbitrary screen-based programs on a remote machine, which can be very useful, e.g. when implementing
menu services. Multiple -t options force tty allocation, even if ssh has no local tty.
这篇关于伪终端将不被分配,因为标准输入不是终端的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!