SFTP GET Local folder issue


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting SFTP GET Local folder issue
# 1  
Old 04-16-2013
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:
-------------------------
Code:
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:
-------
Code:
>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.

Last edited by Franklin52; 04-17-2013 at 03:20 AM.. Reason: Please use code tags
# 2  
Old 04-16-2013
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
Code:
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...
# 3  
Old 04-17-2013
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
# 4  
Old 04-17-2013
Quote:
Originally Posted by skpvalvekar
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'.
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.

Last edited by Corona688; 04-17-2013 at 12:49 PM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Sftp cannot see folder in destination server

I'm using sftp to connect from a Windows server (User ID is ssh1) to AIX server (User ID ftpeapsg) to access /sftp/ftphrssg/HRSSG/EAPSG in AIX server. User ftpeapsg is created on AIX server. Able to connect to AIX server fine without the need for password however not able to see the folder... (4 Replies)
Discussion started by: userguy
4 Replies

2. UNIX for Beginners Questions & Answers

Retrieve the Latest file in a folder using SFTP

HI Guys, Can anyone help me to retrieve the latest file from below example using SFTP I have below list of files in a folder v403t.lstprgms.sortin1 val027.d099.fwest.oct2711 xcelrptd.d1400sqp.dec1713.t040459.@02del xcelrptd.d1400sqp.dec1713.t073308.@02del... (3 Replies)
Discussion started by: heye18
3 Replies

3. UNIX for Beginners Questions & Answers

Mirror a folder from the Internet to local machine

I have a machine in my LAN that runs Ubuntu and I have full access in it. There is another PC on the Internet that has a public IP eg 3.3.3.3 and it servers as https server and access to it is by username and password. On the remote PC all i have is access through https using username/passwd. ... (3 Replies)
Discussion started by: atux_null
3 Replies

4. UNIX for Dummies Questions & Answers

Transfer image file from local to remote with sftp

Hi. I have managed to transfer a file from remote to my raspberry pi, but I have the camera mounted on the Raspbien so I would like to transfer the image the other way. I use this line: sshpass -p 'PASSWORD' scp -- USER@ssh.servername.com:/www/cam/image.jpg /home/pi/shared/web/image.jpg (4 Replies)
Discussion started by: brickglow
4 Replies

5. Shell Programming and Scripting

Lftp sftp get - script renames the local file with suffix tilde

Hi, Below script used for sftp get, #/bin/bash USER=xxx PASS=xxx HOST=xxx REMOTE_FILE=$1 LOCAL_FILE_LOC=$2 cd $LOCAL_FILE_LOC lftp sftp://$USER:$PASS@$HOST:10022 -e "get $REMOTE_FILE; bye" If file does not exist in sftp server, and file (same as remote file name) exists in local dir,... (4 Replies)
Discussion started by: vhegde1011
4 Replies

6. Shell Programming and Scripting

Copy one file from a server to a local folder

Hi, Is there a way I can copy a file from a server to a local folder (i.e. My Documents)? can it be done by scp? I tried this but it just rename the file as the folder it has to be transferred at. scp -r name@some_server:/home/user/file.txt 'somehere\home\home_dir' Thanks. (4 Replies)
Discussion started by: erin00
4 Replies

7. UNIX for Dummies Questions & Answers

Sftp using batchfile - storing result local

I'm making an sftp-connection to a remote server. I want the result of an ls-command in a local file and the result of ls on another folder in another local file. Because everything has to go as fast a possible I wan't to do everyting in one connection. The command I use is : psftp -v -batch -b... (4 Replies)
Discussion started by: pistach
4 Replies

8. UNIX for Advanced & Expert Users

chrooted SFTP upload folder

Hi List, I have set up a chrooted SFTP setup following the instructions I found on tech republic: /blog/opensource/chroot-users-with-openssh-an-easier-way-to-confine-users-to-their-home-directories/229 I have successfully got it all working and I can download files when logged in via sftp... (0 Replies)
Discussion started by: landossa
0 Replies

9. Shell Programming and Scripting

how to FTP a file from the local folder to unix server

Hi All, please help me to write a shell that ftp a file which is in the local (C:\) drive to a Unix server. Where as i know the IP for the Unix server. i could do this process by using ftp command. pls help me to write as Shell script. Thanks in advance for all of your answers.:b::b: (3 Replies)
Discussion started by: little_wonder
3 Replies

10. UNIX for Dummies Questions & Answers

Copying multiple folders to local machine (don't know folder names)

Hi. I'm trying to copy multiple folders from the remote machine to the local machine. I wrote a batch file to run an ftp window. The problem I am having is that the only command to copy files is mget *, and this copies only files, not folders. For example, ftp ts555 cd ts555/test ' test... (5 Replies)
Discussion started by: leenyburger
5 Replies
Login or Register to Ask a Question