The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
display the result of wc -l with words before and after the result melanie_pfefer UNIX for Dummies Questions & Answers 3 04-30-2008 04:33 AM
How to get a result of a cmd into variable? manchau UNIX and Linux Applications 1 03-06-2008 04:36 AM
Outputting formatted Result log file from old 30000 lines result log<help required> vikas.iet Shell Programming and Scripting 5 12-02-2007 07:43 PM
sFTP result mpang_ Shell Programming and Scripting 4 08-01-2007 07:06 PM
result of find mpang_ Shell Programming and Scripting 1 05-01-2006 08:00 PM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 05-29-2008
Registered User
 

Join Date: Dec 2007
Posts: 9
result of ftp

Hi friends,
I am trying to FTP a file to a different server. My script is given below

Code:
command=`ftp -n $FTP_HOST <<END_SCRIPT
user $FTP_USER $FTP_PASSWD 
lcd $TEMPFOLDER
cd $FTP_LOCATION
put $FILE
bye 
END_SCRIPT`
result="$command"
echo "result is $result"

if [ -z $result ] ; then
      echo "successfully FTPed the file"
   else
      echo "Failed to FTP the report file"
fi

}
but int the result variable what I am getting is Local directory now /home/...

And if the server name is wrong the result variable has value not connected.

can anyone help me to find out why it is like that..

Last edited by Yogesh Sawant; 05-29-2008 at 05:28 AM. Reason: added code tags
Reply With Quote
Forum Sponsor
  #2  
Old 05-29-2008
era era is offline
Herder of Useless Cats
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,650
You are collecting the output from the ftp script in command and then simply copying that to result so the variable will contain whatever ftp printed.
Reply With Quote
  #3  
Old 05-29-2008
Dhruva's Avatar
Registered User
 

Join Date: Mar 2006
Location: India
Posts: 255
Script is fine and result it is giving is as expected.If you can frame what result you are looking for then we can give a shot.
Reply With Quote
  #4  
Old 05-29-2008
Registered User
 

Join Date: Dec 2007
Posts: 9
Thanks Dhruva and era.
Is there any way that I can prevent the ftp from printing the message local directory.....
I mean customizing the ftp output.. ie. If everything went on well.. I should get a success message... otherwise.. failure message
Reply With Quote
  #5  
Old 05-29-2008
era era is offline
Herder of Useless Cats
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,650
Why not just adapt your script to cope with the range of possible outputs? If the output is the lcd output and nothing else, assume success ...?
Reply With Quote
  #6  
Old 05-29-2008
Dhruva's Avatar
Registered User
 

Join Date: Mar 2006
Location: India
Posts: 255
This code will work but you need to chk one thing,the code 226.
Code:
ftp -nvi ipaddress <<EOF >logfile.txt
user username password
lcd /local directory path
cd /Remote directory path
put filename
bye
EOF
#pls confirm the success code is 226 if file ftped
x=`grep -o 226 logfile.txt`
if [ "$x" -eq 226 ]
 then
echo "successful"
else
echo "failed"
fi
Reply With Quote
  #7  
Old 05-29-2008
Registered User
 

Join Date: Dec 2007
Posts: 9
Thanks Dhruva,
That works
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 07:31 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0