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:


沒有留言:

張貼留言

[Git 常見問題] error: The following untracked working tree files would be overwritten by merge

  Source From  Here 方案1: // x -----删除忽略文件已经对 git 来说不识别的文件 // d -----删除未被添加到 git 的路径中的文件 // f -----强制运行 #   git clean -d -fx 方案2: 今天在服务器上  gi...