time icrement based loop

D

deadpickle

I need to create a loop that will run a command every 5 seconds. I
know I can probably do this with a series of while, for and if
statements but I just cant wrap my head around it. Is there an easier
way? If not, how is it suggested that I do this?

The command I need to run is
$fh->client_automated("x.x.x.x","port","get","some_file");
It is part of a client script that uses the Net::FileShare module. If
the program is run within a while loop it eventually has an error that
closes the port and stops connection. This is bad because I need a
constant connection in order to keep the data flowing between the
computers. Any help would be very appriciated.
 
T

tuser

deadpickle said:
I need to create a loop that will run a command every 5 seconds. I
know I can probably do this with a series of while, for and if
statements but I just cant wrap my head around it. Is there an easier
way?

easier than a series of while, for and if ?

Well, I don't know if that's really easier, but it's certainly short.
Here is a perl program to run a command every 5 seconds without a
series of while, for and if statements:

perl -e '{ print qq{run command\n}; sleep 5; redo }'
 
D

deadpickle

tuser said:
easier than a series of while, for and if ?

Well, I don't know if that's really easier, but it's certainly short.
Here is a perl program to run a command every 5 seconds without a
series of while, for and if statements:

perl -e '{ print qq{run command\n}; sleep 5; redo }'

Thank you very much. Ill run it and see what happens.
 
X

xhoster

deadpickle said:
I need to create a loop that will run a command every 5 seconds. I
know I can probably do this with a series of while, for and if
statements but I just cant wrap my head around it. Is there an easier
way? If not, how is it suggested that I do this?

5 seconds from when to when? one start to the next start? one finish to
the next start? What will happend if it is 3 seconds or 7 seconds rather
than 5? Have you looked at "perldoc -f sleep"?

The command I need to run is
$fh->client_automated("x.x.x.x","port","get","some_file");
It is part of a client script that uses the Net::FileShare module. If
the program is run within a while loop it eventually has an error that
closes the port and stops connection. This is bad because I need a
constant connection in order to keep the data flowing between the
computers. Any help would be very appriciated.

It isn't clear how or if this relates to your first question.

Xho
 
D

deadpickle

5 seconds from when to when? one start to the next start? one finish to
the next start? What will happend if it is 3 seconds or 7 seconds rather
than 5? Have you looked at "perldoc -f sleep"?



It isn't clear how or if this relates to your first question.

Xho

I want the client script to connect to the server, get the file then
dissconnect, wait 5 seconds, then reconnect to the server. I inserted
the sleep function and after 5 seconds I get a bunch of errors:
Use of uninitilized value in string eq/ne at
C:/PXPerl/lib/Net/FileShare.pm
Error sending packet: unknown error
I have no clue as to whats going on.
 
T

Tad McClellan

deadpickle said:
I get a bunch of errors:
Use of uninitilized value in string eq/ne at
C:/PXPerl/lib/Net/FileShare.pm


That is not an error message.

It is a warning message.

(BTW: An "error" is different from an "error message".)

I have no clue as to whats going on.


You are using an undef value when you don't want to be.
 
D

deadpickle

Tad said:
That is not an error message.

It is a warning message.

(BTW: An "error" is different from an "error message".)




You are using an undef value when you don't want to be.
Is there a way to make this value defined, i tried installing the
module Net::Fileshare withh activestate's PPM but I guess it did not
work.
 
D

deadpickle

deadpickle said:
Is there a way to make this value defined, i tried installing the
module Net::Fileshare withh activestate's PPM but I guess it did not
work.

I got Net::Fileshare to be defined and now I dont get the uninitalized
error any more but I still get the packet error. Is this because the
connection did not close? If I enter "close ($fh)'" nothing happens,
how can I get the client to close its connection?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top