time icrement based loop

Discussion in 'Perl Misc' started by deadpickle, Sep 6, 2006.

  1. deadpickle

    deadpickle Guest

    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.
    deadpickle, Sep 6, 2006
    #1
    1. Advertising

  2. deadpickle

    tuser Guest

    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 }'
    tuser, Sep 6, 2006
    #2
    1. Advertising

  3. deadpickle

    deadpickle Guest

    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.
    deadpickle, Sep 6, 2006
    #3
  4. deadpickle

    Guest

    "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_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

    --
    -------------------- http://NewsReader.Com/ --------------------
    Usenet Newsgroup Service $9.95/Month 30GB
    , Sep 6, 2006
    #4
  5. deadpickle

    deadpickle Guest

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


    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.
    deadpickle, Sep 6, 2006
    #5
  6. 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
    Tad McClellan, Sep 7, 2006
    #6
  7. deadpickle

    deadpickle Guest

    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.
    deadpickle, Sep 7, 2006
    #7
  8. deadpickle

    deadpickle Guest

    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?
    deadpickle, Sep 7, 2006
    #8
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. flamesrock
    Replies:
    8
    Views:
    453
    Hendrik van Rooyen
    Nov 24, 2006
  2. Michael Tomer

    Time based loop limiting

    Michael Tomer, Sep 8, 2009, in forum: Ruby
    Replies:
    7
    Views:
    143
    Michael Tomer
    Sep 9, 2009
  3. FMAS

    loop in loop takes too much time

    FMAS, Jun 12, 2004, in forum: Perl Misc
    Replies:
    8
    Views:
    159
    Anno Siegel
    Jun 13, 2004
  4. Replies:
    7
    Views:
    267
    A. Sinan Unur
    Feb 14, 2006
  5. Isaac Won
    Replies:
    9
    Views:
    372
    Ulrich Eckhardt
    Mar 4, 2013
Loading...

Share This Page