Oracle ftp script
Automate your file transfers.
Make sure you always test this oracle ftp script on a test server before implementing it
on a production system !
on a production system !
If you are using a recent version of Linux, you should investigate scp as an alternative to FTP.
Below is a script to automate transferring files from one server to another.
In this case, we're ftp'ing archive log files from the standby server back to the production server. (prod.world.com)
The trick to this script is to make sure that all the files to be ftp'ed have a similar filename structure,
which is always the case with archive log files.
There are 2 examples.
The first one shows you how to ftp a range of filenames, the second one transfers all filenames in a directory.
Both scripts are saved as ftp_commands.txt.
To run it in the background (so that it does not get killed if your session gets disconnected),
you will need to be located in the directory where the archive log files are on the standby server
and you would run it as follows:
nohup ftp -ivn prod.world.com < ftp_commands.txt &
You can check its progress by tailing nohup.out in the directory where you executed the command.
tail -f nohup.out
First script:
(note how we transfer a range of files with mput, and the last single file with put).Contents of ftp_commands.txt:
user oracle oraclepassword
binary
cd /logs/proddb/arch
prompt off
mput proddb_1_2514*.arc
mput proddb_1_2515*.arc
mput proddb_1_2516*.arc
mput proddb_1_2517*.arc
mput proddb_1_2518*.arc
mput proddb_1_2519*.arc
mput proddb_1_2520*.arc
put proddb_1_25210.arc
bye
binary
cd /logs/proddb/arch
prompt off
mput proddb_1_2514*.arc
mput proddb_1_2515*.arc
mput proddb_1_2516*.arc
mput proddb_1_2517*.arc
mput proddb_1_2518*.arc
mput proddb_1_2519*.arc
mput proddb_1_2520*.arc
put proddb_1_25210.arc
bye
Second script:
Contents of ftp_commands.txt:
user oracle oraclepassword
binary
cd /logs/prodb
prompt off
mput *.*
bye
binary
cd /logs/prodb
prompt off
mput *.*
bye
Recommended reading:
An introduction to Linux commands.


