Expect: spawned process in sleep state (log_file problem?)

From: Bob - Andover, MA (tsreyb_at_yahoo.com)
Date: 09/22/04


Date: 22 Sep 2004 11:56:11 -0700

I have a working Expect script which spawns another tcl script
(capturing its output to a file) and then continues on to do other
useful things. The general idea is:

#!/usr/local/bin/expect --

#-- First, spawn the xyz script
  log_file xyz.txt
  spawn xyz.tcl
  expect {
    eof {
    }
  }
  catch {close -i $spawn_id}
  catch {wait -i $spawn_id}
  log_file

#-- Now do more stuff ..
  set abc [expr 1 + 2]
  puts "abc is $abc"

Today I decided to see if I could do the "more stuff" section while
the xyz script ran in background.

I think I'm very close to having it operational, but the spawned xyz
script gets into a sleep state for some reason. I suspect it is
because it no longer has its log file attached (because I explicitly
detached it). I could leave it attached, but the problem is I do NOT
want the output of xyz and "more stuff" to be intermingled - I really
want xyz to have its own log file.

Here's how I currently have it implemented (in the broken state):

#!/usr/local/bin/expect --

#-- First, spawn the xyz script
  log_file xyz.txt
  spawn xyz.tcl
  log_file

#-- Now do more stuff ..
  set abc [expr 1 + 2]
  puts "abc is $abc"

#-- Wait for xyz..
  expect {
    eof {
    }
  }
  catch {close -i $spawn_id}
  catch {wait -i $spawn_id}



Relevant Pages

  • Re: problems with grep
    ... I want to write a script that will look at other scripts and find ... And why does this match xyz but not abc ???? ...
    (comp.unix.shell)
  • Re: problems with grep
    ... I want to write a script that will look at other scripts and find ... And why does this match xyz but not abc ???? ...
    (comp.unix.shell)
  • Re: script to take backup
    ... >> i want to create a script to take backup of specific directories. ... >> how can i list only abc, xyz and bcd directories in the search. ...
    (comp.unix.aix)
  • Re: Using spawn() to capture output of child process
    ... e.g. the sbmjob mimicking a spawn and the semicolon ... separated requests mimicking a script: ... and the spawned results to go to spool since that runs ... The spawned child process executes a simple shell script ...
    (comp.sys.ibm.as400.misc)
  • RE: ASP and WMI
    ... I'm wondering if ur using COM to call the script or if your trying to call ... currently logged on user) then once the user loggs of the server the COM+ app ... If ur not using COM but pure ASP then it might be an idea to spawn the ... ie VB can be used to spawn these process via a COM+ ...
    (microsoft.public.windows.server.scripting)