Passing a bash list to osascript.

Hi,

I came up with this and of course it isn’t working.
Please can someone guide me to what I have to change?
It reads file from a dir get the file path.
Creates a list like “item1”,“item2”,“item…n” for the applescript way, right??
Pass it to osascript and shows a dialog.
P.s I need later the file list again in the bash script.

Or should I go for something like

to get a kind of escaped list?

Basically, how can I pass list from bash to applescript?

Thank you.

Hi,

This is working.

But still curious why the former code isn’t working and what I should change.

I think it has something to do with this.

Quote style you used:
[i]applescript=‘tell application “Finder”\n’;
applescript=‘$applescript display dialog “hello world”\n’;
applescript='$applescript end tell";

echo $applescript | osascript[/i]
This doesn’t work because when using a single-quote-style string in bash you can’t use var names in it.

So use double quoted instead
[i]applescript=“tell application "Finder"\n”;
applescript=“$applescript display dialog "hello world"\n”;
applescript=“$applescript end tell”;

echo $applescript | osascript[/i]