Shell commands are blocking -- work around?

Sivakatirswami katir at hindu.org
Sat Nov 11 06:00:06 EST 2006


Some on our team are *nix nerds and if I need a powerdrill to add to my
tool box they are, being long time masters of the unix  patchwork quilt
method of micro programs and  pipes...  more than happy to give me
a little bash script. OK so, my cmd line skills are slowly improving and
  I can install these widgets in

/usr/local/bin/some_cool_tool.sh  # on my OSX box, G4 Powerbook

e.g.

SEARCH_PATTERN=$1
locate index.shtml | while read INDEX_FILE; do
   fgrep -H -i "$SEARCH_PATTERN" $INDEX_FILE
done | more
exit 0

(wow, that is soooo concise!)

and  then in Revolution set up a button:

on mouseUp
   put empty into fld "results"
   set the shellCommand to "/bin/sh"
   put "/usr/local/bin/web_content_search.sh" & quote & fld "findString" 
& quote
into tShellCmd
   put shell (tShellcmd) into fld "results"
end mouseUp

It all works, is very "sweet" And it is a  *lot* faster than using 
transcript
  for the same job. *but* Only problem is: it is blocking... and this is 
documented behavior:

"The current handler pauses until the shell returns its result. If the
command was successful but did not return anything, the shell function
returns empty."

I tried this:

on mouseUp
   put empty into fld "results"
   send "searchWebContent" to me in 1 second
end mouseUp

on searchWebContent
   set the shellCommand to "/bin/sh"
   put "/usr/local/bin/web_content_search.sh " & quote & fld 
"findString" & quote into tShellCmd
   put shell (tShellcmd) into fld "results"
end searchWebContent

That also works, but it is still blocking.

Any work arounds? Goal: production environment where we want
to fire off some long processes, go back to work, come back
after a few minutes and pick up the results.

(open and read contents, check for a string in 10,000+ index.shtml
files, return results-hits) OK, so, its already super fast, by a
magnitude  of 20 times faster than the same dig  in BBEdit,
but still, in those 2 minutes I could be getting some work done.

Does this go to the old problem we face  with Rev being a
single  threaded  app? (I don't know exactly what that means,
but Andre keeps waving that flag! and this smells like a case in point...)

Of course I can just open the terminal in OSX and run the cmd there and
go  back  to work in Revolution, but that breaks the integration.
(have to cut and  paste results into Rev... to carry on)

it would really be great (am i dreaming?) if Process #1 went off to get
my Hot Thai Special, while I went back to work (Process # 2) and
then later Process #1 rings a bell saying "Lunch has arrived!"

i.e. background process completion notification interrupts
foreground operations where  "interrupt" is a desired behavior.
ala "Ghost" on OSX

I do a lot of in house RAD data processing apps and there's too much
thumbtwiddly while waiting for results...

  IT rapsters singing:

"Files get big, bigger and bigger
Directories grow, grow and grow...
the busy cursors spin, spin, spin...
work done in one hour goes, down, down, down..."

Sivakatirswami
www.himalayanacademy.com

Get Hinduism Today Digital Edition. It's Free!
http://www.hinduismtoday.com/digital/




More information about the use-livecode mailing list