我正在嘗試編寫一個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 關注
- 1230 瀏覽
添加回答
舉報
0/150
提交
取消
