have this shl that will FTP a file from the a directory in windows to UNIX, It get the name of the file stored in this variable $UpLoadFileName then put in the local directory LocalDir="${MPATH}/xxxxx/dat_files" that part seems to be working, but then I need to take that file and rename, I am using another shl do do this, look at the end of the code when I call sh pain, I will put the code of that shl at the end also, if I run the two shls separately, it works but when I call the shl pain from the main one it does not work
Here is the code from I called the main shl
MPATH=$BANNER_HOME;
JOBNUM=$ONE_UP;
USER=$BANUID;
JOBNAME="RZPEFT";
AT_SIGN="@";
set -x
##set +x
LPATH="/u02/sct/banjobs/";
RemoteHost="xxxxxxxxxxxxxxx";
### look at this
RemoteUser="xxxxx_finaid";
RemotePass="xxxxx";
LocalDir="${MPATH}/xxxxx/dat_files";
##LocalDir = "${MPATH}/dataload/finaid"
##CDRemoteDir='cd \orgs\"Financial Aid"\"MIIS"\"0910"\"FTP" ';
var1='cd orgs\Financial'
var2='Aid\MIIS\0910\FTP'
CDRemoteDir=$var1$var2
## Grab the file
ScriptName="rzpeftf.shl";
## Grab the file
ScriptName= "rzpeftf.shl";
UpLoadFileName=`date "+%m%d%y"00.DSB`;
echo "UpLoadFileName" $UpLoadFileName
TMode="ascii"; # Transfer mode
EmailAddress="xxxxxx@xxxxx.edu";
LogFileName="rzpeftf_${USER}_${JOBNUM}.log";
LogFile="${LPATH}${LogFileName}";
TodayDate=`date`;
echo "\nActivities for "$TodayDate":" >> $LogFile;
LF1=${LPATH}${LogFileName};
LF2=${LPATH}${LogFileName};
SHL_SCRIPT_PATH="${MPATH}/xxxxx/shl/";
##set variables for Error testing and messages
ERROR_NAME="error_message_.rzpdsf_shl";
ERROR_RUN="${SHL_SCRIPT_PATH}${ERROR_NAME}";
ERROR_TEST_NAME="error_testing_routine.shl";
ERROR_TEST_ROUTINE="${SHL_SCRIPT_PATH}${ERROR_TEST_NAME}";
ERR_VAR="NO";
ERROR_USER="error_message_user.shl";
ERROR_RUN_USER="${SHL_SCRIPT_PATH}${ERROR_USER}";
#========================================================================#
# Error Handling Function
function ErrorHandle
{
# if type is 1, then the file does not exist or unreadable
if [ $type -eq 1 ]
then
echo "File "$UpLoadFileName" does not exist or unreadable" >> $LogFile;
echo "Subject: Error in Running Script\n Error in uploading file script "$ScriptName". File "$UpLoadFileName" does not exist or unreadable" > EmailMessage;
sendmail -F " File Upload" $EmailAddress < EmailMessage;
rm EmailMessage;
fi
# if type is 2, then the file has zero size
if [ $type -eq 2 ]
then
echo "File "$UpLoadFileName" has a zero size value" >>$LogFile;
echo " Subject: Error in Running Script\n Error in uploading file script "$ScriptName". File "$UpLoadFileName" has a zero size value" > EmailMessage;
sendmail -F "The $UpLoadFileName File Upload" $EmailAddress < EmailMessage;
rm EmailMessage;
fi
echo "End of activities\n" >> $LogFile
# Exit the program since error occurred
exit 1;
}
###here adding
# Before copying the file, we need to remove the same name file if exists
if test -a ${LocalDir} ${NewName}
then
echo " " >>${LF1} 2>>${LF2}
echo "Found ${LocalDir} ${NewName} file in the dir, will remove first" >>${LF1} 2>>${LF2}
rm ${LocalDir} ${NewName} >>${LF1} 2>>${LF2}
ERR_VAR=$($ERROR_TEST_ROUTINE $LogFileName);
if [ $ERR_VAR = 'NO' ]
then
echo "Successfully remove ${LocalDir}${NewName} " >>${LF1} 2>>${LF2}
else
echo "Error: could not remove ${LocalDir}${NewName} file" >>${LF1} 2>>${LF2}
echo " " >>${LF1} 2>>${LF2}
sh ${ERROR_RUN} >>${LF1} 2>>${LF2}
echo "Warning Email message sent to tech staff. " >>${LF1} 2>>${LF2}
echo " " >>${LF1} 2>>${LF2}
sh ${ERROR_RUN_USER} >>${LF1} 2>>${LF2}
echo "Warning Email message sent to user. " >>${LF1} 2>>${LF2}
echo " " >>${LF1} 2>>${LF2}
echo "Script Ended and no updating done." >>${LF1} 2>>${LF2}
exit 1
fi
fi
###here adding
#========================================================================#
# Change the directory to one contains the file to be transported
$CDRemoteDir;
#========================================================================#
# Change dir to where the ftp will place the uploaded file
cd ${LocalDir}
# Initiate the FTP process
ftp -n $RemoteHost <<!EOF
quote user $RemoteUser
quote pass $RemotePass
cd orgs
cd "Financial Aid"
cd MIIS
cd 0910
cd FTP
get $UpLoadFileName
sh pain
quit
!EOF
shl pain
# End of FTP Process
#
Here is the shl pain
#! /bin/sh
file_seq=$( < /u02/sct/banner/bandev2/xxxxx/misc/EFTSQL.dat)
echo $file_seq "file_seq"
file2=eft$(expr $file_seq + 1).dat
echo $file2 "file2"
file3=eftsql$(expr $file_seq + 1).dat
echo $file3 "file3"
the idea is to read the file
1234 file_seq
then incremented by one
eft1235.dat file2
eftsql1235.dat file3
then take this name and rename $UpLoadFileName from the main shl eftsql1235.dat
then I have to increment the file in the following directory in by one
/u02/sct/banner/bandev2/xxxxxxx /misc/EFTSQL.dat)
so next time I run the process 1235 will be on that file (EFTSQL.dat)
so the new sequenc will be 1235 + 1
I am using the file in /u02/sct/banner/bandev2/xxxx/misc/EFTSQL.dat as a sequence..