Issue
This Content is from SuperUser. Question asked by Jacobus Smit
Specifically I am using the SURF.nl lisa compute terminals, but I haven’t been able to find out whether this is possible and how to if so. The steps I (believe I) want to achieve are:
- Connect to user@gateway,
- Request a compute node with X cores for Y time,
- Wait for the node to be allocated,
- ssh into this node.
Ideally I want to set up my ssh config to allow me to allocate and use a compute terminal in a single ssh command, but for the time being I began writing a script to do what I want.
#!/bin/sh
ssh user@host salloc -n ${1:-1} -c 4 -t ${2:-00:00:01} |
while IFS= read -r line; do
if grep -o "r[0-9]+n[0-9]+" "$line" ; then
ASSIGNEDHOST = "`grep -o "r[0-9]+n[0-9]+" "$line"`"
echo "$ASSIGNEDHOST"
fi
done
echo "$ASSIGNEDHOST"
ssh user@"$ASSIGNEDHOST".host
Unfortunately what happens now is that it sshes in fine and allocates a node, but doesn’t go from there. How should I escape the while loop once it detects (via grep
) an allocated node?
Solution
This question is not yet answered, be the first one who answer using the comment. Later the confirmed answer will be published as the solution.
This Question and Answer are collected from SuperUser , is licensed under the terms of CC BY-SA 2.5. - CC BY-SA 3.0. - CC BY-SA 4.0.