Ответ 1
Не очень понятно, КАК вы пытаетесь запустить его в Терминале. Но я предполагаю, что вы сохранили текстовый файл applecript с помощью #!/usr/bin/osascript
shebang и #!/usr/bin/osascript
файл chmod
чтобы иметь возможность его выполнить.
Затем вызывается файл в терминале, просто используя путь к файлу.
#!/usr/bin/osascript
#Here be the rest of your code ...
set output to ("Song: " & song & " - " & artist & " - " & album)
do shell script "echo " & quoted form of output
end tell
Обновление 2, в ответ на комментарии.
Если у меня есть текстовый файл с разделителями табуляции с содержанием как:
track Skin Deep Beady Belle Closer
Вкладки настроены так: трек **** TAB **** Skin Deep **** TAB **** Beady Belle **** TAB **** Closer
И файл сценария как:
on run fileName
set unique_songs to paragraphs of (read POSIX file fileName)
repeat with nextLine in unique_songs
if length of nextLine is greater than 0 then
set AppleScript text item delimiters to tab
set song to text item 2 of nextLine
set artist to text item 3 of nextLine
set album to text item 4 of nextLine
set output to ("Song: " & song & " - " & artist & " - " & album)
do shell script "echo " & quoted form of output
end if
end repeat
end run
Затем в Терминале запустите:
/usr/bin/osascript ~/Documents/testOsa2.scpt ~/Documents/testTab.txt
Я вернусь:
*Song: Skin Deep - Beady Belle - Closer*