AIX - FTP

Hello,

I have a FTP script below that automatically send files to host. Currently, i am having problems if our network connection is down. Our host cannot receive a file once the network connect is down.

Could there be a additional command that i need to add below so that it would not send files if the network connection is down? It would send this file if the network connection is restored. Because currently we have to check and send it manually. This is VI script though. Thanks.

ftp -n -v testIP << %EOF

user test test2
quote site namefmt 1
bin
put /mydir/RMR_09.txt /theirdir/C$dt-09.txt
put /mydir/sRMR_09.txt /theirdir/S$dt-09.txt

Checking if network is up before you try to ftp will not help if the network goes while a transfer is happening.
I don't know how long a ftp-client usually "hangs" until it receives a timeout and if it really spits out a return code >1 in that case (it should). Different ftp-clients might have different options for this.

ftp is not encrypted and unsecure - maybe switch to ssh/scp/sftp and set up public key authentication, if it is an option. You would also not have to write clear passwords in a file.
You can use helpful options with scp for example like:

    ConnectionAttempts
    ConnectTimeout

see man scp.

You can script a lot of things around it to make it more waterproof for your problem case, but generally I'd say you should try to solve that network problem as priority and implement the ssh/scp/sftp protocol suite.

Oh.. i was not able to put it inside the code box. My apologies.

Anyway, my FTP script is currently in CRON so I cannot see if there was a problem during the transmission of the file. Is there a audit trail that pertains to FTP?

I am not into auditing but there is a RedBook available for that topic from IBM on their RedBook website. Also auditing is more about permissions, who may do what or did what etc. I doubt it has any functionality to check your logics about network down and broken ftp transfers.
My guess is you have to script a bit something yourself to represent the logic needed to do all necessary checks. Maybe you have some job control tool that can help with that.

But is it possible that those files that were not sent through FTP will go on a specified directory (eg. UNPROCESSED directory)? If so, would it be possible to add it in my FTP script above?

Also, i decided in putting a log file on the FTP but apparently it displays all the FTP details during the transmission. Is it possible to only save those lines that corresponds with FTP failure? Or only save a specific word in the file (eg. subcommand received).

EDIT:

Since I can add a "grep" command inside my FTP script, I can minimize the information down to my desired word or phrase. However, I still don't know the exact message when network connection went down during FTP.

Is there anyone who could share it with me?

ftp -n -v testIP << %EOF >> /home/logftp.txt

user test test2
quote site namefmt 1
bin
put /mydir/RMR_09.txt /theirdir/C$dt-09.txt
put /mydir/sRMR_09.txt /theirdir/S$dt-09.txt

Thanks.