Find the answer to your Linux question:
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: ...
  1. #1
    Just 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

  2. #2
    Trusted Penguin Cabhan's Avatar
    Join Date
    Jan 2005
    Location
    Seattle, WA, USA
    Posts
    3,230
    The problem is this line:
    Code:
    all_bgs=`echo \ `expr $RANDOM % $cnt\``
    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.

    I assume that you want all_bgs to hold a random number? Why not just do this:
    Code:
    all_bgs=$(expr "$RANDOM" % "$cnt")
    $(...) syntax is the same as `...` syntax, but I find it a lot more readable. Also, the echo is entirely unnecessary here.
    DISTRO=Arch
    Registered Linux User #388732

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...