SFTP files to a server from Linux.

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.

Bumping up posts or double posting is not permitted in these forums.

Please read the rules, which you agreed to when you registered, if you have not already done so.

You have another thread that differs by just the client being AIX. I have moved that post to a more general section.

You may receive an infraction for this. If so, don't worry, just try to follow the rules more carefully. The infraction will expire in the near future

Thank You.

The UNIX and Linux Forums.