Reputation: 657
I'm trying to copy files from a remote windows server to Unix server. I was successfully able to copy files from windows server using command prompt but when I run these commands from a script it's not working as expected.
commands used:
sftp user@remoteserver.com
lcd local_dir
cd remote dir
get file_name
exit
When I run these commands from a script the script is stopping after it connects to the remote server.
Can anybody tell me how to fix this issue.
Upvotes: 0
Views: 302
Reputation: 9904
The commands lcd
to exit
are sftp
commands, so you cannont just write them into a script line by line but have to redirect them as sftp
s stdin:
# all lines till "EOF" will be redirected to sftp
sftp user@remoteserver.com <<- EOF
lcd local_dir
cd remote dir
get file_name
exit
EOF
# here you are in your shell script again, eg:
SFTPRES=$?
Upvotes: 1