I use a High-Performance Cluster for some of my work. I can dynamically see the state of the work but I couldn't use the If statement in the cluster query. I want to hear a sound when my work finishes.

My code follows. First I can see the state of the work then I convert it to a String and it is counted. If t2 is not equal to 68, that means the work is finished. But it didn't work. Do you have any other ideas?

Dynamic[RemoteRunProcess[remote, "squeue -u21", 
   "StandardOutput"], UpdateInterval -> 10] // Framed
t2 = Dynamic[
    RemoteRunProcess[remote, "squeue -u21", 
     "StandardOutput"]], _?LetterQ], UpdateInterval -> 10]
If[t2 != 68, EmitSound[Sound@SoundNote[0]]]
  • 1
    $\begingroup$ t2 has head Dynamic, so it will never be equal to 68 (you are essentially doing Dynamic[...] == 68 which is always False. You have to wrap Dynamic around the whole thing for it to work as expected, i.e. Dynamic[t2 = ....; If[t2 != 68, ...]] $\endgroup$
    – Lukas Lang
    Nov 24, 2020 at 14:49
  • $\begingroup$ Thank you Lukas, it works. $\endgroup$
    – mrtydn
    Dec 11, 2020 at 11:16


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.