return val of exec'ed prog 
Author Message
 return val of exec'ed prog

Hi,

Consider:
set ret [ exec xterm -e myprog ]

Here, myprog has been compiled from a C file that exits with certain
exit code,say, exit(-1).
Is there any way I can find the value of this exit code ? I must
execute myprog in a new xterm.

Thanks



Mon, 17 Jan 2005 04:12:47 GMT  
 return val of exec'ed prog

Quote:

> Hi,

> Consider:
> set ret [ exec xterm -e myprog ]

> Here, myprog has been compiled from a C file that exits with certain
> exit code,say, exit(-1).
> Is there any way I can find the value of this exit code ? I must
> execute myprog in a new xterm.

> Thanks

Look at the documentation for the tcl variable errorCode (tclvars man
page), which is briefly mentioned on the exec man page.


Mon, 17 Jan 2005 07:03:29 GMT  
 return val of exec'ed prog

Quote:
>Consider:
>set ret [ exec xterm -e myprog ]

>Here, myprog has been compiled from a C file that exits with certain
>exit code,say, exit(-1).
>Is there any way I can find the value of this exit code ? I must
>execute myprog in a new xterm.

First thing, use catch -- carefully read about catch in
    http://wiki.tcl.tk/exec
and about errorCode in
    http://www.tcl.tk/man/tcl8.3/TclCmd/tclvars.htm

Next, will xterm mask the return code of myprog?  Consider:
    % catch { exec /bin/sh -c "exit 4" } ret  
    1
    % set errorCode
    CHILDSTATUS 9264 4
whereas:
    %  catch { exec xterm -e /bin/sh -c "exit 4" } ret  
    0
This indicates to me that xterm is not passing the exit code of sh

--
Glenn Jackman



Mon, 17 Jan 2005 07:14:42 GMT  
 return val of exec'ed prog

Quote:


>>Consider:
>>set ret [ exec xterm -e myprog ]

>>Here, myprog has been compiled from a C file that exits with certain
>>exit code,say, exit(-1).
>>Is there any way I can find the value of this exit code ? I must
>>execute myprog in a new xterm.

>First thing, use catch -- carefully read about catch in
>    http://wiki.tcl.tk/exec
>and about errorCode in
>    http://www.tcl.tk/man/tcl8.3/TclCmd/tclvars.htm

>Next, will xterm mask the return code of myprog?  Consider:
>    % catch { exec /bin/sh -c "exit 4" } ret  
>    1
>    % set errorCode
>    CHILDSTATUS 9264 4
>whereas:
>    %  catch { exec xterm -e /bin/sh -c "exit 4" } ret  
>    0
>This indicates to me that xterm is not passing the exit code of sh

                        .
                        .
                        .
Me, too.  While I s'pose there could be an xterm
somewhere that *does* return the exit value of the
command it's asked to invoke, it seems unlikely to
me.

Zombie, do you truly want myprog run in an xterm?
Is user interaction necessary?  Do you realize you
could, at least in principle, run myprog as a direct
subprocess of the Tcl script you're writing?  Fail-
ing that, I'd recommend you wrap myprog with a tiny
script that preserves the exit status you're after,
and arranges to communicate it back to your original
script.  Simplest would probably be to stuff it in
the file system somewhere.  Might there be more than
one instance of myprog running at a time?
--


Business:  http://www.Phaseit.net
Personal:  http://starbase.neosoft.com/~claird/home.html



Mon, 17 Jan 2005 20:43:28 GMT  
 return val of exec'ed prog

Quote:




> >>Consider:
> >>set ret [ exec xterm -e myprog ]

> >>Here, myprog has been compiled from a C file that exits with certain
> >>exit code,say, exit(-1).
> >>Is there any way I can find the value of this exit code ? I must
> >>execute myprog in a new xterm.

> >First thing, use catch -- carefully read about catch in
> >    http://wiki.tcl.tk/exec
> >and about errorCode in
> >    http://www.tcl.tk/man/tcl8.3/TclCmd/tclvars.htm

> >Next, will xterm mask the return code of myprog?  Consider:
> >    % catch { exec /bin/sh -c "exit 4" } ret  
> >    1
> >    % set errorCode
> >    CHILDSTATUS 9264 4
> >whereas:
> >    %  catch { exec xterm -e /bin/sh -c "exit 4" } ret  
> >    0
> >This indicates to me that xterm is not passing the exit code of sh
>                    .
>                    .
>                    .
> Me, too.  While I s'pose there could be an xterm
> somewhere that *does* return the exit value of the
> command it's asked to invoke, it seems unlikely to
> me.

Yes, xterm hiding the exit code is the crux of the problem.

