Results 1 to 2 of 2
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: ...
- 02-11-2008 #1Just Joined!
- Join Date
- Nov 2006
- Posts
- 9
EOF while looking...
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
Code:#!/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
- 02-11-2008 #2
The problem is this line:
You have the first backtick, which starts the expression. You then have a slash-space-backtick, and that backtick closes the expression. A little further on you have a slash-backtick, which escapes the backtick, so nothing happens. The last backtick opens a new expression, which continues onto the next line, causing the problem.Code:all_bgs=`echo \ `expr $RANDOM % $cnt\``
I assume that you want all_bgs to hold a random number? Why not just do this:
$(...) syntax is the same as `...` syntax, but I find it a lot more readable. Also, the echo is entirely unnecessary here.Code:all_bgs=$(expr "$RANDOM" % "$cnt")
DISTRO=Arch
Registered Linux User #388732


Reply With Quote