Hi All,,,
Good Morning, I have script which has to ftp a file. I have code written previously:
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 directory
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
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 29
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 29
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
echo "Log File is putfiles${jobid}.log"
cat putfiles${jobid}.log
echo Done
# 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
Here in the script I want to assign the varaiable manuallty.
server=unejyf
user=jye/erui
pwd=the@gu
tdir=/iper
sdir=/etfe/etew/this
cmd=mput
files=anbc
jobid="thelsohjfg"(this is a short jobname for the ftp file name,i.e the temp files in unix shell usees this name).
I am getting this error:
etfe/etew/this
putfiles thelsohjfg.log: No such file or directory
ftpLog3 thelsohjfg.dat: No such file or directory
===================================================================
About to ftp files mput (abc4*) from /etfe/etew/this to /iper
Connec
220
BB
331
Pa
530
Us
Login
FAILED: Cannot login
Status = 98
Can anyone help me changing the code. I am new to this type of scripting.
Thank you
Good Morning, I have script which has to ftp a file. I have code written previously:
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 directory
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
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 29
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 29
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
echo "Log File is putfiles${jobid}.log"
cat putfiles${jobid}.log
echo Done
# 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
Here in the script I want to assign the varaiable manuallty.
server=unejyf
user=jye/erui
pwd=the@gu
tdir=/iper
sdir=/etfe/etew/this
cmd=mput
files=anbc
jobid="thelsohjfg"(this is a short jobname for the ftp file name,i.e the temp files in unix shell usees this name).
I am getting this error:
etfe/etew/this
putfiles thelsohjfg.log: No such file or directory
ftpLog3 thelsohjfg.dat: No such file or directory
===================================================================
About to ftp files mput (abc4*) from /etfe/etew/this to /iper
Connec
220
BB
331
Pa
530
Us
Login
FAILED: Cannot login
Status = 98
Can anyone help me changing the code. I am new to this type of scripting.
Thank you