Avatar of Vijay Mallesh
Vijay Mallesh
 asked on

SFTP Get command fails in Shell Script and works fine Manually

I'm trying to get a file using SFTP command in the shell script and it fails with "Cannot download non-regular file:". Below is the piece of code I have written.

sftp -v -F /usr/home/.ssh/sftp.config <user>@<servername> <<EOF2
cd <targetdirectory>
mget $File
bye
EOF2

Also when I try to list the files in the shell script, it gives "Couldn't get handle: Failure" error.

However, If I do the same operation manually(SFTP to get the file), I'm able to get the file successfully without any errors.

Very much confused as why the SFTP command in shell script is not allowing to download the file whereas the same set of commands when manually run works.

Any inputs is greatly appreciated. Thank you so much!!

Thanks,
Vijay
Shell Scripting

Avatar of undefined
Last Comment
dfke

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
dfke

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes