4

I'm fiddling with bash for the first time and trying to get something simple to work.

#!/bin/bash
    while true ; do
    osascript <<EOF
        tell application "System Events"
            tell every desktop
                set picture to "/Users/bill/Desktop/bckg_changer/ARM_1885.jpg"
            end tell
        end tell
    EOF
done

When I execute this file from the command line, it throws:

Bills-iMac-4:test bill$ ./test.sh
./test.sh: line 11: syntax error: unexpected end of file

I found this question, and the formatting and structure is similar - so not sure what is missing.

The picture changing script itself works - it's when I add the while loop that the end of file error is thrown.

Caveat

I know this script doesn't make sense - the idea was to have a continuous loop, that would revert the desktop picture to the jpg if it was subsequently changed in the System Preferences. Obviously a poor choice of methods and resource use... :-)

1 Answer 1

6

change

osascript <<EOF

to

osascript <<-EOF

The - lets you indent the terminating EOF.

2
  • 2
    Adding the <<-EOF still throws the Error, but removing the indent as you elude to in the answer worked. Commented Jul 21, 2018 at 21:28
  • 3
    @BillArmstrong <<-EOF allows indenting with tabs, but not spaces. Commented Jul 22, 2018 at 3:57

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.