Cannot create a pending script folder

I have this script

#!/usr/bin/expect

set DATE [exec date +%F]
spawn sftp user@192.168.0.20
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 does not create a directory. Error:

cannot create directory

I do not know what I am doing wrong. Any help would be appreciated.

+4
source share
1 answer

If you want to upload files to a new local new directory, why not create this directory with the exec function and not using sftp?

#!/usr/bin/expect

set DATE [exec date +%F]
exec mkdir "$DATE"
cd "$DATE"
spawn ...
+4
source

Source: https://habr.com/ru/post/1568710/


All Articles