Hi,
I am looking for a shell script to sftp to a file server and copy all the files from a directory after the script is run.
The server name should be a user input parameter and of-course the username/password as well. Rest all should be handled by the script.
I tried with below snippet:-
echo "FTP'ing the CSV output to file server now.."
echo "Please enter the FTP server name:"
read ftpservername
echo "Please enter the username:"
read username
sftp $username@$ftpservername
However, the problem is:- When it is run, it brings on the sftp password prompt - which I dont want. I would like to handle password as well automatically within script as user input and then copy files from a particular directory to a directory on the file server (This is also a user input).
Any idea how this can be handled with-in the script? The script should automatically take care of establishing a successful SFTP session to the server and then transfer the files.
Help with sample script will be highly appreciated.
Thanks.