shell on OS X workaround ( was Re: SNMP Traps)

Dar Scott dsc at swcp.com
Sat Mar 23 02:00:00 EST 2002


On Friday, March 22, 2002, at 04:42 PM, Dar Scott wrote:

> The dictionary on my Revolution has OS X crossed out for "shell" 
> and "read from process", but curiously not for "open process".

I guess the AppleScript programmers on the list laugh every time I 
say there is no Revolution shell() function that works on OS X.

I know nothing about AppleScript, but with a tiny bit of fooling 
around I came up with this:

function shellSH cmd
   -- Sorry, no quote marks in cmd in this version
   -- And shellCommand is ignored
   put "do shell script" & quote & cmd & quote into s
   do s as AppleScript
   put result() into r
   replace numToChar(13) with linefeed in r
   return r
end shellSH

This uses sh and not tcsh that the Terminal program uses.  There is 
probably a way to do this with Terminal, but even those six lines 
of AppleScript are beyond me until I get a reference.

Here is one way to ping, then:

function ping ip
   return shellSH("/sbin/ping -c 1 " & ip) contains "1 packets received"
end ping

This takes over 10 seconds if the computer is not there.  It 
returns virtually immediately if it is.  I tried -w, but it doesn't 
seem to work.

I still hear giggling.

Dar Scott





More information about the use-livecode mailing list