I cannot seem to retrieve a non-zero return code when calling the ftp macro. It doesn't matter what errors are encountered during the ftp macro execution e.g. directory doesn't exist, file doesn't exists etc.

I'd love to know why.

I'm using bash on Solaris.

My .netrc file looks like so:

machine myftp1
        login xxxxxxxx
        password xxxxxxxxx

macdef getASCIIfiles
       cd $1
       prompt off
       get $2

Executing the following commands

echo "\$ getASCIIfiles Scratch/mydir NON_EXISTANT_FILE.TXT" | ftp -i myftp1    
echo $?

produces the following output

Hash mark printing on (8192 bytes/hash mark).    
Interactive mode on.    
NON_EXISTANT_FILE.TXT: The system cannot find the file specified.    

Why is zero being returned?

  • Maybe use wget or curl instead of ftp?
    – Barmar
    Nov 6, 2014 at 17:02
  • @Barmar It is a legacy system; moving away from ftp is not an option unfortunately Nov 7, 2014 at 11:59

1 Answer 1


The 'ftp' command does not seem to return other error codes than 0.

An alternative solution would be to check the FTP return codes. There is some examples in how to do this here: https://stackoverflow.com/a/4442763

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .