From: GIUSEPPE LEONARDO LICARI (peppe.licari_at_hotmail.it)
Date: Tue May 10 2022 - 03:59:03 CDT

Dear Axel,
Thank you for your suggestions. Usually try to stick to Tcl and call other external commands and software from there. Since I needed to run jobs with slurm in a cluster I though that it was easier to go with bash from the beginning. I will try to rethink if I can shift to fully Tcl, otherwise I will use files to read the exit codes, as you mentioned.

Best regards,
Giuseppe

On 9. May 2022, at 16:17, Axel Kohlmeyer <akohlmey_at_gmail.com> wrote:


Giuseppe,

Since the startup of VMD is usually a costly operation, it is generally favorable to incorporate what you do in the bash script into VMD scripting and thus avoid the issue altogether.
If you write your VMD scripting carefully (e.g. delete molecules and retrieve numerical molecule IDs into variables and operate on them) you can reset VMD as if it wasn't started before. Since Tcl scripting can do pretty much everything that bash can.

If all else fails, you can always "communicate" via files, i.e. have VMD write an "exit_status" file and then read it from bash.

On Mon, May 9, 2022 at 10:06 AM GIUSEPPE LEONARDO LICARI <peppe.licari_at_hotmail.it<mailto:peppe.licari_at_hotmail.it>> wrote:
Dear all,
I am running the latest VMD version in text mode from a bash script using the following command:

vmd -eofexit -dispdev text -args ${vars_array[@]} < script.tcl

I would like to parse different exit codes from the TCL script to communicate if the script was successful or not. I tried to use “return” or “exit” followed by a number in the TCL script and grabbing the exit code from the vmd execution using e.g. EXIT_CODE=$?,
which is the standard way to find the exit code of the last command in Bash. However, I always get an exit code of 0

I have the impression that the TCL code terminates with the exit code I specify, but then VMD will terminate after the TCL code and will exit with 0 exit code. So Bash will always see the 0 exit code.

Do you have any idea how I could retrieve directly the exit code from the TCL and parse that to the bash script?

Best regards,
Giuseppe Licari

--
Dr. Axel Kohlmeyer  akohlmey_at_gmail.com<mailto:akohlmey_at_gmail.com>  https://urldefense.com/v3/__http://goo.gl/1wk0__;!!DZ3fjg!-K9RqjkFHXW4s0Ur1mW-YkjZ-1okmTNtiyuhSo6XLsKQtpdQ1yQQKLjMnAumMT8kgIVMEQ866gD4WIHhRQnscJyYHEg$ <https://urldefense.com/v3/__https://nam12.safelinks.protection.outlook.com/?url=http*3A*2F*2Fgoo.gl*2F1wk0&data=05*7C01*7C*7C575b080a3272480769d008da31c6add8*7C84df9e7fe9f640afb435aaaaaaaaaaaa*7C1*7C0*7C637877026629326619*7CUnknown*7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0*3D*7C3000*7C*7C*7C&sdata=UaPuJ7v4qVQadc*2FvpafYnUsCQ84ElUivvNpNE2XTqHE*3D&reserved=0__;JSUlJSUlJSUlJSUlJSUlJSUlJSU!!DZ3fjg!-K9RqjkFHXW4s0Ur1mW-YkjZ-1okmTNtiyuhSo6XLsKQtpdQ1yQQKLjMnAumMT8kgIVMEQ866gD4WIHhRQns29nviIQ$ >
College of Science & Technology, Temple University, Philadelphia PA, USA
International Centre for Theoretical Physics, Trieste. Italy.