Skip to content
Permalink
Browse files
update
fixed the issue with scripts not running when parent folder contains spaces in the name
  • Loading branch information
aa3025 committed Feb 15, 2021
1 parent 2dd46f1 commit be453b573c01fbced3ae45671f5bdf72e9aa9ddf
Show file tree
Hide file tree
Showing 13 changed files with 1,134 additions and 1 deletion.
20 READ.ME
@@ -1 +1,19 @@
This repository contains various EEC HPC related scripts
These scripts allows to establish desktop session with remote compute node of HPC for Windows PCs.


0) if you never started VNC server on HPC, login to HPC in console (e.g. PuTTY) and execute "vncpasswd" to set the password for VNC (can be the same as your HPC password or different)
1) Choose a folder here: zeus or pluto to launch VNC session on the required HPC.
2) Launch only 01_START_VNC_Session_..._1_node_24h.hta (doubleclick on it), if prompted how to open the *.hta file, choose mshta.exe option (normally picked automatically).
3) Fill in your HPC password
4) In the black console window wait for the VNC server job to start in the queue of HPC, note the target node name
5) Close the black console window
6) The second tool will start automatically to connect you to VNC session -- fill the target node name and your password

By default the VNC job will last 24 hours.
When you select "Logout" from your VNC Desktop session (in main menu), the VNC slurm job will terminate. If you just close VNC Desktop window --> it will remain running untimm termination time is reached. if you need longer than 24 h time limit for your VNC Desktop session, please ask me.

For more details see: http://zeus.coventry.ac.uk/wordpress/?p=1119

Alex Pedcenko
aa3025@coventry.ac.uk

Binary file not shown.
@@ -0,0 +1,185 @@
<head>
<title>VNC Server Startup</title>
<HTA:APPLICATION
ID="vncpluto"
APPLICATIONNAME="VNC Server Startup"
SCROLL="no"
SINGLEINSTANCE="no"
>
</head>

<script language="VBScript">
Dim dtmStartTime

Sub window_onload
window.resizeTo 400,600
strUser = CreateObject("WScript.Network").UserName
document.getElementById(2).Value = strUser
squeue.location.href = "http://pluto.coventry.ac.uk/queue.php?userid=" & strUser
End Sub


Sub sleep (Timesec)
Set objwsh = CreateObject("WScript.Shell")
objwsh.Run "Timeout /T " & Timesec & " /nobreak" ,0 ,true
Set objwsh = Nothing
End Sub

function toggle
document.getElementById("cpus").disabled=document.getElementById("checkbox").checked
End function

function toggle1
document.getElementById("numnodes").disabled=Not document.getElementById("few").checked
End function

function toggle3
document.getElementById("nodename").disabled=Not document.getElementById("particular").checked
End function

function reload
location.reload True
End function

Sub Submit

Dim WshShell, objCmdExec
Dim strCmdTool, strCmdArgs
Dim strCmdOutput
strUser = CreateObject("WScript.Network").UserName
document.getElementById("squeue").src = "http://pluto.coventry.ac.uk/queue.php?userid=" & document.getElementById(2).Value

