Advertisement
Guest User

Untitled

a guest
Dec 4th, 2016
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.01 KB | None | 0 0
  1. <html>
  2.  
  3. <Form Name ="form1" Method ="POST" ACTION = "">
  4. <p> <INPUT TYPE = "Submit" Name = "Submit1" VALUE = "Start"> </p>
  5. <p> <INPUT TYPE = "Submit" Name = "Submit2" VALUE = "Stop"> </p>
  6. <p> <INPUT TYPE = "Submit" Name = "Submit3" VALUE = "kill"> </p>
  7. </form>
  8.  
  9. </html>
  10.    
  11. <?php
  12.  
  13. set_include_path(get_include_path() . PATH_SEPARATOR . 'phpseclib');
  14.  
  15. include('Net/SSH2.php');
  16. $config = include('/home/xxx/mc/mc-login.php');
  17.  
  18. $host= $config['host'];
  19. $pass= $config['pass'];
  20. $port= $config['port'];
  21. $user= $config['username'];
  22.  
  23. $ssh = new Net_SSH2($host,$port);
  24. if (!$ssh->login($user, $pass)) {
  25.     exit('Login Failed');
  26. }
  27.  
  28. /*
  29.  
  30. */
  31.  
  32. if ( isset( $_POST['Submit1'] ) ) {
  33.    
  34.     echo "1: ";
  35.     echo $ssh->exec('cd mc/ && screen -dmS mc_test ./s.sh');    //start
  36.     }
  37.  
  38. if ( isset( $_POST['Submit2'] ) ) {
  39.    
  40.     echo "2: ";
  41.     echo $ssh->exec('screen -S mc_test -X stuff "stop$(printf \\r)"');      //stop
  42.     }
  43.    
  44. if ( isset( $_POST['Submit3'] ) ) {
  45.    
  46.     echo "3: ";
  47.     echo $ssh->exec('killall java');    //kill
  48.     }  
  49.  
  50.  
  51. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement