shell script to ftp multiple files


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting shell script to ftp multiple files
# 1  
Old 05-27-2011
shell script to ftp multiple files

Hi,

i use the below script to send a single file to remote server from linux.
Code:
                ftp -nvi <<!EOF
                open $Host_name
                user $USER_ID $PWD
                binary
                mput $file_name
                quit
                !EOF (where i get host,user and pwd from another file)

what if i want to send multiple file as input.
the script should be run as,

>> ./ftp.sh file1 file2 file3 file4

the no.of file given as input will vary!Smilie

thanks,
Pradeep

Last edited by jim mcnamara; 05-27-2011 at 12:26 PM.. Reason: code tags
# 2  
Old 05-27-2011
Code:
#!/bin/ksh   
ftp_it()
{
ftp -nvi <<!EOF
  open $Host_name
  user $USER_ID $PWD
  binary
  mput "$1"
quit
!EOF 
}
              
cnt=1                      
set -A arr "$@"            
while [ $cnt -lt $# ]      
do                         
   ftp_it ${arr[cnt]}
   cnt=$(( $cnt + 1 ))
done

# 3  
Old 05-27-2011
hi,

i get an syntax error:

new.sh: syntax error at line 4: `<<' unmatched
please help!!

---------- Post updated at 09:55 PM ---------- Previous update was at 09:51 PM ----------

i have soreted out the syntax error!

now i get the below error:
ftp: user home/prad/tools/FTP: Servname not supported for ai_socktype
(to) Not connected.
Not connected.

pls help Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

FTP Script for Multiple Files of Same Name

Hello! I'm having a bit of trouble coming up with a script that can connect to 3 different log boxes and pull down files for that day into a single directory, where the files will all have the same name as per: stats_websites_20150801010000-20150801015959.csv.gz... (2 Replies)
Discussion started by: Cludgie
2 Replies

2. Shell Programming and Scripting

FTP in shell script and selecting files for upload

Hi, Im a newbie with programming and shell scripting. Im running OSX/Mac and Darwin. I would like to create a shell script that would : 1. Search a Volume and directory (including subdirectories) for a file that : * filename ends with ”_Highres.pdf” and * the file creation date of... (8 Replies)
Discussion started by: NickeZ28
8 Replies

3. Shell Programming and Scripting

Shell FTP script to send all files to different path

Hello to all in forum I hope you can help me. I want to send via FTP to a linux server the 2 kind of files that are in the same folder, as follow: 1- Send all files that are named verified.SomeString.zz.pttp to path /var/verified 2- Send all files where the name begins with verified.conf... (3 Replies)
Discussion started by: Ophiuchus
3 Replies

4. Emergency UNIX and Linux Support

Shell script to get all the files from FTP server

Hi Guru's, I am new to UNIX. my requirement is to log on to FTP server and get all the .txt files. i have developed one script by searching some forums but getting error and not able to fix them. pls see below code. ftp -i-n<<EOF open $FTP_HOST... (30 Replies)
Discussion started by: arund_01
30 Replies

5. UNIX for Dummies Questions & Answers

ftp files from one server to another using shell script

Hi Guys Any Help I have created a spool file that i need to copy onto another server using FTP in a shell script both servers are linux (3 Replies)
Discussion started by: itai
3 Replies

6. UNIX for Advanced & Expert Users

Shell script to ftp files from windows to unix

Hi , I need to ftp some input files from windows to unix server.All the files will be saved in the C drive in my machine.Currently all these files are transferring manually to the unix server.I need to write a shell script which ftp the files from windows to unix box.When I searched in the forum i... (1 Reply)
Discussion started by: kavithakuttyk
1 Replies

7. Shell Programming and Scripting

Getting a list of files on an ftp, via shell script...

G'day, I was wanting to write a shell script that checks an ftp server for the presence of new files, then get those files. In so much as the get, this is pretty straight forward, but I cannot work out how to get a list of files to check. Is it possible for a shell script to get the output of... (1 Reply)
Discussion started by: Elric of Grans
1 Replies

8. UNIX for Dummies Questions & Answers

find and FTP multiple files in Korn Shell

I want to FTP multiple files in a directory that the files were created since midnight of the same day using korn shell. I can use the "find" command using -newer arguement that compares against a time stamp file. The script identifies the files, I can't use a variable = `find . ` as the... (2 Replies)
Discussion started by: lambjam
2 Replies

9. Shell Programming and Scripting

Random files do not FTP in the shell script

The following script is used to loop through files in the /tmp directory and transfer those files onto another server. However, some of the files do not transfer. It is very random when the transferring is done (i.e. one of the files won't transfer then next time, that one will transfer and... (1 Reply)
Discussion started by: RLatham20
1 Replies

10. Shell Programming and Scripting

ftp files inside a shell script

I have a shell script where I am trying to ftp some files but I get the error message "EOF unclosed" every time the script reaches the ftp section. Here is how my script is written. #more code up here rm -f $object >> $LOG_FILE 2>&1 fi #end of if done #end of for loop ... (5 Replies)
Discussion started by: matrix1067
5 Replies
Login or Register to Ask a Question