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:
Whenever I run it I get this message:
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:
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:
- ssh -t user@server<
- 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
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:
沒有留言:
張貼留言