Result Code of FTP Script

A. Khattri ajai
Fri Dec 17 17:30:20 PST 2004


On Fri, 17 Dec 2004, Brad De Vries wrote:

> Hey all, does anyone know of a way to obtain the result code of an FTP script?
>
> I have a script file:
> -----------
> open rmt_srv
> user test test123
> cd /incoming
> put file1
> bye
> -----------
>
> When I run "ftp -inv < script_file" the result code is always zero
> even when it fails to connect to the remote server or login.
>
> What I'd like to do is:
> -----------
> ftp -inv < script_file
> rc=$?
>
> if [ $rc -eq 0 ]; then
>   rm -f file1
> else
>   echo "FTP Failure"
> fi
>
> exit $rc
> -----------


Horribly insecure. Why not use ssh to copy the file instead? i.e.

scp file1 test at rmt_srv:/incoming/file1

(The example above assumes you have setup public-key auth between the
machines so no password is required).

Another option is to use a netrc file to automate the ftp session (bleh).


-- 


More information about the Linux-users mailing list