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

return value from an expect script

272 views
Skip to first unread message

carson...@yahoo.com

unread,
Jul 29, 2005, 12:15:47 PM7/29/05
to
I am having a problem with the return value from an expect script.
I call the expect script from an executable and it is used to login to
an rf gun in a warehouse. Once the login is accomplished, I go to
interact mode so the gun is talking directly to the calling process.
My problem is that when something goes wrong with the gun and it's
process is no longer usefull it either goes to init or dies and one or
both of the calling process goes to runaway.
It appears that when the gun process dies the expect process always
returns successful to the calling curses process even tho there is no
longer a display attached causing the runnaway.
Does anyone have any thoughts on this.

Thanks,
Carson

carson...@yahoo.com

Michael A. Cleverly

unread,
Jul 29, 2005, 9:06:46 PM7/29/05
to

When the spawn'ed process dies interact will return. If you want the
script to exit at that point follow it with an exit. I.e.,

spawn /your/program
# do your login
interact
exit 1 ;# or some other suitable exit status

... or something simillar. Then have your executable that calls the
Expect script test the exit status to see if it should exit (or have it
exit too).

Michael

carson...@yahoo.com

unread,
Jul 30, 2005, 8:19:50 PM7/30/05
to
Thanks, actually I didn't realize that interact returned. However, I'm
not sure that will help because the expect process is forked and exec'd
from the main process and the parent waits for the child to close, but
the wait doesn't have a way to check the return status for the child
process, at least I don't think so, I'll take a closer look and see if
this will work. At any rate I do appreciate the response.

0 new messages