Re: AppleScript and UNIX: Together at last!
Re: AppleScript and UNIX: Together at last!
- Subject: Re: AppleScript and UNIX: Together at last!
- From: Chris Nebel <email@hidden>
- Date: Sun, 25 Mar 2001 00:36:40 -0800
- Organization: Apple Computer, Inc.
email@hidden wrote:
>
Will we be able to use the command line from within scripts? Something like
>
>
tell app "terminal.app"
>
set x to pwd
>
if x = "/users/myself" then
>
cd ../
>
end if
>
set theFiles to ls as list
>
end tell
>
>
This would be awesome and incentivize my learning more Unixy stuff.
"Will" is the operative word here. There's no support for this in 10.0 --
Terminal isn't scriptable in any meaningful way, and there's no direct support
for this in AppleScript. However, it's an oft-repeated request, so it's on
our list of Things To Do. (Language nit: "incentivize" and its parent
"incent" are not words. Try "encourage" instead. Sorry, pet peeve of mine.)
In the meantime, check out this little gadget posted here about four months
ago:
>
ASConsoleSend: Send commands to the console through AppleScript
>
quicksend: send a console command
>
quicksend list -- {something}
>
>
<http://www.autographsystems.com/Wilcox/Applescript/ShellScriptor001d1.sit>
>
>
*************************************
>
tell application "ShellScriptor(Carbon)"
>
set x to quicksend "uptime"
>
end tell
>
>
activate
>
display dialog x
>
**************************
Alternatively, you can take the inside-out approach: instead of calling Unix
things from AppleScript, call AppleScript things from Unix using the osascript
command -- see its man page for more details.
--Chris Nebel
AppleScript Engineering