Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hi,
I am trying to FTP files ( say 100 files) one per minute.I am using the following
ftp -niv ${BOX} ENDOFTEXT
user xyz abcd
bin
pwd
mput *.txt
bye
ENDOFTEXTwhere do i add ( sleep 60) so that i can ftp one file per minute?
Or is there any other idea to do the above?
Thanks

Put the ftp code as a function that is called once / minute. Pass as a parameter the name of the file you want to send within a for loop.

David,
Thanks
but this will ask for multiple times of connecting , disconnecting and reconnecting..i do not want to do that for 500 times for 500 files.

You could try running it in background as a co-process. This would complicate things since you only have a basic text interface between the foreground process and the coprocess; but it does avoid having to reconnect each time you need ftp.

Do i have any option of connecting to ftp only once and executing the for loop or sending the files one per one minute?
my options will be
1.if possible to call a script or use a forloop within that FTP connection
2.define a macro (macdef) to the above.
can anyone suggest..how to do that?Thanks

ftp yourremotehost |&
# (assuming you have a .netrc file to automate
# login) the ftp session is now a co-process.print -p ascii
print -p cd some/path# Feed it commands via print -p
cd some/local/path
# You can execute other commands in the foreground.
for f in *.txt
do
print -p put $f
doneprint -p bye
You can also use read -p to fetch output from the co-process, and there are some fancy redirection options in man ksh that I haven't properly experimented with.
The above is the ksh implementation: other shells probably have different ways of doing it.

Hi,
thats a wonderful idea.
but when ever i write print -p argument
its giving error
PRINT:Cannot open file: argument
do i need to change any configuartion /setup?
I am using ksh.
thanks

Here is what i got.
whence -v print
print is an exported alias for /apps/usr/bin/printand i tried to open the print file....it was not readable....
please suggest.
Thnx

Sounds like someone wrote a program with the same name as a standard shell command, which has to be asking for trouble.
Good to hear that worked anyway.

badluck for me i have some other problem in this..i have to send say 500 files. but my FTP session is timed out after few minutes...
how do i mange that?...my idea would be if i can catch with any flag..
if ftp timedout is true then reconnect to ftp...
but i am still inside ftp> how do i write a shell script?
please suggest.Thanks

![]() |
cron/scp/expect Problem
|
Insert line breaks in ASC...
|

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |