1

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
       hash
       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.    
0

Why is zero being returned?

  • Maybe use wget or curl instead of ftp? – Barmar Nov 6 '14 at 17:02
  • @Barmar It is a legacy system; moving away from ftp is not an option unfortunately – Bobby Kenny Nov 7 '14 at 11:59
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

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.