Hi, I'm trying to use a code that change the wallpaper automatically, but I obtain the next error:
Line 18: Unexpected EOF while looking for matching `` '
Line 25: sintax error: Unexpected End of File

I think the code line is:
cnt=`wc -l "$temp_bg_list" | cut -f1 -d " "`

But I really don't understand what is the problem, so, can you help me?

Thanks a lot

#!/bin/bash
#tomado de: www.djlosch.com

bg_path=/home/tamayo/wallpapers
extensions="jpg png gif jpeg JPG GIF PNG"
temp_bg_list=/tmp/bg_change_list

rm -f $temp_bg_list

for extension in $extensions
do
    find $bg_path -iregex ".*.$extension" >> "$temp_bg_list"
done

cnt=`wc -l "$temp_bg_list" | cut -f1 -d " "`
all_bgs=`echo \ `expr $RANDOM % $cnt\``

selected_bg=`head -n$all_bgs "$temp_bg_list" | tail -n1`

logger "Changed desktop to: $selected_bg"

gconftool-2 -t string -s /desktop/gnome/background/picture_filename 
"$selected_bg"
exit 0

Hey There,

I think might actually be this line:

all_bgs=`echo \ `expr $RANDOM % $cnt\``

since the first backtick inside your backtick has a space between the escape and backtick.
It think it should be this

all_bgs=`echo \`expr $RANDOM % $cnt\``

Sometimes I find it easier to mix different ways of doing the same thing when I have multiple recursive exec, like the line above could be change to:

all_bgs=$(echo `expr $RANDOM % $cnt`)

and still do the same thing.

Hope that helps :)

, Mike

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.