Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I have a bash script that cd to the right directory then uses the mput command to ftp all the files in the directory to a remote server, as below:

for from_dir in $DATE_LIST 
do
    cd ${FILE_LANDING_DIR}/deltas/${from_dir}
    ftp_files
done

ftp_files () {
    ftp -inv $HOST <<-EOF > $LOG_DIR/tempftplog
    user $USER $PASS 
    cd ${ID_LANDING_DIR}
    mput *
    bye 
    EOF
} 

I tried altering the ftp_files function to ftp only the .gz files in that directory by changing the line from mput * to mput *.gz but that did not work.

Can someone tell me how I can do this once in the ftp command?

share|improve this question
    
What do you mean mput *.gz did not work? What is the error message you get? –  janos Jun 17 '12 at 8:16
add comment

2 Answers 2

up vote 0 down vote accepted

Does mput *.gz not work? If not, try the ftp glob command first.

http://man.cx/ftp

share|improve this answer
add comment

What about performing a directory search and piping it to the mput?

ls *.gz | mput

I cannot test this right now because Im not at a linux box so it might need to be tweaked to get it to work 100% correctly.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.