Skip to content

Instantly share code, notes, and snippets.

@chapel
Created June 4, 2010 10:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chapel/425249 to your computer and use it in GitHub Desktop.
Save chapel/425249 to your computer and use it in GitHub Desktop.
set text item delimiters to " "
set scriptName to text item 1 of parameter
set paramCount to count parameter's text items
try
set scriptParameters to text items 2 thru paramCount of parameter
on error
set scriptParameters to ""
end try
set text item delimiters to ""
if scriptName contains "/" then
set pathName to ""
else
set a to path to application support from user domain
set p to POSIX path of a
set pathName to p & "Linkinus 2/Scripts/External/"
end if
try
if scriptName ends with ".rb" then
set scriptType to "ruby "
else if scriptName ends with ".php" then
set scriptType to "php -f "
else if scriptName ends with ".py" then
set scriptType to "python "
else if scriptName ends with ".pl" then
set scriptType to "perl "
else if scriptName ends with ".sh" then
set scriptType to "bash "
end if
set text item delimiters to " "
set output to do shell script "/usr/bin/env " & scriptType & quoted form of (pathName & scriptName) & " " & scriptParameters
set text item delimiters to ""
return output
on error
return "The script you entered does not exist or was typed incorrectly. If you are trying to use a script not in ~/Library/Application Support/Linkinus 2/Scripts/External/ then you need to supply the full path to the script. Filename entered: " & scriptName
end try
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment