I have a cron on my Ubuntu server that runs this bash script daily:
#!/usr/bin/expect -f
spawn sftp user@ip
expect "password:"
send "password\n"
expect "sftp>"
send "cd remote_directory\n"
expect "sftp>"
send "lcd ~/dtc/data/outstanding\n"
expect "sftp>"
send "mget * \n"
expect "sftp>"
send "exit\n"
interact
It connects to a remote server via SFTP and downloads a bunch of files. This is working no problem, however, I want these files to appear in a certain directory on the machine (my server) running this script.
This is what I'm attempting to do on line 8 to no avail. How can I run this script via cron, and make sure it cds into the right directory on my server so that it places the downloaded files into the right directory?
lcd
command on line 8