From: Axel Kohlmeyer (akohlmey_at_gmail.com)
Date: Mon May 09 2022 - 09:17:29 CDT

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> 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  https://urldefense.com/v3/__http://goo.gl/1wk0__;!!DZ3fjg!4C-qNT8k_cTRlgqt7h_hsmZwpLT9uJcShx0rKGgvt2qtRex4WkYyIlyUwsbFcJ2l4GfGM9RGHjHnhu_B0g$ 
College of Science & Technology, Temple University, Philadelphia PA, USA
International Centre for Theoretical Physics, Trieste. Italy.