Created
June 4, 2010 10:14
-
-
Save chapel/425249 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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