I am trying to setup a batch job or a script to FTP a file from the RISC box to a drive on my novell server automatically without any user intervention. The problem how can I pipe in the userID and password.
ftp macros are defined in the $HOME/.netrc file. The following steps describe how to create an ftp macro.
Prerequisites
You must have created the $HOME/.netrc file.
To Write a Macro
1.Edit the $HOME/.netrc file to include the following instructions:
macdef init
put schedule
Be sure to insert a blank line at the end of your ftp macro. The blank
line terminates the ftp macro. In the above example, the macdef
subcommand defines the subcommand macro init. The line
following is the command the macro specifies, in this case put
schedule, where schedule is the name of a file.
2.After creating the ftp macro, at the command line prompt, enter:
ftp abyss
In this example, abyss is the host name to which you are connecting.
ftp scans the $HOME/.netrc file for a login definition for the host
abyss and uses the login definition to log the user into abyss.
3.After logging in, at the command line prompt, enter:
ftp init
In this example, ftp scans for the macro named init and executes
the command or commands the macro specifies.
An ftp macro is associated with the login entry immediately preceding it.
ftp macros are not global to the $HOME/.netrc file. The macro init
will be executed automatically upon login. Other macros can be
executed from the ftp prompt (ftp>) by entering the following:
$getit
In this example, the $ executes the ftp macro getit.
----------------------------
I found this generic script which can be modified to suit any circumstance, has some error checking too, perhaps this will help you along. I havent used this as is, but in a highly modified form instead:
echo "open $IP
user $user $pass
$verbose
$type
put $ifile $ofile
close
quit" |$ftp -n
echo "\n##### End FTP Session #####"
foo=`grep -i "does not" $log`
if [ "$?" -eq "0" ] ; then
rc=1
status="${status}Source file does not exist\n"
fi
foo=`grep -i "killed" $log`
if [ "$?" -eq "0" ] ; then
rc=1
status="${status}File transfer process has abended\n"
fi
foo=`grep -i "space" $log`
if [ "$?" -eq "0" ] ; then
rc=1
status="${status}Ran out of disk space before completion of copy\n"
fi
foo=`grep -i "Lost connection" $log`
if [ "$?" -eq "0" ] ; then
status="Successful"
fi
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.