Guest User

Untitled

a guest
Nov 16th, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. use Net::SSH2;
  2. use strict;
  3.  
  4. my $ssh = Net::SSH2->new();
  5.  
  6. $ssh->connect('xx.xx.xx.xx');
  7.  
  8. $ssh->auth(username => 'xxxxxx', password => 'xxxxx');
  9.  
  10. my $channel = $ssh->channel() or do { print" [LOG ERROR]: Failed to create channel. Exiting ...n"};
  11.  
  12. $channel->blocking(0);
  13.  
  14. $channel->shell() ;
  15.  
  16. sleep(5);
  17.  
  18. my $cmd='df -h';
  19.  
  20. print $channel "$cmdn";
  21.  
  22. sleep(5);
  23.  
  24. while(<$channel>)
  25. {
  26. print $_;
  27. }
  28.  
  29.  
  30. $channel->close();
  31.  
  32. $ssh->disconnect();
Add Comment
Please, Sign In to add comment