Reputation: 625
I have this script
#!/usr/bin/expect
set DATE [exec date +%F]
spawn sftp [email protected]
expect "password:"
send "password\n"
expect "sftp>"
send "cd /getfile/$DATE/ \n"
expect "sftp>"
send "lcd /putfile/ \n"
expect "sftp>"
send "mkdir $DATE"
expect "sftp>"
send "lcd /putfile/$DATE \n"
expect "sftp>"
send "mget *.* \n"
expect "sftp>"
send "quit \n"
everything works here, but it does not create the directory. The error is:
cant create directory
I don't know what I'm doing wrong. Any help would be appreciated.
Upvotes: 4
Views: 3125
Reputation: 72717
If you want to download files to a local new directory, why not create this directory with expect's exec instead of with sftp?
#!/usr/bin/expect
set DATE [exec date +%F]
exec mkdir "$DATE"
cd "$DATE"
spawn ...
Upvotes: 5