程式扎記: [Linux 常見問題] Pseudo-terminal will not be allocated because stdin is not a terminal

標籤

2015年4月14日 星期二

[Linux 常見問題] Pseudo-terminal will not be allocated because stdin is not a terminal

Source From Here
Question
I am trying to write a shell scipt 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:
  1. ssh -t user@server<
  2. DEP_ROOT='/home/matthewr/releases'  
  3. datestamp=$(date +%Y%m%d%H%M%S)  
  4. REL_DIR=$DEP_ROOT"/"$datestamp  
  5. if [ ! -d "$DEP_ROOT" ]; then  
  6.     echo "creating the root directory"  
  7.     mkdir $DEP_ROOT  
  8. fi  
  9. mkdir $REL_DIR  
  10. exit  
  11. EOT  
  12.   
  13. scp ./dir1 user@server:$REL_DIR  
  14. 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?

How-To
Try ssh -t -t to force pseudo-tty allocation even if stdin isn't a terminal.

See also: Terminating SSH session executed by bash script

Below are execution examples on CentOS 6.4:


沒有留言:

張貼留言

網誌存檔

關於我自己

我的相片
Where there is a will, there is a way!