PerlMe has asked for the wisdom of the Perl Monks concerning the following question:

Hi,
I have a application where my script needs to do the following:
1)Telnet to a system, say A.
2)Do a bunch of tasks.
3)Reboot the system, A.
4)Again telnet to the system, A to check if it is on.
I have working code for 1, 2 and 4 parts. But I got some questions relating to 3)
I can use
#The enxt two lines are only for reference #$t = new Net::Telnet (Timeout => 1000); #$t->open("10.10.4.11"); $t->cmd(reboot);
but generally the target system, A hangs at the time (normally if you were working on A's console then you do a enter or something and we will get the command prompt).
1)How can I get the command prompt back and control back to the perl script?
Any thoughts?
Thanks,
R 2)

Replies are listed 'Best First'.
Re: Reboot: System call
by aquarium (Curate) on Jul 18, 2007 at 01:17 UTC
    don't know which particular version of "reboot" you're working with but, there should be a "quiet" option for the command. check the reboot command switches.
    the hardest line to type correctly is: stty erase ^H
Re: Reboot: System call
by quester (Vicar) on Jul 18, 2007 at 07:20 UTC
    Alternatively, Linux systems will reboot with a simple

    init 6

    Most Unix systems will too, although the reboot state is not always "6".

Re: Reboot: System call
by Mr. Muskrat (Canon) on Jul 19, 2007 at 18:23 UTC

    How can I get the command prompt back and control back to the perl script?

    What's wrong with using close?

    # ... $t->cmd('reboot'); $t->close();

    Update: D'oh! You're saying that your script hangs on cmd... The first time I read it I thought you were trying to connect immediately after the cmd.

      I finally got it working. Thanks guys for your inputs
      $t->cmd('reboot&');
      '&' would do the trip. This would return the prompt back. I can then run a sleep and then reconnect to the system again. In this case I can't use init6 as I am restarting a target system.