Expect: How to get the exit code from spawned process

Expect: How to get the exit code from spawned process

Content Index :

Expect: How to get the exit code from spawned process
Tag : development , By : kalfa
Date : November 29 2020, 03:01 PM

fixed the issue. Will look into that further I am not quite sure if it a good idea to create a new Thread or "reopen" this 3-year old Thread, if you think it's better to reopened it, please excuse my spam in this Forum but I have the same Problem and don't get a solution out of the information of the thread. At the Moment I had a script that looks like this: , You should write like this:
expect {
  -re "Password: " {
    send "$pass\r"
expect eof

catch wait result
exit [lindex $result 3]
expect {
  -re "Password: " {
    send "$pass\r"

  eof {
    catch wait result
exit [lindex $result 3]

No Comments Right Now !

Boards Message :
You Must Login Or Sign Up to Add Your Comments .

Share : facebook icon twitter icon

How to return spawned process exit code in Expect script?

Tag : linux , By : toki
Date : March 29 2020, 07:55 AM
Hope this helps You're already waiting for the eof at the end of your loop, you just need to use wait and catch the result:
spawn true
expect eof
catch wait result
exit [lindex $result 3]
spawn false
expect eof
catch wait result
exit [lindex $result 3]

How to get the exit code of spawned process in expect shell script?

Tag : linux , By : xguru
Date : March 29 2020, 07:55 AM
fixed the issue. Will look into that further With the help of glenn, I got solution.. and my final script is::
expect script is
 [Linux Dev:anr ]$ cat testexit.sh
 export tmp_script_file="/home/anr/tmp_script_temp.sh"
 cp /home/anr/tmp_script $tmp_script_file
 chmod a+x $tmp_script_file
 cat $tmp_script_file
 expect << 'EOF'
 set timeout -1
 spawn  $env(tmp_script_file)
 expect {
 "INVALID "  { exit 4 }
 timeout     { exit 4 }

 foreach {pid spawnid os_error_flag value} [wait] break

 if {$os_error_flag == 0} {
     puts "exit status: $value"
     exit $value
 } else {
     puts "errno: $value"
     exit $value
 echo "spawned process status" $?
 rm -f $tmp_script_file
 echo "done"
 [Linux Dev:anr ]$ cat tmp_script
 exit 3
 [Linux Dev:anr ]$ ./testexit.sh
 exit 3
 spawn /home/anr/tmp_script_temp.sh
 exit status: 3
 spawned process status 3

TCL/Expect equivalent of Bash $@ or how to pass arguments to spawned process in TCL/Expect

Tag : bash , By : dexteryy
Date : March 29 2020, 07:55 AM
help you fix your problem If somebody wants to call external program (which was passed as a Bash argument) from Bash and also pass it command line options (which were also passed as a Bash arguments) the solution is fairy simple: , To literally translate your example
set program [lindex $argv 0]
set arguments [lrange $argv 1 end]
spawn $program {*}$arguments
spawn [lindex $argv 0] [lrange $argv 1 end]
spawn [lindex $argv 0] {*}[lrange $argv 1 end]
proc lshift {varname} {      
    upvar 1 $varname var
    set var [lassign $var first]
    return $first
expect1.6> set argv {foo bar baz}
foo bar baz
expect1.7> set script [lshift argv]
expect1.8> set script
expect1.9> set argv
bar baz

need to return exit code of spawned procees from expect script

Tag : shell , By : KingGuppy
Date : March 29 2020, 07:55 AM

Expect spawned snx process dies

Tag : bash , By : Paolo
Date : March 29 2020, 07:55 AM
Related Posts Related QUESTIONS :
  • AWS Lambda + Serverless, where/how to deploy js module that couldn't be bundled?
  • how to place mobile call from PWA
  • How to get connected clients and client certificate in node-opcua server
  • Passing dictionary from one template to another in Helm
  • Kivy. Position of GridLayout inside ScrollView
  • How can I try to place a pending order every X minutes till it's successfull?
  • Is there a way to download the SonarLint report generated in Eclipse IDE?
  • How to Open Port in Windows Firewall using C++ Builder?
  • How to put "OR" operator in Karate API assertion statement
  • Get .model.json as String
  • Proof Process busy on combine_split
  • Does memoization work on smple .select with strings?
  • Check if movement ended
  • Determine If a String Is Present in a List or Map?
  • Shortest_Path Interpretation of Edge Weight
  • Azure Pipelines - What's the difference between a Pipeline artifact and a Build artifact?
  • How to save content of bilion websites found by search engine (how google is doing it)
  • dynamodb index does not return all data
  • Either scp or roles claim need to be present in the token using when application permissions to read sharepoint sites
  • how to speed up sympy-matrix of matrics calculation runtime
  • SNMP Walk and Get / GetNext for MIBs that are not supported by agent
  • Using Puppeteer, how to get Chrome DevTools' "Network" tab's timing information?
  • Twig uses htmlspecialchars internally for escaping. How do I pass ENT_NOQUOTES?
  • How to use @pnp/sp to retrieve users for a People Picker
  • How to find the last letter of a line with TUSTEP
  • SwiftUI: What is the Proper Logic Statement to Prevent Views From Disappearing While Using a Custom Slider
  • alfresco start workflow directly from document library
  • How to migrate Bot Services to framework 4.3 ussing AppSettings
  • How to make a window always appear at specified location?
  • M3 Java: How to check that a class implements a function from an interface
  • Handling routing_key for topic routing
  • Gremlin Java 3.4 withRemote deprecated
  • Libtorch: cannot load traced lstm scriptmodel
  • Correct HAR format for sendHarRequest
  • If statement in Robot
  • How to set STUN servers in JsSIP 3.3.0
  • Delete large amount of Vertexs from the Cosmos Db using Gremlin queries
  • How to see details about user, even if they're not registered?
  • How to apply scrollbar-primary to a div?
  • Spark: How to aggregate/reduce records based on time difference?
  • Can I query the list of variables and types
  • Use case for "sets of tuple data" in Pyomo
  • how to separate columns in hive
  • Matching borrowed enum - why is this syntax equivalent?
  • How to Query Realm DB Browser?
  • Cannot access font awesome in custom Liferay 7.1 theme
  • how to create a custom login page in salesforce.com?
  • Why does MPI_Init accept pointers to argc and argv?
  • How to create a Turing machine that takes a single digit decimal number from 0 - 9 and output the cube
  • Windbg + IDA: calculate an address in a module
  • Swing Panel Question
  • Spring-ws client from WSDL
  • New or not so well-known paradigms, syntax features and behaviours of programming languages?
  • How do I build a J2EE EAR file in RAD using Maven?
  • JPEG image with alpha channel on website
  • Graphics/Vision Interesting Topics
  • Code golf: the Mandelbrot set
  • ASP Classic Session Variable Not Always Getting Set
  • Install avisynth under Linux via SSH
  • Drupal Views display newest content per taxonomy limit to one node
  • shadow
    Privacy Policy - Terms - Contact Us © scrbit.com