The way that I have written ftp scripts in the past is with the
following format. I write a function that creates a separate ftp
script (e.g. makeFTP). Then I call that script once it has been
generated. See the example below:
makeFTP()
{
echo "ftp -in << END" > ftpfile
echo "verbose on" >> ftpfile
echo "open <servername> >> ftpfile
echo "binary" >> ftpfile
echo "user $user $passwd" >> ftpfile
echo "cd $sourcedirectory" >> ftpfile
.... #other ftp commands also redirected to ftpfile
echo "bye" >> ftpfile
echo "END" >> ftpfile
chmod 775 ftpfile
Quote:}
Then with in your script you can call
ftpfile to perform the ftp for you. I also
suggest redirecting it to an output file so
you can see that the execution worked correctly.
E.G -- ftpfile > file.out
Hope this helps.
Tabitha
Quote:> I need to write an FTP script that will fetch files. The both machines
> running linux.
> How would you go about doing that? I tried a bit, but couldn't get it
to
> work. It would be fine putting the userid and password in the script,
since
> this job should run (via cron) every morning.
> Please help or point me in the right direction. I know how to do it,
using
> the plain ftp program. Just the script bothering!
Sent via Deja.com http://www.deja.com/
Before you buy.