Help for this page

Select Code to Download


  1. or download this
    [root@ip:/tmp] ssh root@ip "sudo -u bob date"
    root@ip's password: 
    sudo: sorry, you must have a tty to run sudo
    [root@ip:/tmp]
    but ssh -t root@ip "sudo -u bob date" solves the problem
    
  2. or download this
    use Carp qw(carp confess croak);
    use Net::SSH2;
    ...
    print $stdout;
    $ssh->disconnect();
    exit(0);
    
  3. or download this
    perl myssh.pl "sudo -u bob date" won't work
    perl myssh.pl "date" works and gives the date command output.