FTP script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting FTP script
# 1  
Old 03-26-2007
FTP script

To start, this thread, I have read the FTP FAQ and done a search and I can't figure this out. This is really simple, but the first command won't execute. I've removed my server name, user and pass. I've tried modeling it after some of the other examples in the FAQ using ksh, but still can't get that line to execute. It just skips it and goes to the next line. What's the problem?

#!/bin/sh
ftp -n "myserver"<<END_OF_FTP
user username password
put testfile.txt
echo " Test file uploaded!"
get testfile.txt
echo "Test file downloaded!"
END_OF_FTP
# 2  
Old 03-26-2007
For one thing you can't shove echo commands into a here-document intended for ftp since ftp doesn't have an echo command.
# 3  
Old 03-26-2007
OK got it, thanks. Clearly I'm new to scripting.
# 4  
Old 03-26-2007
Here is a script that I use to transmit files:
Code:
function doftp {
   echo 'ftp -in some.ftp.com <<End-Of-Session' > om850ftp
   echo 'user userid pass_word' >> om850ftp
   echo 'type ascii' >> om850ftp
   echo 'cd tempin' >> om850ftp
   echo 'put /law1/lawson/logan/edi/owens850 owens850' >> om850ftp
   echo 'rename owens850 /inbound/owens850_'"$(date +%Y%m%d%H%M%S)" >> om850ftp
   echo 'quit' >> om850ftp
   echo 'End-Of-Session' >> om850ftp
   chmod 777 om850ftp
   ./om850ftp
   rm /law1/lawson/logan/edi/owens850
   rm /law1/lawson/logan/edi/OWENS.outb.*
   rm /law1/lawson/prod/edi/out/POEDI
}
chmod 777 /law1/lawson/logan/edi/OWENS.outb.*
cat /law1/lawson/logan/edi/OWENS.outb.* > /law1/lawson/logan/edi/owens850
if [[ -s /law1/lawson/logan/edi/owens850 ]]; then
     doftp
else
    echo 'owens850 file not found or is empty'
    exit 12
fi
exit

# 5  
Old 03-26-2007
I got it to work, thanks.
# 6  
Old 03-26-2007
I am wondering however, how to verify that the file completed downloading properly because I will need to delete the file on the server when I'm done. So I need to a simple way to verify the downloaded file's integrity and to ensure the process completed properly.
# 7  
Old 03-27-2007
U can use some of my code...but U have to have rsh enabled..

sendTo=machineName
remoteDir=/home/path/test
localDir=/home1/script/test


exists=$(rsh ${sendTo} ls ${remoteDir} | grep ^${file}$ | wc -l )


if [ ${exists} -ne 1 ]
then
rcp ${localDir}/${file} root@machine:${remoteDir}/
# or rm bla bla...
fi
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

configuration for ftp script in main script

Hi, I am new to shell scripting,and i was planning to write a script that will FTP files to destination folder. I was planning that All configuration should be done through a properties files. and finally the output should be Files are transferred I have developed a properties file named... (4 Replies)
Discussion started by: rahul125
4 Replies

2. Shell Programming and Scripting

Need help in ftp script

hello , I am working on a FTP script which navigates to specific directory and pulls the file Issue which i am facing :: ---------------------------- i) When there is a file it pulls the file , but when there is not file in the directory it fails in the same statement and it is not... (3 Replies)
Discussion started by: ranga27
3 Replies

3. Linux

Need SCP script equivalent to FTP script .

Hi, Currently i'm using the folllowing FTP acript and its working. echo "open $server" > ftp_file echo "user $user $password" >> ftp_file echo "cd $remote_dir" >> ftp_file echo "lcd $local_dir" >> ftp_file echo "put $file">> ftp_file echo "bye" >> ftp_file ftp -nv < ftp_file I've... (1 Reply)
Discussion started by: vickramshetty
1 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. Shell Programming and Scripting

ftp script not able to connect to ftp server.

I have the following ftp script to get files from a remote location. However, on running the script I find that I am not even able to connect to ftp server. I am able to connect to ftp server using other GUI ftp tools like WS_FTP using the same IP. IP used here is a dummy IP. What can go... (3 Replies)
Discussion started by: gram77
3 Replies

7. 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

8. Shell Programming and Scripting

Need help - script for ftp..

I have my ftp script as below.. This is logging the messages into ftp.log file , But I want the same output(what ever messages are going into ftp.log) to be printed on the console too for the user to show the status.. Tried with "tee" .. unable to get the solution.. Can some one help me... (3 Replies)
Discussion started by: Srini75
3 Replies

9. UNIX for Dummies Questions & Answers

excuting a shell script within ftp script

Novice here... I need help with excuting a shell script on a flat file that I've transfered over from a Windows XP machine for manipulation through an auto FTP script... so that after it is transfers it excutes the shell script and then returns it back to XP machine... Any ideas... (2 Replies)
Discussion started by: Gerry405
2 Replies

10. Shell Programming and Scripting

FTP script in Unix shell script

Hello , I am trying to make a shell script (Unix) for a ftp connection to another server and to get a file. So I have no knowledge about ftp and my script must do automaticly the connection with the user and passwd. Can you help us about that... Christian... (2 Replies)
Discussion started by: steiner
2 Replies
Login or Register to Ask a Question