How to do 'shell' functions in OS X |
(Mac OS X Only)
|
shell()
function that works on OS X.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.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 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.function ping ip return shellSH("/sbin/ping -c 1 " & ip) contains "1 packets received" end ping