How can I open an AppleScript application with arguments

I have AppleScript that runs a scan program (command line) that scans it in a specific folder. I need to pass arguments to applescript, which in turn passes arguments to the terminal.

In the terminal, I want to start open -a /Applications/MyScanApp.app myargumentand run AppleScript. How can I pass this argument? Thanks for the help! I am usually a PHP programmer, and this is completely different.

My AppleScript:

tell application "Terminal"
    do script "./myscanprogram myargument 2>&1"
end tell
+4
source share
2 answers

quoted form of? , . , , .

on run argv
    tell application "Terminal"
        do script "./myscanprogram " & quoted form of (item 1 of argv) & " 2>&1"
    end tell
end run

, AppleScript, Terminal.app ? AppleScript do shell script, , stdout.

on run argv
   do shell shell script "/path/to/myscanprogram " & quoted form of (item 1 of argv) & " 2>&1"
end run

, . , AppleScript ,

on run argv
   do script "/path/to/myscanprogram " & quoted form of (item 1 of argv) & " &>/dev/null &"
end run
+8

, AppleScript, , , , ...

Applescript:

on run argv
    tell application "Terminal"
        do script "./myscanprogram " & (item 1 of argv) & " 2>&1"
    end tell
end run

osascript :

osascript pathToYourScript.scpt myargument

, /

+2

All Articles