file does not exist or unreadable in an FTP script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting file does not exist or unreadable in an FTP script
# 1  
Old 07-21-2009
file does not exist or unreadable in an FTP script

I will appreciate any help with this...
I have a file in this directory that looks like: this
07210900.SUP, I am getting the following error:

Activities for Tue Jul 21 07:29:14 EDT 2009:
File 07210900.SUP does not exist or unreadable
End of activities

The idea is to capture the file in the CDRemoteDir then change the name
to a new name and then ftp to a unix directory.
the XXXX is me changing some code (security reasons)

CDRemoteDir='cd orgs/"Financial Aid"/"MIIS"/"0910"/"FTP" ';
ScriptName="miis_ftp.ELM_SUP.shl";
UpLoadFileName=`date "+%m%d%y"00.SUP`;
NewName= "eluppdtop.dat" ;

Here is the all script

Code:
MPATH=$BANNER_HOME;
JOBNUM=$ONE_UP;
USER=$BANUID;
LPATH="/u02/sct/banjobs/";
RemoteHost="files.xxxxxxx.edu";
### look at this
RemoteUser="xxxx_xxxxx";
RemotePass="xxxxxxx";
 
CDRemoteDir='cd orgs/"Financial Aid"/"MIIS"/"0910"/"FTP" ';
ScriptName="miis_ftp.ELM_SUP.shl";
UpLoadFileName=`date "+%m%d%y"00.SUP`;
NewName= "eluppdtop.dat" ;
 
TMode="ascii"; # Transfer mode
EmailAddress="xxxxxxi@hhhhhh.edu";
LogFileName="miis_ftp.ELM_SUP_${USER}_${JOBNUM}.log";
LogFile="${LPATH}${LogFileName}";
TodayDate=`date`;
echo "\nActivities for "$TodayDate":" >> $LogFile;
#========================================================================#
# 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 eluppdtop.dat File Upload" $EmailAddress < EmailMessage;
rm EmailMessage;
fi
echo "End of activities\n" >> $LogFile
# Exit the program since error occurred
exit 1;
}
#========================================================================#
# Change the directory to one contains the file to be transported
##cd $LocalDir;
cd $CDRemoteDir;
# Do an -r command on the desired file ensure that the file exist and readable
if [ ! -r $UpLoadFileName ]
then
type="1";
ErrorHandle;
fi
# Do an -s command on the desired file ensure that the file exist
# and is not null
if [ ! -s $UpLoadFileName ]
then
type="2";
ErrorHandle;
fi
 
#========================================================================#
# Initiate the FTP process
# Loop through remaining parameters to create ftp commands.
(
# Enter user-name and password in host machine
echo "user $RemoteUser $RemotePass"
# Set transfer mode
echo $TMode
# Change directory in host machine
echo ${CDRemoteDir}
# Change local directory in local machine
echo lcd $LocalDir
# Transfer original file name
echo put $NewName
# End ftp session
echo quit
) | ftp -vin $RemoteHost >> $LogFile
# End of FTP Process

#========================================================================#

Last edited by vgersh99; 07-21-2009 at 09:22 AM.. Reason: fixed code tag
# 2  
Old 07-21-2009
Double posting not allowed, read the forum rules!

Thread closed continue here:
https://www.unix.com/shell-programmin...dows-unix.html
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Checking FTP server file exist or not

I am trying to delete old file in ftp server, after transferring new file successfully . but here i am checking both the file available or not using ls command. if both the file available means i need to get file_new and file_old file size as greater than zero. but i am getting only for... (3 Replies)
Discussion started by: elango963
3 Replies

2. Shell Programming and Scripting

Verifying if a file exist (script shell)

Hello, This is my code: nb_lignes=`wc -l $1 | cut -d " " -f1` for i in $(seq $(($nb_lignes - 1)) ) do machine=`head $1 -n $i | tail -1` machine1=`head $1 -n $nb_lignes | tail -1` ssh root@$machine -x " scp /home/file.txt root@$machine1:/home && rm -r /home/file.txt" done fi ... (2 Replies)
Discussion started by: chercheur857
2 Replies

3. Shell Programming and Scripting

Shell script to check files if exist else touch the file

Hi All, Thanks in Advance I wrote the following code if then echo "version is 1.1" for i in "subscriber promplan mapping dedicatedaccount faflistSub faflistAcc accumulator pam_account" do FILE="SDP_DUMP_$i.csv" echo "$FILE" ... (5 Replies)
Discussion started by: aealexanderraj
5 Replies

4. Shell Programming and Scripting

Curl ftp upload success but no file exist on the server !!!!

hello, I'm trying to upload a file to this ftp server and others ftp://ftp.byethost12.com as you can see in the output of CURL using the -v option curl reports that the upload succeeded but when i connected to the server with file-zilla there is no file uploaded the same command upload files... (5 Replies)
Discussion started by: laraaj
5 Replies

5. Shell Programming and Scripting

Does not exist or unreadable error in windows ftp script

I have a file like this 07200900.SUP,in a windows directory I need to FTP this file to UNIX , the directory in unix is N:\orgs\Financial Aid\MIIS\0910\FTP I am getting this error miis_ftp.ELM_SUP.shl: =cd orgs/"Financial Aid"/"MIIS"/"0910"/"FTP" : not found IN THE LOG FILE Activities for Mon... (3 Replies)
Discussion started by: rechever
3 Replies

6. Shell Programming and Scripting

Check file and if it doesnt exist , exit script

Hi, Another problem, here is my code #!/bin/sh dir='/opt/apps/script/CSV' datadir='/opt/apps/script/data' while : ; do ls -1rt $dir/*.csv > /dev/null 2>&1 if ;then cp $datadir/weekly.txt $dir/weekly.csv else exit 0 fi done (10 Replies)
Discussion started by: tententen
10 Replies

7. UNIX for Dummies Questions & Answers

Expect Script - While file exist

Hi: Can anyone help me with the while loop in expect script. Following is my scenario: 1. one of my process is running and looking for a file 2. as soon as the file is dropped the proces then processes the file and creates a control file ".ctl" to indicate end of process for that file ... (5 Replies)
Discussion started by: skal5
5 Replies

8. UNIX for Dummies Questions & Answers

Need Script to check file exist and compare

I need a script that will check for the existence of new files that FTP'd in the morning, results go to log file. The 2nd step is to compare the new file with the previous days file. If the new file size is 30% or more smaller in size then previous day this needs to also be sent to log. This... (1 Reply)
Discussion started by: rbknisely
1 Replies

9. UNIX for Dummies Questions & Answers

Unreadable Unix File

Hi Everyone, I have a question for you all. I am working at a company and we are trying to recover .dat files which were created on an older linux box and we have a folder of .dat files that are unreadable. When you try to open them in a text editor you get jibberish all shapes and sizes and... (19 Replies)
Discussion started by: ryangfm
19 Replies

10. Shell Programming and Scripting

Have a shell script check for a file to exist before processing another file

I have a shell script that runs all the time looking for a certain type of file and then it processes the file through a series of other scripts. The script is watching a directory that has files uploaded to it via SFTP. It already checks the size of the file to make sure that it is not still... (3 Replies)
Discussion started by: heprox
3 Replies
Login or Register to Ask a Question