Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

FTP novell

Status
Not open for further replies.

Iwitt

MIS
Mar 7, 2000
9
0
0
US
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.


Thanks for your help

Iklon
 
I didn't think that Novell did tcp without special software...
There use to be fastconnect and stuff....

but if we are talking tcp, you can create a macro to pass password and commands


Writing Macros

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:

#!/bin/ksh
bindir=/usr/local/scripts
logdir=/usr/local/scripts
ftp=/usr/bin/ftp
Email=user@domain.com
IP=xxx.xxx.xxx.xxx
user=username
pass=password
ifile="[source file]"
ofile="[destination file]"
type=asc
myname=`basename $0`
verbose="verbose"
dd=`date +%d%m`
log=$logdir/$dd.log
host=`hostname`
rc=0
boj=`date`

exec 1>$log 2>&1

echo "\n##### Begin FTP Parameters #####\n"
echo "Program Name: $myname"
echo "Process ID: $$"
echo "Log file name: $log"
echo "Email: $Email"
echo "Source Machine $host"
echo "Destination Machine: $IP"
echo "User ID: $user"
echo "Password: ##############"
echo "Source File: $ifile"
echo "Destination File: $ofile"
echo "\n##### End FTP Parameters #####\n\n"

echo "##### Begin FTP Session #####\n"

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

eoj=`date`
echo "\nJob start time: $boj"
echo "Job end time: $eoj"
echo "\nResult code: $rc ($status)"

mail -s &quot;FTP results from $myname&quot; $Email <$log
IBM Certified Specialist - MQSeries
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top