我正在尝试编写一个shell脚本,在远程服务器上创建一些目录,然后使用scp将文件从本地计算机复制到远程服务器上。这是我到目前为止所拥有的:ssh -t user@server<<EOTDEP_ROOT='/home/matthewr/releases'datestamp=$(date +%Y%m%d%H%M%S)REL_DIR=$DEP_ROOT"/"$datestampif [ ! -d "$DEP_ROOT" ]; then echo "creating the root directory" mkdir $DEP_ROOTfimkdir $REL_DIRexitEOTscp ./dir1 user@server:$REL_DIRscp ./dir2 user@server:$REL_DIR每当我运行它时,我收到此消息:Pseudo-terminal will not be allocated because stdin is not a terminal.脚本永远挂起。我的公钥在服务器上是可信的,我可以在脚本之外运行所有命令。有任何想法吗?
3 回答
弑天下
TA贡献1818条经验 获得超8个赞
即使stdin不是终端,也要尝试ssh -t -t(或ssh -tt简称)强制伪tty分配。
从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.
- 3 回答
- 0 关注
- 1155 浏览
添加回答
举报
0/150
提交
取消