The UNIX and Linux Forums  

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
Check FTP Status april Shell Programming and Scripting 2 05-06-2009 09:04 AM
Script to check status of a PID zeekblack Shell Programming and Scripting 14 10-03-2006 04:09 PM
Automated FTP to variable directory with error check songtam UNIX for Dummies Questions & Answers 3 04-10-2006 10:57 AM
check the status and send an email with status isingh786 Shell Programming and Scripting 3 12-29-2005 07:22 PM
Ftp Status Check acheepi Shell Programming and Scripting 4 09-08-2005 04:23 PM

 
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
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 03-03-2004
anijog anijog is offline
Registered User
  
 

Join Date: Feb 2004
Posts: 3
Status check of Automated FTP

Hi,

I've following code fragment as a part of 1 of my scripts.

Function is supposed to perform automated ftp to designated host.

Here are the details:-

#! /usr/bin/ksh

< some code>


perform_ftp()
{

#Assume that file to transfer is available in current directory

TMP_FILE=/tmp/$$-FTP
echo " open <hostname>" > ${CMD_FILE}
echo "user <user name> <password> " >> ${CMD_FILE}
echo "put <some file> " >> ${CMD_FILE}
echo "bye" >> ${CMD_FILE}

ftp -vin < ${CMD_FILE} 1> /dev/null 2>>${ERROR_LOG}

if [ $? -ne 0 ]; then
echo "\nError Transmitting the file"
rm -f ${CMD_FILE}
exit 1
else
echo "\nSuccessfully Transmitted report file."
fi

rm -f ${CMD_FILE}

}

The problem with above function is that even though the actual put command is not successful, say because file system is full or lack of appropriate permission, script will always report that file was transmitted successfully.

This is because last command "bye" executed as a part of FTP is always successful & "$?" always returns 0.

Any pointers how can I check whether "put" command was successful or not?

P.S. :- Requirement is not to log output of ftp command in ERROR_LOG. It has to be discarded, no matter whether FTP is successful or not.






}
 

Bookmarks

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 09:15 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