document.getElementById(1).disabled = true
document.getElementById(1).Value = "Please Wait!"
FullName = replace(vncpluto.commandLine,chr(34),"")
arrFN=split(FullName,"\")
FileName = arrFN(ubound(arrFN))
SourceDir=replace(FullName,FileName,"")
'msgbox(FullName)
if document.getElementById("checkbox").checked = true then
nnodes="-N 1 --exclusive"
else
nnodes="-N 1 --ntasks-per-node " & cpus.Value
end if
if constraint.Value <> "" then
feature=" -p " & constraint.Value
else
feature=""
end if
if document.getElementById("few").checked = true then
if document.getElementById("checkbox").checked = true then
nnodes="-N " & numnodes.Value & " --exclusive"
else
nnodes="-N " & numnodes.Value & " --ntasks-per-node " & cpus.Value
end if
end if
if (document.getElementById("particular").checked) And (nodename.Value <> "") then
nodesnames=" -w " & nodename.Value
else
nodesnames=""
end if
Randomize
middleman="pluto"
nLow = 51
nHigh = 99
Randomize
myport=Int((nHigh - nLow + 1) * Rnd + nLow)
middleport=myport+5900
state_cmd="squeue -j $JOBID -o %t -h"
'cmd=SourceDir & "..\tools\plink.exe -t -ssh " & middleman & ".coventry.ac.uk -l " & login.Value & " -pw " & pass.Value & " " & chr(34) & "rm -fr ~/.cache/sessions; echo xfce4-session > ~/.vnc/xstartup; chmod +x ~/.vnc/xstartup; rm -f ~/vnc.log; J=$(sbatch " & nnodes & feature & nodesnames & " -t " & runtime.Value & ":00:00 /share/apps/slurm/vnc.slurm); JOBID=$(grep -o " & chr(34) & "[0-9]" & chr(34) & " <<< $J | tr -d " & chr(39) & "\n" & chr(39) & "); echo Your VNC Job $JOBID is submitted to the queue... you will be connected when the job will be RUNNING; echo ; squeue -u " & login.Value & " -j $JOBID; while [[ " & chr(34) & "$STATE" & chr(34) & " != " & chr(34) & "R" & chr(34) & " ]] ; do STATE=$(" & state_cmd & "); sleep 2; done; echo ; echo Your job seems now RUNNING! Let us check again...; echo ; echo ; squeue -j $JOBID; cat ~/vnc.log; echo ; echo Note above the Target Node for your VNC Session. If you requested more than ONE node, you need to connect to the FIRST node in the above node list.; echo ; echo Press Enter to close this window and continue...; read a" & chr(34)
cmd="..\tools\plink.exe -t -ssh " & middleman & ".coventry.ac.uk -l " & login.Value & " -pw " & pass.Value & " " & chr(34) & "rm -fr ~/.cache/sessions; echo xfce4-session > ~/.vnc/xstartup; chmod +x ~/.vnc/xstartup; rm -f ~/vnc.log; J=$(sbatch " & nnodes & feature & nodesnames & " -t " & runtime.Value & ":00:00 /share/apps/slurm/vnc.slurm); JOBID=$(grep -o " & chr(34) & "[0-9]" & chr(34) & " <<< $J | tr -d " & chr(39) & "\n" & chr(39) & "); echo Your VNC Job $JOBID is submitted to the queue... you will be connected when the job will be RUNNING; echo ; squeue -u " & login.Value & " -j $JOBID; while [[ " & chr(34) & "$STATE" & chr(34) & " != " & chr(34) & "R" & chr(34) & " ]] ; do STATE=$(" & state_cmd & "); sleep 2; done; echo ; echo Your job seems now RUNNING! Let us check again...; echo ; echo ; squeue -j $JOBID; cat ~/vnc.log; echo ; echo Note above the Target Node for your VNC Session. If you requested more than ONE node, you need to connect to the FIRST node in the above node list.; echo ; echo Press Enter to close this window and continue...; read a" & chr(34)

'Set objFSO=CreateObject("Scripting.FileSystemObject")
'outFile="output.log"
'Set objFile = objFSO.CreateTextFile(outFile,True)
'objFile.Write cmd
'objFile.Close
Set objShell = CreateObject("WScript.Shell")
objShell.Run cmd,1,true
'msgbox("%windir%\system32\mshta.exe " & chr(34) & SourceDir & "02_START_tunnel_to_pluto_nodes.hta" & chr(34))

objShell.Exec("%windir%\system32\mshta.exe " & chr(34) & SourceDir & "02_START_tunnel_to_pluto_nodes.hta" & chr(34))

'objShell.Exec("%windir%\system32\mshta.exe 02_START_tunnel_to_pluto_nodes.hta")
'Window.Close

'Example:


End Sub

</script>

<body style="margin-left:1px;margin-right:1px;">
<center><h3>Pluto Node VNC Session Startup</h3></center>
<br />
<table border=0>
<tr>
<td>Input Your HPC Username: </td><td> <input type="text" id=2 name="login" size="10"></td>
<tr>
<td>Input Your HPC Password: </td><td> <input type="password" name="pass" size="10"></td>
</tr>
<tr>
<td>Time Limit for the VNC Session: </td><td> <input type="text" name="runtime" size="5" value=24> hours</td>
</tr>

<tr>
<td>I want the whole compute node: </td><td> <input onClick="toggle()" type="checkbox" id="checkbox" name="whole" checked> <br /></td>
</tr>

<tr>
<td>I need &gt;1 compute nodes: <input onClick="toggle1()" type="checkbox" id="few" name="few" unchecked> <br /></td><td><input type="text" id="numnodes" name="numnodes" size="3" disabled value=2> nodes</td>
</tr>

<tr>
<td>I want only: </td><td> <input type="text" id="cpus" name="cpus" value=1 size="5" disabled> CPU/node </td>
</tr>
<tr>


<td>Constraint needed? </td><td>
<select name="constraint">
<option value="">no, any node is fine</option>
<option value="gpu">GPU</option>
<option value="long">long (max 5 days)</option>
</select>
</td>
</tr>
<tr>
<td>I want a particular node <input onClick="toggle3()" type="checkbox" id="particular" name="particular" unchecked>, named: </td><td> <input type="text" id="nodename" name="nodename" size="10" disabled></td>
</tr>

</table>
<br />

<center>
<input id=1 class="button" type="button" name="btnSubmit" value="Start VNC" onClick="Submit">&nbsp;&nbsp;&nbsp;<input id=100 class="button" type="button" name="reload" value="Reset" onClick="reload()">
</br><br />
<iframe id="squeue" name="squeue" width=400 height=200></iframe>




</center>

<footer>
<font size=-2>Programmed by: Alex Pedcenko <a href="mailto:aa3025@coventry.ac.uk">
aa3025@coventry.ac.uk</a> </font></footer>
</body>
@@ -0,0 +1,98 @@
<head>
<title>SSH Tunnel Setup</title>
<HTA:APPLICATION
ID="tunnelpluto"
APPLICATIONNAME="SSH Tunnel Setup"
SCROLL="no"
SINGLEINSTANCE="yes"
>
</head>

<script language="VBScript">
Dim dtmStartTime

Sub window_onload
window.resizeTo 400,320

strUser = CreateObject("WScript.Network").UserName
document.getElementById(2).Value = strUser
End Sub

Sub sleep (Timesec)
Set objwsh = CreateObject("WScript.Shell")
objwsh.Run "Timeout /T " & Timesec & " /nobreak" ,0 ,true
Set objwsh = Nothing
End Sub

function go_green(id)
document.getElementById(id).style.background = "green"
end function
Sub Submit
document.getElementById(1).disabled = true
document.getElementById(1).Value = "Please Wait!"
FullName = replace(tunnelpluto.commandLine,chr(34),"")
arrFN=split(FullName,"\")
FileName = arrFN(ubound(arrFN))
SourceDir=replace(FullName,FileName,"")

middleman="pluto"
nLow = 51
nHigh = 99
Randomize
myport=Int((nHigh - nLow + 1) * Rnd + nLow)
middleport=myport+5900


port=5900+vnc.Value

'cmd=SourceDir & "..\tools\plink.exe -batch -pw " & pass.Value & " -t -L localhost:" & middleport & ":localhost:" & middleport & " " & login.Value & "@" & middleman & ".coventry.ac.uk ssh -L " & middleport & ":localhost:" & port & " " & host.Value
cmd="..\tools\plink.exe -batch -pw " & pass.Value & " -t -L localhost:" & middleport & ":localhost:" & middleport & " " & login.Value & "@" & middleman & ".coventry.ac.uk ssh -L " & middleport & ":localhost:" & port & " " & host.Value
Set objShell = CreateObject("Wscript.Shell")
'
objShell.Run cmd,1
sleep 3
msgbox("This is your ssh-tunnel, do not close this terminal! Press OK to launch VNC viewer.")
sleep 2
objShell.Run "..\tools\vncviewer64.exe localhost:" & myport

Window.Close
sleep 5




End Sub

</script>

<body>
<center><h3>Pluto Tunnel Setup</h3></center>
<br />
<table border=0>
<tr>
<td>Input Your HPC Username: </td><td> <input id=2 type="text" name="login" size="10"><br /></td>
<tr>
<td>Input Your HPC Password: </td><td> <input type="password" if="pass" name="pass" size="10" style="background-color:pink;" onChange="go_green('pass')"><br /></td>
</tr>
</tr>
<tr>
<td>Input target node name: </td><td> <input type="text" name="host" id="host" size="10" value="compute-0-" style="background-color:pink;" onChange="go_green('host')"><br /></td>
</tr><tr>

<td>VNC display Nr (default 1): </br><font size=-2>You need to start VNC server on the target node in advance.</font></td><td> <input disabled type="text" name="vnc" value="1" size="5"></td>
</tr></table>
<br />

<center>
<font size=-2>You will be prompted to enter your VNC password when you click Connect</font>
</br>
<input id=1 class="button" type="button" name="btnSubmit" value="Connect" onClick="Submit">

</center>


</body>
BIN +603 KB tools/plink.exe
Binary file not shown.
BIN +951 KB tools/vncviewer.exe
Binary file not shown.
Binary file not shown.

0 comments on commit be453b5

Please sign in to comment.