I am wondering if with an FTP command line utility, you can use the FTP get command to get a file with an absolute path, as opposed to having to cd into each successive directory to get a file.

When I type

ftp> get pub/sdc.tgz

Or even this (with one or two slashes before pub)

ftp> get /pub/sdc.tgz

It tells me it cannot find the file:

local: /pub/sdc.tgz remote: /pub/sdc.tgz
ftp: local: /pub/sdc.tgz: No such file or directory

However when I instead do

ftp> cd pub
ftp> get sdc.tgz

It works totally fine.

Is there any correct syntax in the ftp command line to get a file with an absolute path, or do I need to cd into pub first to do it?

(FYI: What I am trying to do is use a PERL script that runs daily that saves a file to an FTP server, then a later script that will 1. get the file -- which I am not opposed to using wget to do -- and 2. delete the file after I get it, which I need to do with FTP. I want the file to be deleted by the second script, so that in the future if the first script has trouble saving the file to the FTP server, the second script will know that there was an error because the file is not there. I could save it with different names too, but I do not want to pollute the FTP server with a ton of files from different days.)


2 Answers 2


It's because when you use FTP's Get, and don't specify a local path/file name, it tries to use the same path/name as the Remote file.

This error:

ftp: local: /pub/sdc.tgz: No such file or directory

Is telling you it can't find the file on the LOCAL machine. So my assumption would be that you don't have a "pub" folder on in the root of your local drive.

Syntax: get remote-file [local-file]


remote-file - Specifies the remote file to copy.

local-file - Specifies the name to use on the local computer. If not specified, the file is given the remote-file name.

So try something like:

ftp> get pub/sdc.tgz c:\temp\sdc.tgz

or perhaps

ftp> get pub/sdc.tgz .\sdc.tgz

To download it to the current folder.

See here for more info on Get usage.

Related SU Question: Can I specify a destination with the ftp get command?


You can use ncftpget, which uses absolute paths, if you can install it in your client machine.

Also, if you are using Perl, then you can take a look at the FTP module.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.