Well here’s the problem…
I’ve worked out how to assign the result of an applescript operation to a bash variable within a shell script;
foo=osascript -e 'some applescript opperation'
but i need to be able to do the opposite also.
how do i (within a shell script) get the result of a bash command line into a variable for applescript to play with?
I’m trying to make a itunes controller through applescript but it needs have an interface of .sh files. (the point being to control iTunes over ssh).
And so I need to be able to (the middle of a shell script) transfer variable values between applescript one liners and the rest of the shell script and back.
For clarity’s sake here is what I’m currently working on
#!/bin/sh
if [ $# = 0 ]; then
echo "syntax: toggleshuffle.sh playlist"
else
if [ `osascript -e 'tell application "iTunes" to get shuffle of playlist "Rock"'` = `echo "true"` ]; then
# This line is my best guess at how to do this but the do shell script bit doesn't seem to be able to see the $@ variable from the rest of the script
osascript -e 'tell application "iTunes" to set shuffle of playlist (do shell script "echo $@") to false'
else
osascript -e 'tell application "iTunes" to set shuffle of playlist (do shell script "echo $@") to true'
fi
fi
osascript -e 'tell application "iTunes" to set shuffle of playlist (do shell script "echo ' $@'") to false'
do the trick, i.e., place $@ outside the single quotes? I don’t script iTunes so I don’t understand the significance of $@ here, but if I just set z to XYZ and substitute $z for $@ in your script then (do shell script) doesn’t object, whereas it does if I don’t break up the command.