2011年10月13日 星期四

Perl execute telnet command as root

http://ubuntuforums.org/showthread.php?t=19236


# Edit sudoers with visudo
# myuser ALL=(ALL)       NOPASSWD: /mybin/killexe MYEXE
# myuser ALL=(ALL)       NOPASSWD: /mybin/MYEXE

use Net::Telnet ();
   $t = new Net::Telnet (Timeout => 10,
                         Prompt => '/\[myuser\@myhost\ mydir\]\$ $/');
   $t->open("127.0.0.1");
   $t->login("user","password");
   @lines = $t->cmd("who");
   print @lines;

沒有留言:

張貼留言