From Wiki-UX.info

Wiki-UX / File Transfer Protocol / How to automate a ftp session
Jump to: navigation, search

How to automate a ftp session

Abstract

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.

Contents


Procedure

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

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

This page was last modified on 3 August 2010, at 02:21. This page has been accessed 1,415 times.