shell script - ftp downloading serveral files without mget


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting shell script - ftp downloading serveral files without mget
# 15  
Old 08-20-2009
You has to make the smae probe...if shell use mget yo need to probe with mget... in you response i understand you use get...

If you has define max_file=5 you first see 5 lines:
DEBUG[XXXX]
DEBUG[XXXX]
DEBUG[XXXX]
DEBUG[XXXX]
DEBUG[XXXX]
ftp error
ftp error
ftp error
ftp error
ftp error

and in the 5 DEBUG the shell call to de function
Quote:
i would except something like this:

Quote:
DEBUG:File Name=[XXXX]
ftp: No control connection for command.
DEBUG:File Name=[XXXX]
ftp: No control connection for command.
DEBUG:File Name=[XXXX]
ftp: No control connection for command.
DEBUG:File Name=[XXXX]
ftp: No control connection for command.
To see this you need tu put max_file=1 Smilie

Well if you probe to make a conection
and use get and is ok... then change in the script

"mget $buffer" for "get $buffer"

and put
max_file=1
# 16  
Old 08-20-2009
very big thanks to you chipcmc

it works fine with get Smilie

now i will tried to move them to another folder after downloading, hope this script won't download the files if they are in a subfolder of the folder from which i download...

Code:
while read file
 do
         echo "DEBUG:File Name=[$file]"
         buffer="$buffer $file"
         conta=$(expr $conta + 1)
         if [ $max_file -eq $conta ]
         then
           send_ftp "mget $buffer" "/dev/null"
send_ftp "rename $buffer subfolder/$buffer" "/dev/null"
           buffer=""
           conta=0
         fi
 done <$file_list

could it work like this?
i will try with test files^^
# 17  
Old 08-20-2009
turn off interactive mode

have you tried turning off interactive mode before using mget * ?
ftp to server
type prompt <enter>
this will turn off interactive mode, now try mget *
# 18  
Old 08-20-2009
it works is a great notice xD ... in this case the problem is ftp server ar pasive and active mode and if you has a proxy i think maybe there are a not correct configuration.
I read something about the ftp internali open another ports.. and something happends when sftp_server has to redirect the paquets to the client...but a don't remember so well.

Quote:
Originally Posted by dennysv
have you tried turning off interactive mode before using mget * ?
ftp to server
type prompt <enter>
this will turn off interactive mode, now try mget *
in theory for this propose is the option -i in the ftp:
-i Disable interactive prompting by multiple-file commands; see
the prompt command, below. By default, when this option is
not specified, prompting is enabled.
and this option is put in the shell.
# 19  
Old 09-07-2009
now i need to download only the newest files from the ftp (uploaded within the last 5 minutes)

i thought about checking last modification date and compare it to the date timestamp, but how do i do that in ftp?

Code:
if [ $(($(date +%s)-$(date +%s -r $file))) -le 300 ]; then 
             echo "old $file"; 
          else 
             echo "new $file";

date doesn't work in ftp, is there a similar command for ftp???
# 20  
Old 09-11-2009
um.. Im a noob so this prolly wont work but your not wanting the date, your wanting an Evaluation of the date right ??

`date '+%s'`
<- your missing the single quotes for the formatting of the date...

Man date...see what shows....
...again im prolly wrong
o.O
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

FTP mget will only grab files not folders

Hey All, first post :rolleyes: So I am writting a script to pull down files from an ftp that will be called from a bat file on windows. This seems pretty straight forward, and grabs all of the "files" in the cd location, but I am running into some permission issue that will not allow me to... (1 Reply)
Discussion started by: mpatton
1 Replies

2. UNIX for Advanced & Expert Users

Help with get/mget from FTP server with files older than 10 minutes

Hi! I am new to unix and this forum as well.. Can someone please help me : I want to "get/mget" files which are older than 10 minutes from a remote FTP server like "ftp.com". After getting the files to local unix server say "Prod.com" , i need to delete only those files from ftp.com which... (4 Replies)
Discussion started by: SravsJaya
4 Replies

3. Shell Programming and Scripting

Downloading FTP Files

Hi every one, I have the requirement to download the files from FTP and move those files to unix box. Once after coping the files, i need to remove the files in FTP. I'm a newbie in Unix script. Can you please suggest a script for this.. Thanks in advance.. (2 Replies)
Discussion started by: Murali4u
2 Replies

4. Shell Programming and Scripting

shell script to ftp multiple files

Hi, i use the below script to send a single file to remote server from linux. ftp -nvi <<!EOF open $Host_name user $USER_ID $PWD binary mput $file_name quit !EOF (where i... (2 Replies)
Discussion started by: pradebban
2 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 Dummies Questions & Answers

Using FTP mget from Visual Basic Shell

Hi calling a batch file with FTP commands from Visual basing with Shell, it basically to copy files then delete them. The delete seems to work but the copy, it looks like the mget command doesn't have the complete information on where to copy the files. Here is the batch file content. Open... (2 Replies)
Discussion started by: Mario120560
2 Replies

7. Shell Programming and Scripting

No return code in ftp mget script

I have a automated FTP script that gets a file using mget. I am using mget because the date will change on the file frequently. The mget works, however if I incorrectly type the file (e.g. if I want to get /dog123 and I enter /dg*) I do not receive and error code from in the FTP session. The... (1 Reply)
Discussion started by: dog123
1 Replies

8. Shell Programming and Scripting

Problem in Downloading one day old files from FTP site

HI, I'm downloading one day old files from ftp site. Below is my script ---------------------------- printf "open $HOST \n" > ftp.cmd printf "user $USER $PASSWD\n" >> ftp.cmd printf "bin\n" >> ftp.cmd #printf "cd /Models/\n" >> ftp.cmd printf "prompt\n" >> ftp.cmd printf "for oldfile... (4 Replies)
Discussion started by: shekhar_v4
4 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