Tuesday, November 16, 2021

[SOLVED] How to fix error message in tcl script having command [exec bjobs] when no jobs are running?

Issue

when I am running a Tcl script that contains the following lines:

set V [exec bjobs ]
puts "bjobs= ${V}"

When jobs are present it's working properly but, no jobs are running it is showing an error like this:

No unfinished job found
    while executing
"exec bjobs "
    invoked from within
"set V [exec bjobs ]"

How to avoid this error? Please let me know how to avoid this kind of errors.


Solution

if {[catch {exec bjobs} result]} {
    puts "bjobs have some issues. Reason : $result"
} else {
    puts "bjobs executed successfully. Result : $result"
}

Reference : catch



Answered By - Dinesh