Guest User

Untitled

a guest
May 27th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  1. set text item delimiters to " "
  2. set scriptName to text item 1 of parameter
  3. set paramCount to count parameter's text items
  4. try
  5. set scriptParameters to text items 2 thru paramCount of parameter
  6. on error
  7. set scriptParameters to ""
  8. end try
  9. set text item delimiters to ""
  10.  
  11. if scriptName contains "/" then
  12. set pathName to ""
  13. else
  14. set a to path to application support from user domain
  15. set p to POSIX path of a
  16. set pathName to p & "Linkinus 2/Scripts/External/"
  17. end if
  18.  
  19. try
  20. if scriptName ends with ".rb" then
  21. set scriptType to "ruby "
  22. else if scriptName ends with ".php" then
  23. set scriptType to "php -f "
  24. else if scriptName ends with ".py" then
  25. set scriptType to "python "
  26. else if scriptName ends with ".pl" then
  27. set scriptType to "perl "
  28. else if scriptName ends with ".sh" then
  29. set scriptType to "bash "
  30. end if
  31. set text item delimiters to " "
  32. set output to do shell script "/usr/bin/env " & scriptType & quoted form of (pathName & scriptName) & " " & scriptParameters
  33. set text item delimiters to ""
  34.  
  35. return output
  36. on error
  37. 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
  38. end try
Add Comment
Please, Sign In to add comment