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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ftp

Status
Not open for further replies.

kumariaru

IS-IT--Management
Mar 9, 2006
61
AU
Hi all,
I am doing Ftp of a file from one server to other server.When I run the shell script it is showing me this:

======
About to ftp files mput (POP*) from /etv/BO/wor/sta to /Peft
(to)
u
Not
co
Not
co
Status = 0
 
Post your script. It's hard to debug it without seeing what it's doing.
 
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

 
And what is the content of putfiles${jobid}.log ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Hi PHV,
jodid is going a name assigned.And I am assigning this in my job(datastage) manually.
 
I asked about the content of this file after you runned the script as I think the answer is here.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Add these lines right before the final [tt]exit[/tt]...
Code:
echo "Log file is putfiles${jobid}.log"
cat putfiles${jobid}.log
echo Done
Then run it again and post what it displays.
 
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

with regards
kumari
 
So, now you know for sure that the transfert wasn't successful.
 
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.

sever$1 29

Thanks
Kumari
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top