21 lines
693 B
Bash
21 lines
693 B
Bash
#!/bin/sh -l
|
|
|
|
#set -e at the top of your script will make the script exit with an error whenever an error occurs (and is not explicitly handled)
|
|
set -eu
|
|
|
|
echo 'Connecting to SSH server and creating directory..'
|
|
|
|
sshpass -p $4 ssh -o StrictHostKeyChecking=no -p $3 $1@$2 mkdir -p $6
|
|
|
|
echo 'Connection to SSH server and directory creation finished successfully!'
|
|
|
|
echo 'Starting file transfer..'
|
|
# create a temporary file containing sftp commands
|
|
printf "%s" "put -r $5 $6" >$TEMP_SFTP_FILE
|
|
#-o StrictHostKeyChecking=no to avoid "Host key verification failed".
|
|
sshpass -p $4 sftp -b $TEMP_SFTP_FILE -P $3 $7 -o StrictHostKeyChecking=no $1@$2
|
|
|
|
echo 'File transfer finished successfully!'
|
|
exit 0
|
|
|