Hi Sam,
Here is my script.I am assigning the remaining variable values through routine(used in datastage).
function checkStatus {
Status=0
errmsgtest=`cat putfiles${jobid}.log`
if [[ $errmsgtest = "" ]]; then
echo FAILED: No messages found
echo Status = 99
exit 99
fi
errmsgtest=`grep -c 'The system cannot find the file specified' putfiles
${jobid}.log`
if [[ $errmsgtest -ge 1 ]]; then
echo The system cannot find the file specified
echo Status = 97
exit 97
fi
errmsgtest=`grep -c 'A file or directory in the path name does not exist
' putfiles${jobid}.log`
if [[ $errmsgtest -ge 1 ]]; then
echo A file or directory in the path name does not exist
echo Status = 97
exit 97
fi
errmsgtest=`grep -c 'No such file or directory' putfiles${jobid}.log`
if [[ $errmsgtest -ge 1 ]]; then
echo FAILED: No such file or directory - Check source and target dire
ctory
echo Status = 97
exit 97
fi
errmsgtest=`cut -f2 -d\: putfiles${jobid}.log`
echo $errmsgtest>ftpLog3${jobid}.dat
errmsgtest2=`cut -c1-20 ftpLog3${jobid}.dat`
if [[ $errmsgtest2 = "unknown host or inva" ]]; then
echo FAILED: Invalid IP address
echo Status = 96
exit 96
fi
errmsgtest=`cut -c1-6 putfiles${jobid}.log`
for msg in $errmsgtest; do
echo $msg
if [[ $msg = "Login" ]]; then
echo FAILED: Cannot login
echo Status = 98
exit 98
fi
if [[ $msg = "?Inval" ]]; then
echo FAILED: Invalid command
echo Status = 97
exit 97
fi
done
}
# Setup Variables
server=$1 29
user=$2
pwd=$3
tdir=$4
sdir=$5
cmd=$6
files=$7
jobid=$8
if [[ $9 = "Y" ]]; then
files="${files}*"
fi
cd $sdir
d=`pwd`
echo $d
if [ $d = $sdir ]
then
rm putfiles${jobid}.log
rm ftpLog3${jobid}.dat
#Begin ftp process
echo ===================================================================
echo About to ftp files $cmd \($files\) from $sdir to $tdir
if [[ $cmd = "mput" ]]; then
echo "open $server
user $user $pwd
cd $tdir
$cmd $files
quit " | ftp -i -n -v > putfiles${jobid}.log
fi
if [[ $cmd = "put" || $cmd = "append" ]]; then
echo "open $server
user $user $pwd
cd $tdir
$cmd $files
quote site chmod 666 $files
quit " | ftp -n -v > putfiles${jobid}.log
fi
else
rm putfiles${jobid}.log
rm ftpLog3${jobid}.dat
echo 'No such file or directory' > putfiles${jobid}.log
fi
checkStatus
# Delete Files from source directory
#echo About to delete files \($files\) from $sdir
#cd $sdir
#rm $files
#if no errors, exit normally
echo Status = 0
exit 0
Hi Sambones,
Here is the message I am getting after adding the given code:
About to ftp files mput (POP*) from /etv/BO/wor/sta to /Peft
(to)
u
Not
co
Not
co
Log File is putfiles.log
(to) usage: open host-name [port]
Not connected.
Not connected.
Done
Status = 0
Hi PHV,
Yes, I came to know the error. But I want to know why I am not able to connect. While I am able to connect manually and also able to transfer the file. I feel like the problem is with the port. I have assigned the port number beside the server in the script, even i am logging too the server by assigning the port number.
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.