Link to home
Start Free TrialLog in
Avatar of peter
peterFlag for United States of America

asked on

how to sftp files

Hi everyone,
first time transferring files with sftp: )
Working with an outside company to get some files over to them on a daily basis.
Requirement is to sftp files from our server  to the customers sftp server.
Then archive the files on our server in a tar ball with time date stamp. Still need help with this.

To sftp to the customers server is:
sftp username@123.456.789.123
SSH Server supporting SFTP and SCP
Connected to 123.456.789.123
sftp> ls
Inbox

Basically it's an sftp server with an Inbox only. Once files are sent to the Inbox, it moves the files to the required directory based on file type. So I just have to get the files to their Inbox.

Here's how I started the script, it does work, just wanted your thoughts.

#!/usr/bin/expect
spawn /usr/bin/sftp username@123.456.789.123
#sleep 5
expect "sftp>"
send "mput /directory1/*.*\r"
expect "sftp>"
send "mput /directory2/*.*\r"
expect "sftp>"
send "mput /directory3/*\r"
expect "sftp>"
send "mput /directory4/*\r"
expect "sftp>"
send "mput /directory5/*\r"
expect "sftp>"
send "mput /directory6/*\r"
send "quit \r"

Hope this explains it clearly enough. Thank you!
ASKER CERTIFIED SOLUTION
Avatar of MikeOM_DBA
MikeOM_DBA
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of peter

ASKER

Thanks Mike, it uses public keys for authentication so that's not an issue.
Then you are good to go!
:p