Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Shell Script Game

  • 03-04-2009 08:44PM
    #1
    Registered Users, Registered Users 2 Posts: 1,129 ✭✭✭


    This thread is inspired by the traditional q&a threads.

    The difference here is you post a shell script to achieve the task set by the before poster and then set a new task for the following poster.

    I'd say keep it simple at first and then ramp up into slightly more complex stuff.
    This will mean the thread could become a useful learning mechanism for the less
    able of us, and allow some people to try their hand at their first script.

    You can post a solution to the task not directly above you, but only if the task is completely out of your depth or you have a more elegant/creative solution to a previous task.

    Task 1: Download the daily new cyanide and happiness comic and set it as the wallpaper. (Ubuntu Gnome, feel free to do other distros/desktop managers)


Comments

  • Registered Users, Registered Users 2 Posts: 1,110 ✭✭✭Skrynesaver


    Stick this in a script and call from cron.
    #!/bin/bash
    if [ ! -d  /home/skrynesaver/tmp/bgdl ] ; then
       mkdir - p /home/skrynesaver/tmp/bgdl
    fi
    cd /home/skrynesaver/tmp/bgdl
    rm index.html bgImage.png
    wget http://www.explosm.net/comics/new/
    wget -O bgImage.png $(grep -o '<img alt="Cyanide and Happiness, a daily webcomic" src="[^"]*' index.html.1 |awk -F'src="' '{print $2}' )
    conftool-2 --direct   --config-source xml:readwrite:/etc/gconf/gconf.xml.mandatory   --type string   --set /desktop/gnome/background/picture_filename bgImage.png
    


    Next up, assume you have received a collection of untagged mp3/ogg files from another OS which are in a tree
    artist-
            |->Album
            ...
             |->Album
                          |->track
                          |->track
    

    The names of the files and directories contain spaces, change all spaces to underscores in the filenames and prompt the user for the artist's genre, add this genre to the ID3Tag of each track.


Advertisement