shell vs. process

Dar Scott dsc at
Sat Sep 30 20:33:40 EDT 2006

Hash: SHA1

On Sep 30, 2006, at 5:37 PM, Kevin Walzer wrote:

> Since I am targeting OS X, I need to know how
> others handle this.

Yes, you can do this.  Here is an example for ping:

local ckpingID = ""
local procName

on startPing ipaddr
   if ckpingID is empty then
     put "/sbin/ping"&&ipaddr into procName
     open process procName for text read
     put empty into field "field"
   end if
end startPing

on ckPing
   read from process procName until empty
   put the result into r
   if r is empty or r is "eof" then
     put it after field "field"
     put "  [" & r & "]  " after field "field"
   end if
   send "ckPing" to me in .3 seconds
   put the result into ckpingID
end ckPing

on stopPing
   close process procName
   wait .1 seconds
   if procName is among the lines of openProcesses() then kill  
process procName
   cancel ckpingID
   put empty into ckpingID
end stopPing

To test that you will need a field "field" on the card.  You can put  
the above script in a card handler.  Then put a couple buttons on the  
card to call startPing and stopPing.  Once you are happy with that,  
then try with tcpdump.

Some years ago I found a number of bugs in "open process" on Windows,  
so bad I don't use it there.  There is a chance that some of those  
are universal, so watch out and check for more errors than in the  
above example.

Also, Rev has a fundamental problem with processes.  It conceptually  
opens up a bi-directional link instead of two one direction links.   
This means you can't close the link to the process's stdin without  
closing the link to its stdout/stderr.  That means you don't see any  
final word, and for processes that sort on input data, this is  

I hope that helps.  Let us know how tcpdump with Rev works out.


- --
Dar Scott
Dar Scott Consulting  and  Dar's Lab
8637 Horacio Place NE
Albuquerque, NM 87111

Lab, office, home:  +1 505 299 9497
Fax:                call above first
Skype:              ask
dsc at

Computer programming

Version: GnuPG v1.4.3 (Darwin)


More information about the Use-livecode mailing list