I have a problem passing multiple arguments to an AppleScript. My scripting environment is Mac OS X 10.4.11, my AppleScript version is 1.10.7 and I am working on a 1.8 GHz PowerPC G5.
I created a small sample script, which looks as follows:
on run {argitems}
set argitems to argitems as list
repeat with argitem in argitems
set command to "logger " & quoted form of argitem
do shell script command
end repeat
end run
The script takes the arguments passed on the command line and logs them to the console with the logger command (I don’t use display dialog, as user interaction is not allowed when executing scripts with osascript).
Now when I execute the above script with the following osascript command, it won’t log all given arguments, but only the first one:
osascript osascript /Users/martin/Desktop/arglogger.scpt 'var1' 'var2' 'var2'
-- will only log var1 on the console app...
Is this a known bug? I need to pass multiple file paths to a script at once and if this is not possible, then I am screwed I really hope for your help!
When I read this I remembered one of your posts from last year showing how to accomplish this.
Is what you are talking about here different in some way that is not allowing display dialog?
Yes. The company I am working for uses Mac OS X 10.4.11 only (last system, which features support for the classic environment). But unfortunately Tiger does not have the AppleScript Runner application installed mentioned in my post Now I have to rewrite a lot of scripts to not use any user interaction…
I just tested this on 10.4.11 and it worked.
I put three arguments in from the command line and got three display dialogs.
The only thing returned was the last button.
There are some other examples people added to your post from last year.
You should check them out.
Does this work for you or am I missing something?
on run args
repeat with anArg in args
tell application "System Events"
display dialog anArg
end tell
end repeat
end run
Many thanks for testing this for me! And yes, it helps me out. But I also have to rewrite a lot of scripts, as they are supposed to run silently on a server now, reading configuration files instead of getting interactive user input.