Getting exit status code from 'ftp' command in linux shell

后端 未结 6 1190
半阙折子戏
半阙折子戏 2020-12-28 23:08

I need to retrive the exit status code from a command line program. No worries, I used $?. But for ftp, even if it doesn\'t connect, it opens the ftp shell, so I\'m not able

6条回答
  •  醉话见心
    2020-12-28 23:10

    If you need to download something and see if the download succeeded, why don't you use wget? It supports the FTP protocol.

    It will report the status of the download with several return codes (quote from man page):

    EXIT STATUS
       Wget may return one of several error codes if it encounters problems.
       0   No problems occurred.
       1   Generic error code.
       2   Parse error---for instance, when parsing command-line options, the .wgetrc or .netrc...
       3   File I/O error.
       4   Network failure.
       5   SSL verification failure.
       6   Username/password authentication failure.
       7   Protocol errors.
       8   Server issued an error response.
    

提交回复
热议问题