Quote:
> Zombie, do you truly want myprog run in an xterm?

ummm...kinda yes.
myprog takes a minumum of 1-2 minutes to run (can be 5-10 min or more)
During its execution myprog indicates what's going on:
"...doing this...doing that...now doing this..."
This keeps user engaged,without feeling lost.

However, I have just found out that fileevent can be used to do this
type of  monitoring...I'm not very sure.
I'll check out the fileevent page and see.

Quote:
> Fail-ing that, I'd recommend you wrap myprog with a tiny
> script that preserves the exit status you're after,
> and arranges to communicate it back to your original
> script.  Simplest would probably be to stuff it in
> the file system somewhere.  Might there be more than
> one instance of myprog running at a time?

If I understood you correctly, I exec my wrapper.tcl in xterm.Then
wrapper.tcl will exec myprog as a direct subprocess,retrieve the exit
code and place it in a file.
This sounds a plausible solution to me (assuming I persist with xterm)

Thanks much.



Wed, 19 Jan 2005 00:38:52 GMT  
 return val of exec'ed prog

Quote:


>>                        .
>>Me, too.  While I s'pose there could be an xterm
>>somewhere that *does* return the exit value of the
>>command it's asked to invoke, it seems unlikely to
>>me.

>Yes, xterm hiding the exit code is the crux of the problem.

>>Zombie, do you truly want myprog run in an xterm?

>ummm...kinda yes.
>myprog takes a minumum of 1-2 minutes to run (can be 5-10 min or more)
>During its execution myprog indicates what's going on:
>"...doing this...doing that...now doing this..."
>This keeps user engaged,without feeling lost.

>However, I have just found out that fileevent can be used to do this
>type of  monitoring...I'm not very sure.
>I'll check out the fileevent page and see.

Definitely the way to go here - fileevent is pretty easy to use & you
will get direct
notification of the process ending and it exit code . And you will get
the little info
blurbs along the way that you can pass on to the user (or even get fancy
& redo
to output into progress bars or something)

- Show quoted text -

Quote:

>>Fail-ing that, I'd recommend you wrap myprog with a tiny
>>script that preserves the exit status you're after,
>>and arranges to communicate it back to your original
>>script.  Simplest would probably be to stuff it in
>>the file system somewhere.  Might there be more than
>>one instance of myprog running at a time?

>If I understood you correctly, I exec my wrapper.tcl in xterm.Then
>wrapper.tcl will exec myprog as a direct subprocess,retrieve the exit
>code and place it in a file.
>This sounds a plausible solution to me (assuming I persist with xterm)

>Thanks much.

You could do all this wrapping & stuffing info into tmp files,
but it would be much much simpler to ditch the xterm entirely

Bruce



Wed, 19 Jan 2005 02:12:59 GMT  
 return val of exec'ed prog

                        .
                        .
                        .
Quote:
>myprog takes a minumum of 1-2 minutes to run (can be 5-10 min or more)
>During its execution myprog indicates what's going on:
>"...doing this...doing that...now doing this..."
>This keeps user engaged,without feeling lost.

>However, I have just found out that fileevent can be used to do this
>type of  monitoring...I'm not very sure.
>I'll check out the fileevent page and see.

It's thoughtful of you to put up an xterm that way.

However, fileevent can be turned to exactly the same
end.  I expect you'll get a satisfying result which-
ever approach you take.
                        .
                        .
                        .

Quote:
>If I understood you correctly, I exec my wrapper.tcl in xterm.Then
>wrapper.tcl will exec myprog as a direct subprocess,retrieve the exit
>code and place it in a file.

We do understand each other.
--


Business:  http://www.Phaseit.net
Personal:  http://starbase.neosoft.com/~claird/home.html



Wed, 19 Jan 2005 02:55:51 GMT  
 return val of exec'ed prog
Hmmm... not just thoughtful... rather clever...
hmmm.... damn clever.
Quote:

> It's thoughtful of you to put up an xterm that way.



Wed, 19 Jan 2005 04:35:49 GMT  
 
 [ 8 post ] 

 Relevant Pages 

1. Question about returning from an exec-ed a csh script

2. Using import in an exec'ed string

3. interaction with exec'ed process

4. How to pass arguments to program been exec'ed

5. waiting for an exec'ed process to finish

6. Redirecting output of a exec'ed application

7. Q: interacting with exec'ed commands ?

8. Capturing output from exec'ed command

9. WINDOW: 'exec' command returns immediately

10. exec of daemons doesn't return

11. Tcl's exec-Command return-code

12. Essentials of Prog Lang 2nd ed?

 

 
Powered by phpBB® Forum Software