Ftp multiple files one at a time


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Ftp multiple files one at a time
# 1  
Old 05-09-2013
Ftp multiple files one at a time

Hi,
I have a problem while ftp'ing zip files one after the other from linux source directory to a ftp host machine. here is the shell script:

Code:
#!/bin/ksh
dir=data/dir1/dir2 # this dir is linux source directory where zip files located.
rmtdir='/home/'
echo $dir
for i in /$dir/*; do
 if [ -f "$i" ]; then
file=$i
ftp -inv <<END_SCRIPT
open host
user x133 x133
ascii
put $file $rmtdir
#sleep 5 
quit
END_SCRIPT
 fi
done

When i run the above shell script, i see that filename (say 123.zip from source directory) that is ftp'd is re-named as home instead of 123.zip.

Last edited by Scott; 05-09-2013 at 10:22 AM.. Reason: Please use code tags
# 2  
Old 05-09-2013
you have to run
Code:
cd $rmtdir
put $file

# 3  
Old 05-09-2013
It's also worth noting that if "123.zip" is an actual ZIP file, it won't be an ASCII file.
# 4  
Old 05-09-2013
I tried the following
Code:
dir=data/dir1/dir2 # this dir is linux source directory where zip files located.
rmtdir='/home/'
echo $dir
for i in /$dir/*; do
 if [ -f "$i" ]; then
file=$i
ftp -inv <<END_SCRIPT
open host
user x133 x133
binary
cd $rmtdir
put $file $rmtdir
quit
END_SCRIPT
 fi
done

and it gave the following error:
Code:
local: /ep-data/pcats/CPS_RSPD1032/970HD.zip remote: /ep-data/pcats/CPS_RSPD1032/970HD.zip
229 Entering Extended Passive Mode (|||48492|)
450 File action is not taken.
?Invalid command.
221 Service closing control connection.


Last edited by Scott; 05-09-2013 at 10:51 AM.. Reason: Code tags, please...
# 5  
Old 05-09-2013
Instead of a for loop, why not use mput?

Code:
dir=data/dir1/dir2 # this dir is linux source directory where zip files located.
rmtdir='/home/'
cd $dir
ftp -inv <<END_SCRIPT
open host
user x133 x133
binary
cd $rmtdir
prompt off
mput *.zip
END_SCRIPT

# 6  
Old 05-09-2013
Sorry if there is confusion created, but i'm trying to ftp one zip file at a time in one ftp session. If there are 100 zip files in linux source directory then 100 ftp sessions should be created and one zip file per session to be ftp'd to host machine's root directory.

Many Thanks for looking
# 7  
Old 05-09-2013
Try disabling extended passive mode:

Code:
epsv4 off

Some info about error 450:

450 FTP Reply Code - Knowledge Base-RhinoSoft
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Transfer multiple different files in FTP

Hi All, i am doing ftp how can i transfer multiple different files example- 03-21-13 06:33AM 46800 CATT_HOURS.pgp 03-21-13 06:33AM 266392 CATT_TAX.txt 03-21-13 06:33AM 91448 CATT_STATUS.txt 03-21-13 06:33AM 468 ... (3 Replies)
Discussion started by: krupasindhu18
3 Replies

2. Shell Programming and Scripting

ftp multiple files at the same time

Hi All, I am using ncftpput in one of my c-shell script to upload files to a remote location. The source files keep coming continuosly and to upload each file ncftpput opens a new connection everytime. It means ncftp uploads the file1 than file2 than file3 .... There is gap 20-25 secs between... (10 Replies)
Discussion started by: sraj142
10 Replies

3. Shell Programming and Scripting

FTP multiple files from multiple directories

I have multiple files that starts as TRADE_LOG spread across multiple folders in the given structure.. ./dir1/1/TRADE_LOG*.gz ./dir2/10/TRADE_LOG*.gz ./dir11/12/TRADE_LOG*.gz ./dir12/13/TRADE_LOG*.gz when I do ftp uisng mput from the "." dir I am getting the below given error mput... (1 Reply)
Discussion started by: prasperl
1 Replies

4. Shell Programming and Scripting

To remove multiple files in FTP

We have a files in FTP server..... after getting the files from FTP by mget *.* i hav to remove all files (multiple files) at once... is there any command to delete multiple files at once (2 Replies)
Discussion started by: nani1984
2 Replies

5. Shell Programming and Scripting

ftp multiple files from same directory

Hi there Gurus, I have the following ftp script: $ more ftp_dump_arch4.sh #! /usr/bin/ksh # Constant variables HOST='xx.xx.xx.xx' USER='user' PASSWD='password' dir='/export/file' ftp_log='/tmp' ftp -n $HOST > $ftp_log/ftp.log << END user $USER $PASSWD verbose lcd $dir bin (3 Replies)
Discussion started by: lweegp
3 Replies

6. Shell Programming and Scripting

Same time ftp download in perl multiple sites.

I currently have a perl script that have to retreive a single file from 20+ sites every 10 min. Right now it will ftp to site1 and download and continue up until site20. I am trying to get this to run all the ftp d/l at the same time. This is where I have my problem, I can't get it to work. ... (5 Replies)
Discussion started by: kofs79
5 Replies

7. Shell Programming and Scripting

Help in FTP'ing multiple files

Hi, I have written the following FTP script to get the multiple files from remote server to local server. My problem is that 'mget *' is not working in the script. I also tried with 'mget *.txt', 'mget *.*' etc. without any success. It do not copy any file to local server. In the script, Prompt... (10 Replies)
Discussion started by: berlin_germany
10 Replies

8. IP Networking

Automated ftp for Multiple files

I have seen the script posted yesterday for automated ftp Can we do some thing like ftp ing multiple files in one script Example input.txt has all files names to be ftped input.txt ------ a.tar b.ccp c.perl i need to ftp all the files present in input.txt i tried something like... (0 Replies)
Discussion started by: pbsrinivas
0 Replies

9. HP-UX

how to ftp multiple files

Hi, I have to write a ftp script which transfers multiple files from one unix server to another. When I try to transfer single file it goes through successfully. But, When I try to do multiple files none of the files get ftp'd. And also, even the single file goes transferred successfully, I... (4 Replies)
Discussion started by: isingh786
4 Replies

10. Shell Programming and Scripting

Need to send multiple files during ftp

Hi guys... I'm working on #!/bin/sh script in a Solaris 7 box that should send several files over to another machine via FTP. Here's what the script looks like: # This script will send the daily MSP customer counts # to the Crystal Reports server located at 192.168.2.106 cd... (2 Replies)
Discussion started by: cdunavent
2 Replies
Login or Register to Ask a Question

Featured Tech Videos