SFTP GET Local folder issue

Hi,

My requirement is that I should execute SFTP from /users/XYZ dir and get the file on to /users/XYZ/TEST folder with out the sys error.

I'm facing the following strange issue with SFTP execution. I need to copy a file 'abc.txt' from Remote m/c(MyServer) to local machine(Server1). I've this file in the folder /users/XYZ on MyServer and need to SFTP it to /users/ABCD on Server1.

On Server1:
-------------------------

cd /users/XYZ
> ls TEST
>TEST/ /* TEST is a sub dir in /users/XYZ */

>ls abc.txt
> /* ls returns no thing as the file doesnot exists here and I need to get it to a folder TEST under this dir */

>sftp uname/pwd@MyServer
> ls /users/ABCD/abc.txt
abc.txt /* File exists*/
> get /users/ABCD/abc.txt   /users/XYZ/TEST/abc.txt
sys err: 
>bye

On Server1:
-------

>ls  /users/XYZ/TEST/abc.txt
>/* returns no file with such a name
>ls  /users/XYZ/abc.txt
>abc.txt /*File got copied here as I exected SFTP command from here*/

When I execute this, my intention was to get the file 'abc.txt' on to '/users/XYZ/TEST', but the execution seems to be a fail, but the catch is that the file gets copied to /users/XYZ, but not to my intended location.
When I'm in /users/XYZ/TEST and When I give "get /users/ABCD/abc.txt" through SFTP without local path details with out any error, the file gets placed in /users/XYZ/TEST.

Your help is highly appreciated.

Regards,
SKP

---------- Post updated at 11:45 AM ---------- Previous update was at 10:08 AM ----------

Request your help in this regad.

It's odd that it's ignoring the full path as you gave it. What system are you on? Your sftp may be buggy.

Try

lcd /users/XYZ/TEST/
get abc.txt

instead of your single get command. lcd is "local change-directory", for the local path, rather than the remote one...

Hi,
I'm on AIX box and it is working in the way you have mentioned using 'lcd' command.

But when I give 'get <Remotepath> <local_path>' it is not working.
I'm planning to use this way without giving the lcd option.
Also, weird thing is that get is also not accepting any optional parameters like '-p'.

Same get command on the same machine is working fine with FTP.

Your Help is highly appreciated.

---------- Post updated 04-17-13 at 05:01 AM ---------- Previous update was 04-16-13 at 11:25 PM ----------

Hi,
All I'm using SFTPG3 : SSH Tectia client 6.1.* and figured out that using sget instead of get I can achieve this.

Regards,
SKP

You do not seem to have the usual openssh version of sftp, but a proprietary one. A proprietary one with bugs, even.

If it doesn't work without lcd, then it doesn't work without lcd. You'll need to use lcd -- or cd earlier in the script itself.