Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Addition & Thanks : catch exit code!

0 views
Skip to first unread message

Davide Frisoni

unread,
Jul 12, 1994, 2:42:18 AM7/12/94
to
Hello everyone,
thanks to all people who answered my question, the main error come from a wrong use of [].

I wrote :
set code [catch [my_cprogram] err] :-(
and now with :
set code [catch {my_cprogram} err] :-)
it works.

But the real problem now, is that my_cprogram write some messages into the stderror
and catch recognize them as error and report me the first-one with code=1 (my exit_code=0).
I "changed" the stderr in stdout and all goes well (right exit code, err=""), but I've
"lost" my messages (probably stdout has been redirected into null device).
What should I do? I've to redirect my stdout in a file?

Thanks in advance,
--
--FRY

. __
.'`' `' \
| _| ==============================================================
|_/\ / Davide Frisoni | e-mail(internet):
\ o| Forschungsinstitut fuer anwendungs- | fri...@faw.uni-ulm.de
_ | \ orientierte Wissensverarbeitung-FAW |
| | \ \ Helmholzstr. 16 | Tel.: +49-731-501.8626
|_| \ \ D-89081 Ulm, Germany | FAX: +49-731-501.929
\ _\ ==============================================================
| | \|
____ /_/
\._/

Frank Stajano

unread,
Jul 12, 1994, 8:27:01 AM7/12/94
to
In article <2vte0b$7...@wega.rz.uni-ulm.de>, fri...@faw.uni-ulm.de (Davide Frisoni) writes:
|> Hello everyone,
|> thanks to all people who answered my question, the main error come from a wrong use of [].
|>
|> I wrote :
|> set code [catch [my_cprogram] err] :-(
|> and now with :
|> set code [catch {my_cprogram} err] :-)
|> it works.
|>
|> But the real problem now, is that my_cprogram write some messages into the stderror
|> and catch recognize them as error and report me the first-one with code=1 (my exit_code=0).
|> I "changed" the stderr in stdout and all goes well (right exit code, err=""), but I've
|> "lost" my messages (probably stdout has been redirected into null device).
|> What should I do? I've to redirect my stdout in a file?

Use "exec my_cprogram" instead of "my_cprogram". First, it will work from within
a script (whereas without exec it only works interactively). Second, the return
value from exec will be whatever your program wrote to its output. The exec man
page is more specific on all the many wonderful tricks you can play, including
supplying your own stdin to the program from within a tcl variable.

--

Frank (Filologo Disneyano)

0 new messages