-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGetMaster.php
More file actions
19 lines (16 loc) · 854 Bytes
/
Copy pathGetMaster.php
File metadata and controls
19 lines (16 loc) · 854 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<?php
// Opening an SSH connection
$connection = ssh2_connect('localhost', 22);
ssh2_auth_password($connection, 'root', 'virtualsense');
//Passing commands to the SSH connection
$stream = ssh2_exec($connection, "/root/scripts/xenserver/Gettest2.py");
//$stream = ssh2_exec($connection, "/root/scripts/xenserver/GetMaster2.py");
//$stream = ssh2_exec($connection, "/root/scripts/xenserver/GetMaster3.py");
$output = ssh2_fetch_stream($stream,SSH2_STREAM_STDERR);
// Block Streaming to let the command finish (it will stop prematurely otherwise)
stream_set_blocking($stream, true);
// The command may not finish properly if the stream is not read to end
$output = stream_get_contents($stream);
fclose($stream);
echo "<?xml version='1.0'?><results><result><code>$output</code><message></message></result></results>";
?>