unix shell commands within ftp shell script

unix shell commands within ftp shell script

Post by Mik » Fri, 26 Jul 2002 09:47:08



I have the following script:

#!/bin/ksh
#
LIST_OF_FILES="f1 f2 f3 f4 f5 f6 f7 f8"
ftp -v hostname <<-EOF >/tmp/log 2>&1  # where hostname is an IP of an ftp server
binary
$(
for file in $LIST_OF_FILES
do
    print "put $file $file.tmp"
    print "rename $file.tmp $file"
done
 )
bye
EOF

I want to send a list of files via one ftp open/close
ftp session. But after the first print statement I want to
check if the file fully transferred by checking the
"226 Transfer complete" output from the ftp server and also maybe
by comparing sizes between the original file and that ftped
(by running the ftp size command). Thus from this I can try to resend
the file or maybe flag the file as a failed transmission.
I could run a separate ftp open/close session for each file
and achieve this (by reading the contents of /tmp/log)
but I was thinking about performance with multiple files.

To me this looks like I need to understand how I can interchange
commands from ftp shell to unix shell. The problem is I can't
seem to find out how to do this. Just pointing me in the right
direction or a hint would be appreciated

Thanks,

Mike

 
 
 

unix shell commands within ftp shell script

Post by Bill Marc » Fri, 26 Jul 2002 13:26:20


On 24 Jul 2002 17:47:08 -0700,

>I have the following script:

>I want to send a list of files via one ftp open/close
>ftp session. But after the first print statement I want to
>check if the file fully transferred by checking the
>"226 Transfer complete" output from the ftp server and also maybe
>by comparing sizes between the original file and that ftped
>(by running the ftp size command). Thus from this I can try to resend
>the file or maybe flag the file as a failed transmission.
>I could run a separate ftp open/close session for each file
>and achieve this (by reading the contents of /tmp/log)
>but I was thinking about performance with multiple files.

>To me this looks like I need to understand how I can interchange
>commands from ftp shell to unix shell. The problem is I can't
>seem to find out how to do this. Just pointing me in the right
>direction or a hint would be appreciated

What you need is an expect script. man expect.

 
 
 

unix shell commands within ftp shell script

Post by Ian Pell » Sat, 27 Jul 2002 00:05:37


I want to send a list of files via one ftp open/close
......
What you need is an expect script. man expect.

See http://expect.nist.gov/
It has an example of what you want to do.
PLUS:-
there is "autoexpect" that learns what you do, Then simply vi its
generated script to what you want.

Regards
Ian

 
 
 

1. shell script within shell script (general question)

When writing a shell script, quite often, I have to write bunch of
separate Awk/Python/etc scripts that are more than few lines.  And, of
course, I lose track of which script does what, especially if I have to
go back and forth with editor.

Is there a way to include those Awk/Python scripts inside of the main
shell script?  Essentially, I would like to write in the main shell
script,

    subfile test1 (/usr/bin/gawk -f) {
        ...
        /pattern/ {action}
        ...
    }

    subfile test2 (/usr/bin/python) {
        ...
        python stuffs
        ...
    }

instead of a file called "test1",

    #! /usr/bin/gawk -f
    ...
    /patthern/ {action}
    ...

and another file called "test2",

    #! /usr/bin/python
    ...
    python stuffs
    ...

Does anyone know which shell allows this?  If no such shell exists, then
how difficult would it be write a hook in the source?

        Yours truly,
--

Linux solution for data management and processing.

2. 2.5.13 on alpha - undefined symbol local_irq_save in snd-seq-midi-event.o

3. How to interact with a shell within a shell script

4. Getting 16bit colour w. S3 864

5. How to attach file to EMAIL MESSAGE within shell script(Korn shell)

6. where could I find XFree86Setup?

7. Invoking SQL commands within K-shell script!

8. ftp daemon won't come up

9. How to use a shell built-in command within a sh script ?

10. Invoke ftp within a shell script

11. ftp from within a shell script

12. ftp within a shell script

13. FTP within shell script