Loading ...
Sorry, an error occurred while loading the content.

Net:: Telnet and sudo problem

Expand Messages
  • Dukelow, Don
    I ve posted this before a after several suggestion offline it was suggested to repost to all. I m using Net::telnet to log into a remote server and once there
    Message 1 of 1 , Jul 2, 2007
    • 0 Attachment
      I've posted this before a after several suggestion offline it was
      suggested to repost to all.

      I'm using Net::telnet to log into a remote server and once there I issue
      the following commands.

      my @answer = $TELNET->print('sudo df -k');
      $TELNET->waitfor('/Password:/i');
      $TELNET->print($PASSWD);

      print "TEST @answer\n";

      If I do this without sudo it works fine, but the shell script I want to
      run requires root access this the need for sudo.

      The dump_log puts this out!
      0x00000: 73 75 64 6f 20 64 66 20 2d 6b 0d 0a sudo df
      -k..

      < 0x00000: 73 75 64 6f 20 64 66 20 2d 6b 0d 0a sudo df
      -k..

      < 0x00000: 50 61 73 73 77 6f 72 64 3a Password:

      > 0x00000: 71 7a 67 71 32 32 31 37 0d 0a <my
      passwd>..


      The only thing I get back in @answer is a 1, not the output from df -k.
      I believe the "1" coming back is from the successful password entry.
      How can I get the results back from the df or any other command/script I
      want through sudo?
      -----
      Don Dukelow
      HP UNIX OVO Enrollment
      Hewlett-Packard Company
      e-mail: dukelow@...
      URL: http://www.hp.ca
    Your message has been successfully submitted and would be delivered to recipients shortly.