Tags: code, exit, expect, missed, obtain, programming, script, spawn, spawned, tcl, theapplication

[Expect] spawn and exit code

On Programmer » TCL

2,145 words with 2 Comments; publish: Wed, 30 Apr 2008 12:35:00 GMT; (200156.25, « »)

I didn't find - or I missed - the info, how to obtain the "exit code" from t

he

application spawned from Expect script. Can anyone help me?

// _ ___ Michal "Sektor" Malecki <sektor(whirl)kis.p.lodz.pl>

\\ L_ |/ `| /^\ ,() <ethourhs(O)wp.pl>

// \_ |\ \/ \_/ /\ C++ bez cholesterolu: http://www.intercon.pl/~sektor/cbx

"Java does not have pointers!"

All Comments

Leave a comment...

  • 2 Comments
    • Sektor van Skijlen wrote:

      > I didn't find - or I missed - the info, how to obtain the "exit code" from

      the

      > application spawned from Expect script. Can anyone help me?

      >

      It depends on which application you are trying to find

      the exit code for. ie, if its on the local machine or

      if you are doing an rsh to a remote machine.

      p97 of Libes Expect book discusses the csh "$status"

      and sh "$?" variables. p118 shows how to obtain this

      when expect spawns an rsh to perform a remote command

      #!/user/local/bin/expect --

      eval spawn rlogin [lindex $argv 0]

      expect "% "

      send "[lrange $argv 1 end] \r"

      expect "% "

      send "echo \$status\r"

      expect -re "*\r\n(.*)\r\n"

      exit $expect(1,string)

      #1; Wed, 30 Apr 2008 12:36:00 GMT
    • John Zwiebel <jzwiebel.tcl-program.todaysummary.com.cisco.com> writes:

      > Sektor van Skijlen wrote:

      > It depends on which application you are trying to find

      > the exit code for. ie, if its on the local machine or

      > if you are doing an rsh to a remote machine.

      > p97 of Libes Expect book discusses the csh "$status"

      > and sh "$?" variables. p118 shows how to obtain this

      > when expect spawns an rsh to perform a remote command

      > #!/user/local/bin/expect --

      > eval spawn rlogin [lindex $argv 0]

      > expect "% "

      > send "[lrange $argv 1 end] \r"

      > expect "% "

      > send "echo \$status\r"

      > expect -re "*\r\n(.*)\r\n"

      > exit $expect(1,string)

      If you're spawning the app directly without going through a shell, the

      exit code is one of the values returned by Expect's wait command.

      Don

      #2; Wed, 30 Apr 2008 12:37:00 GMT