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:

  1. Connect to user@gateway,
  2. Request a compute node with X cores for Y time,
  3. Wait for the node to be allocated,
  4. 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.


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"
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?


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.