1

I have a small SLURM cluster, which I am using to run jobs. I run a script and while that script is running, I want to enter a specific key command "t + enter". I believe I should do it by submitting another job, but I need it to run within the first running script.

Any ideas on how I can achieve this?

  • 1
    Welcome to U&L! It's not clear what you're trying to do. When you say you "want to enter t + enter", where is that keypress going? Is it an input that the (first) script is waiting for? – JigglyNaga Aug 22 at 10:40
  • Hi Jiggly, So while that script is running, I want to be able to input from another screen (i.e. from master to slave) t + Return (because it provides a certain function). I tried to use echo, but what that does is print a char "t" on screen, and when I press enter it is not taken as an input. – George Aug 22 at 12:41
  • Is the "slave", ie. the recipient of the keypress, an X window? If so, you should consider xdotool as described in eg. How to send keystrokes (F5) from a terminal to a GUI program – JigglyNaga Aug 22 at 13:40
  • Thank you, will give it a shot! – George Aug 23 at 8:51
0

George,

You would not want to queue a separate sbatch command to do this. If you used the OpenHPC stack, you could potentially use wwsh ssh -a <command> where the -a is for all or alternatively replace this with the nodes that you want to run the command on.

As for doing it from your existing batch script, have you considered using expect? The expect program would allow you to type something like send -- "t\r" (the t character followed by a return key) if the time that you needed the input to be run would be deterministic. If you want more information on expect, check out something like https://likegeeks.com/expect-command/ .

In my experience can be helpful if your cluster doesn't have a lot of space or you want max performance to use a command line only approach instead of installing x11 on a system (or at least the parts of it required to run xdotool). Personal comfort level will dictate this.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.