The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Does not exist or unreadable error in windows ftp script rechever Shell Programming and Scripting 3 07-21-2009 12:10 AM
Check file and if it doesnt exist , exit script tententen Shell Programming and Scripting 10 07-17-2009 01:36 AM
Expect Script - While file exist skal5 UNIX for Dummies Questions & Answers 5 01-19-2009 12:30 PM
Need Script to check file exist and compare rbknisely UNIX for Dummies Questions & Answers 1 01-16-2008 01:08 AM
Have a shell script check for a file to exist before processing another file heprox Shell Programming and Scripting 3 11-14-2006 03:26 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 07-21-2009
rechever rechever is offline
Registered User
  
 

Join Date: May 2009
Posts: 20
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 (permalink)  
Old 07-21-2009
zaxxon's Avatar
zaxxon zaxxon is offline Forum Staff  
Moderator
  
 

Join Date: Sep 2007
Location: Germany
Posts: 2,285
Double posting not allowed, read the forum rules!

Thread closed continue here:
FTP from Windows to UNIX
Closed Thread

Bookmarks

Tags
uni

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 08:58 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0