Satimage Previous | Next
Using a UNIX executable
Home Documentation Smile Computing Working with external codes Using a UNIX executable  
  • Within any script in AppleScript you can use any shell command, thus you can run any UNIX executable from any script in Smile. This relies on the do shell script command, a standard command in AppleScript under MacOS X. Executing do shell script [someCommandLine] from an applescript is like executing someCommandLine in a Terminal window (except that do shell script invokes /bin/sh while Terminal uses tcsh by default).

    For all details about the do shell script command see Apple's TN2065.

    set x to "Reagan
    do shell script "echo " & x & "|tr '\\r' '\\n'|sort|uniq"
      --  Result:
    The example below would run a code named spl using a file named f_in as input, and would return the result as a string into the variable s.
    -- assume f_in is the POSIX path to some data file with extension .ctl
    set f_out to change ".ctl$" into ".out" in f_in with regexp
    set sh_scpt to "/sw/bin/spl " & f_in & " > & " & f_out
    do shell script sh_scpt
    set s to read POSIX file f_out
  • AppleScript and UNIX use different conventions for file paths. For details read the page below.
  • If the execution of your code lasts a while you may want to have it run in the background. About how to do so, read the page below.
  • You can view a list of the UNIX commands in the page below.
Version française
Copyright ©2008 Paris, Satimage