![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| 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 !! |
|
|
||||
| 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 |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
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
}
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 |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
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.
|
|
#3
|
||||
|
||||
|
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.
|
|
#4
|
|||
|
|||
|
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 |
|
#5
|
|||
|
|||
|
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 ...?
|
|
#6
|
||||
|
||||
|
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 |
|
#7
|
|||
|
|||
|
Thanks Dhruva,
That works |
|||
| Google The UNIX and Linux Forums |