troubleshooting Question

SFTP Get command fails in Shell Script and works fine Manually

Avatar of Vijay Mallesh
Vijay Mallesh asked on
Shell Scripting
1 Comment1 Solution544 ViewsLast Modified:
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
ASKER CERTIFIED SOLUTION
dfke

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 1 Comment.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 1 Comment.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros