-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathsubmit_run.php
executable file
·67 lines (57 loc) · 2.05 KB
/
submit_run.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?
session_start();
include_once('globals.php');
$redirect = "https://".$_SERVER['HTTP_HOST']."/index.php";
if (!isset($_SESSION['username'])) { header("Location:$redirect"); }
if (!isset($_SESSION['password'])) { header("Location:$redirect"); }
if (!isset($_SESSION['home'])) { header("Location:$redirect"); }
$tmpfile = $world['tmp'].'/'.uniqid('qsub-');
file_put_contents($tmpfile, $_POST['result_script']);
if(!$_POST['scriptname']) { $_POST['scriptname'] = uniqid('qsub-'); }
$file = $_SESSION['home'].'/'.$_POST['scriptname'].'.pbs';
// Apre la risorsa SSH
$connection_handler = ssh2_connect($_SESSION['sshserver'],$_SESSION['sshport']);
if(!$connection_handler) {
die("[submit_run.php] Connection Failed: ". $_SESSION['sshserver']." at ".$_SESSION['sshport']);
}
// Esegue la autenticazione in SSH con password plain
$connection = ssh2_auth_password($connection_handler,$_SESSION['username'],$_SESSION['password']);
if (!$connection) {
die("[submit_run.php] AuthPass Connection Failed!");
}
// Invia lo script al nodo master che dovrà avviarlo
if (!ssh2_scp_send($connection_handler, $tmpfile, $file)) {
die("[submit_run.php] SCP not worked for: $name");
}
// Cancella il file sul sistema attuale
unlink($tmpfile);
if($debug) {
$qsub_cmd = 'echo "Result of '.$file.'\n" && cat '.$file;
} else {
$qsub_cmd = 'qsub '.$file;
}
$output = ssh2_exec3($connection_handler, $qsub_cmd);
?>
<head>
<title>Submission Result</title>
<? include_once('html_include/styles.php'); ?>
</head>
<body>
<div class="navbar navbar-fixed-top navbar-inverse" style="position: absolute;">
<div class="navbar-inner">
<div class="container" style="width: auto; padding: 0 20px;">
<a class="brand" href="#">PBS Response</a>
<ul class="nav pull-right">
<li><a href="javascript:window.close()"><div class="badge badge-important"
style="position:relative; top:-1px;">Close</div>
</a></li>
</ul>
</div>
</div>
</div>
<div class="well" style="padding: 50px;">
<?
echo '<pre><code>' . $output . '</code></pre>';
?>
</div>
</body>