Cannot find downloaded file after SFTP "get" command

0

I am using SFTP to download files from a server. It connects to the server fine and when I enter ls it lists all the files I am looking for.

When I get to the: sftp>, I enter: get [FILENAME]

and then it says:

Fetching /directory/FILENAME to FILENAME
/directory/FILENAME 100%

then it takes me back to: sftp>

I have searched for the file on my computer but I cannot find it. I think the second directory it shows should be the local directory I want the file to be downloaded to right? If so how do I change it?

Mo Gaucho

Posted 2014-10-27T18:40:45.377

Reputation: 3

Answers

0

If you do not specify target path in get command (as the second argument), the OpenSSH sftp downloads the file to the current working directory. That path is not shown anywhere in the output (only file name is in this case).

The output of get is like:

Fetching <1st_arg_of_get=remote_path> to <2nd_arg_of_get=local_path_or_filename_only_if_no_2nd_arg>
<1st_argument_of_get=remote_path>  xxx% sizeKB ....

So generally, you should find the downloaded file in the same path you have started sftp from (= current local working directory). To see the local working directory use command lpwd in sftp. You can also use lcd to change the local working directory.

(I assume your local computer is *nix and the sftp is OpenSSH.)

Martin Prikryl

Posted 2014-10-27T18:40:45.377

Reputation: 13 764

1In most SFTP clients, you can issue the lpwd command which will return the client's local working directory. That should be the calling shell's working directory, but it may not be. You can also use lcd to change the local directory and lls to get the local directory's contents. – Bacon Bits – 2014-10-27T19:24:48.607

@BaconBits Thanks for the comment. I have included this to the answer. – Martin Prikryl – 2014-10-27T19:39:02.917

Additionally, you can usually use ! in your ftp/sftp client to escape to the shell. !pwd and/or !ls would be particularly useful here. – Rich Homolka – 2014-10-27T19:54:56.397

Thank you all so much for your help! I really appreciate it! Everything makes sense now :) – Mo Gaucho – 2014-10-27T20:43:10.520