Skip to content
Home » Linux » FTP batch files

FTP batch files

I found this question on the Sys Admin magazine forum:
Can I create a batch file (or something else) to allow me to execute my file transfer from a Tru64 UNIX to a NT without having to type each command? This is what I’m doing now to transfer a recompiled data base from UNIX to NT: At the NT machine:

C:> cd\sandgis
sandgis> erase *.*
are you sure? Y
sandgis> ftp
name: *******
passwd: ********
ftp> cd /data/sandgis
ftp> prompt off
ftp> bin
ftp> mget *.*
ftp> cd /apps/sandcauv
ftp> mget par*.*
ftp> quit
sandgis> cd info
sandgis\info> erase *.*
are you sure? Y
sandgis\info> ftp
name: ****
passwd: *****
ftp> cd /data/sandgis/info
ftp> bin
ftp> prompt off
ftp> mget *.*
ftp >quit
(this is half of it)

Well, you get the idea… I can get a batch file to work until it goes into FTP, then it stops. Since I’ve got to do this on five NT machines twice a week and the total files size is near half a gig., this is very time consuming.

And here’s the response I submitted:

Put your pre-FTP commands in a batch file, as it sounds like you already have, then add the -s:[textfile] parameter to your FTP statements containing FTP commands, e.g. ftp -s:ftp1.txt

The contents of ftp1.txt, based on your example:
prompt off
mget *.*
cd /apps/sandcauv
mget par*.*

Anything you put in a file specified by the -s parameter gets fed to your FTP client.

So, you’ll need a batch file, plus a text file for each FTP session, which could turn into a real mess of files, but it’s a whole lot better than typing all that garbage twice a week.

%d bloggers like this: