How to automate a ftp session

From Wiki-UX.info
Jump to: navigation, search


Abstract[edit]

This article show a simple shell script that can be used to automate a FTP session on HP-UX 11i Operating Environment. The procedure uses the ftp client command -n option.

Procedure[edit]

This procedure is useful to automate the download or upload of file using cron or at jobs. Add all the required ftp commands between the << EOF ... EOF statements.

#! /usr/bin/sh
ftp -n <hostname> << EOF
       debug
       user <uid> <password>
       idle <seconds>
        
       <other commands>

       quit
       EOF

Example[edit]

To download the /etc/passwd file, use the following script:

#! /usr/bin/sh
ftp -n crd370 << EOF 
       debug
       user root MyPassword
       idle 10
        
       cd /etc
       get passwd

       quit
       EOF

Authors[edit]