running command-line programs from rev
dsc at swcp.com
Sun Oct 13 08:09:01 CDT 2002
On Sunday, October 13, 2002, at 04:05 AM, David Vaughan wrote:
> Jan has jumped the gun slightly. You will have a problem if you are using
> 1.1.1. Shell commands in OS X are not supported before 1.5A7. You should
> be OK on this soon.
When I first got Revolution I wrote this to the list. (That means tread
carefully.) It is a simple shell workaround and an example. It has a few
limitations but might work for ditto. I welcome fixes.
> 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.
More information about the use-livecode