Help for this page

Select Code to Download


  1. or download this
    #!/usr/bin/perl
    
    ...
    #$ssh->send("") or die "Cannot spawn: $!\n";
    $ssh->close();
    
  2. or download this
    Cannot execute the passwd command
    
  3. or download this
    #!/usr/bin/perl
    
    ...
        die "Login has failed. Login output was $login_output";
    }
    print "Connected to $uName\n";
    
  4. or download this
    my $who = $ssh->exec("who");
    print ($who);
    
  5. or download this
    $ssh->send("passwd");
    $ssh->waitfor("Changing password for $uName.\n(current) UNIX password:
    + ", 2) or die "prompt 'password' not found after 2 second";
    ...
    $ssh->send("qwerty123");
    
    $ssh->close();
    
  6. or download this
    admin3@admin3-VirtualBox:~/Desktop$ perl NetSSHExpect.pl 
    Connected to admin1
    ...
    admin1   pts/1        2019-07-19 12:41 (192.168.56.1)
    admin1@admin1-VirtualBox:~$ prompt 'password' not found after 2 second
    + at NetSSHExpect.pl line 36.
    admin3@admin3-VirtualBox:~/Desktop$