Using a .netrc file combined with a “Here Document” for ftp scripting can simplify ftp scripting by automating the login and setting up macros – that can be run from a scripted ftp session

Here is an example .netrc file from something I did recently. ┬áNote do a “chmod 600 .netrc” after you have created the file to give it the correct file permissions to be used.

  • the first line specifies a machine name that can be automatically logged into


machine myhostname login remoteusername password remotepassword

Now here is the “Here Document” contained in the bash script testf.bash that does most of the work.


dtstr=$(date +%Y_%m_%d); export dtstr
cd /u01/app/oracle/fast_recovery_area/PROD/backupset/$dtstr
echo “date is: “$dtstr
ftp -v rh2 <<EOFMark
mkdir $dtstr
cd $dtstr
mput *

Leave a Reply

Your email address will not be published. Required fields are marked *