shell vs. process

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


-----BEGIN PGP SIGNED MESSAGE-----
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"
     ckPing
   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"
   else
     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  
worthless.

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

Dar

- --
**************************************
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

http://www.swcp.com/dsc
dsc at swcp.com

Computer programming
**************************************


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.3 (Darwin)

iQEVAwUBRR8M9ze7tSeWxPOyAQKPxQf9GzIhBB51HLRQKk6UE2s/fgJ2HsuBbxeU
SLnJNUIdjCA40plRUAsDDRjoVulfLAAkUpEP4sDnaOPcmFRCfCvhPtQYOIXiitmu
d0x0w459iMuSx+uYyGGY4xuMuPojt/3IM6Kpi35IYk+RrthrJyJqvsfTphqQJTwA
bSLoJfnNKkeOzbznEvii/vrz+Hh/o5kT9nXzFTifEOCL5yJEw14OtxNuvyAHb2SW
3Kt1fwqa6jqvtPXtt3tJITPBtMAtuLKwGSM3YJ7ACZW1U+9XK/PPdPdS/oln5OP2
F5XWHn2GoE0d42ASyIpkP3X1oI68RpecBCbpzuh8HpJiT1bAFenj5Q==
=/gzR
-----END PGP SIGNATURE-----



More information about the use-livecode mailing list