Skip to Main Content

Infrastructure Software

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Check for existence of file on remote machine - sftp

883189Dec 7 2011 — edited Dec 10 2011
HI

I need to connect to the remote machine x and get files from them to my local machine. For that I need to write a ksh script. Before getting the files from server x, I need to check if the file is present or not. If present, get the files. If files not present, get the error message. I tried a lot. But couldn't get any please help. The server x supports only SFTP I guess.

My test code is as follows:

#!/bin/ksh

value=$(find . -name test.txt)
if [ "$value" = "" ]
then print "No such file found"
else {
print " File found "
sftp user@x_servername
get test.txt
EOF
}
fi

But, this code is not working. Its asking for password and hunging up immediately. Is there any other method? Please do help. Its very urgent....
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 7 2012
Added on Dec 7 2011
10 comments
4,959 views