Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > time icrement based loop

Reply
Thread Tools

time icrement based loop

 
 
deadpickle
Guest
Posts: n/a
 
      09-06-2006
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_fil e");
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.

 
Reply With Quote
 
 
 
 
tuser
Guest
Posts: n/a
 
      09-06-2006
deadpickle wrote:
> 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 }'

 
Reply With Quote
 
 
 
 
deadpickle
Guest
Posts: n/a
 
      09-06-2006

tuser wrote:
> deadpickle wrote:
> > 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 }'


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

 
Reply With Quote
 
xhoster@gmail.com
Guest
Posts: n/a
 
      09-06-2006
"deadpickle" <> wrote:
> 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_fil e");
> 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

--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
 
Reply With Quote
 
deadpickle
Guest
Posts: n/a
 
      09-06-2006
xhos...@gmail.com wrote:
> "deadpickle" <> wrote:
> > 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_fil e");
> > 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


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.

 
Reply With Quote
 
Tad McClellan
Guest
Posts: n/a
 
      09-07-2006
deadpickle <> wrote:

> 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.


--
Tad McClellan SGML consulting
Perl programming
Fort Worth, Texas
 
Reply With Quote
 
deadpickle
Guest
Posts: n/a
 
      09-07-2006

Tad McClellan wrote:
> deadpickle <> wrote:
>
> > 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.
>

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.

 
Reply With Quote
 
deadpickle
Guest
Posts: n/a
 
      09-07-2006

deadpickle wrote:
> Tad McClellan wrote:
> > deadpickle <> wrote:
> >
> > > 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.
> >

> 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?

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Triple nested loop python (While loop insde of for loop inside ofwhile loop) Isaac Won Python 9 03-04-2013 10:08 AM
Time based loop limiting Michael Tomer Ruby 7 09-09-2009 12:51 PM
Is time.time() < time.time() always true? flamesrock Python 8 11-24-2006 06:51 AM
Probelm to post XML data in a loop. First time XML is posted, second time data is getting truncated. Please help. vamsi.aluru@gmail.com Perl Misc 7 02-14-2006 12:09 PM
loop in loop takes too much time FMAS Perl Misc 8 06-13-2004 12:27 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57