Hello,
I'm working on an AIX 5.3 mainframe. I have to automatically send files with sftp.
I choose the expect way, here is my code :
Code:
#!/usr/bin/expect -d -f
#spawn /usr/bin/sftp -b sftpbatch user@host
#set mydate `date +%Y%m%d%H%M%S`
cd /imxapp4/impr_files/pcltosend
spawn /usr/bin/sftp user@host
match_max 100000
expect "*ass*"
send -- "mypassword\n"
expect "*Connected*"
send -- "lcd /test\n"
sleep 1
send -- "mkdir date +%Y%m%d%H%M%S\n"
sleep 1
send -- "PUT *\n"
expect eof
output result for the mkdir part :
send: sending "mkdir date +%Y%m%d%H%M%S\n" to { exp4 }
This is simply creating a "date" folder
You can see my first attempt :
Code:
#set my_command `date +%Y%m%d%H%M%S`
...
send -- "mkdir mydate\n"
output :
...
executing commands from command file ./test_expect.sh
wrong # args: should be "set varName ?newValue?"
while executing
"set mydate `date +%Y%m%d%H%M%S`"
(file "./test_expect.sh" line 3)
Do you have an idea how I can do this ? With another shell script without the expect stuff it is working as expected ?
Thanks in advance,
Greg.