result of ftp


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers result of ftp
# 1  
Old 05-29-2008
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 09:28 AM.. Reason: added code tags
# 2  
Old 05-29-2008
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  
Old 05-29-2008
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  
Old 05-29-2008
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  
Old 05-29-2008
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  
Old 05-29-2008
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  
Old 05-29-2008
Thanks Dhruva,
That works Smilie
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to compare the current result with previous line result.?

Hi Gurus, I have requirement to compare current result with previous reuslt. The sample case is below. 1 job1 1 1 job2 2 1 job3 3 2 job_a1 1 2 job_a2 2 2 job_a3 3 3 job_b1 1 3 job_b2 2 for above sample file, GID is group ID, for input line, the job run... (1 Reply)
Discussion started by: ken6503
1 Replies

2. Solaris

FTP log only shows FTP LOGIN FROM entry?

OS: Solaris 9 Configuration /etc/syslog.conf daemon.debug /etc/inetd.conf ftp stream tcp6 nowait root /usr/sbin/in.ftpd in.ftpd -A -l -d Found the ftp.log only generate those entries from other servers/hosts. Can we trace on all ftp entries either from/to the server? ... (6 Replies)
Discussion started by: KhawHL
6 Replies

3. HP-UX

[Solved] Unable to rename file in ftp server .Net:FTP perl

Hello All, I am trying to connect to ftp server and get the files. Also i need to rename the file in other ftp dir. rename method is not allowing me to rename the file in other dir. When i tried copy command by using net::FTP:FILE then perl says it is not installed. Can some body help me to... (2 Replies)
Discussion started by: krsnadasa
2 Replies

4. Shell Programming and Scripting

Automated FTP script using .netrc to multiple FTP servers

Hi all, I'm using the following script to automated ftp files to 1 ftp servers host=192.168.0.1 /usr/bin/ftp -vi >> $bkplog 2>&1 <<ftp open $host bin cd ${directory} put $files quit ftp and the .netrc file contain machine 192.168.0.1 login abc... (4 Replies)
Discussion started by: varu0612
4 Replies

5. Shell Programming and Scripting

passing parameter to ftp script from output of another ftp

Hi, I have a ftp script which first gets all the file names and echo's the latest file. I'm using another ftp command sets to get the file name given by first ftp. The problem is the parameter is not accepted by second ftp. The error message i'm getting is > Rename Temp File calloc:ICMP... (5 Replies)
Discussion started by: ammu
5 Replies

6. UNIX for Advanced & Expert Users

Using FTP to check whether file is completely FTP... plz find the description below

Hi, We have some clients who will place huge files in to one of the remote server. And the shell script written in our local server to retrieve client files (using FTP) placed on one of the remote server of ours by clients. My question Is there any FTP command/script to check from my local... (1 Reply)
Discussion started by: nmsrao
1 Replies

7. UNIX for Dummies Questions & Answers

display the result of wc -l with words before and after the result

hello showrev -p | wc -l returns: 381 What to do in case I want to have this output: number of lines returned by showrev -p is: 381 thx (3 Replies)
Discussion started by: melanie_pfefer
3 Replies

8. Shell Programming and Scripting

Outputting formatted Result log file from old 30000 lines result log<help required>

Well I have a 3000 lines result log file that contains all the machine data when it does the testing... It has 3 different section that i am intrsted in 1) starting with "20071126 11:11:11 Machine Header 1" 1000 lines... "End machine header 1" 2) starting with "20071126 12:12:12 Machine... (5 Replies)
Discussion started by: vikas.iet
5 Replies

9. Shell Programming and Scripting

FTP script to FTP file to UNIX - Solaris

Hello, A couple of times per week, i receive emails notifications when files are available for processing. Currently i read these eamails with a java program and store the attachement on my C: drive and would now like to generate a PC script to send this file name up to UNIX-Solaris and... (3 Replies)
Discussion started by: bobk544
3 Replies

10. IP Networking

FTP command result

Hi there! I've used the ftp command to transfert datas between two linux box. The answer of this command, was: It strange because the transfert was complete and it brings two messages, the first is successful from PORT command and the second is an error from EPRT command! So, It seems that... (1 Reply)
Discussion started by: nymus7
1 Replies
Login or Register to Ask a Question