LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Desktop (https://www.linuxquestions.org/questions/linux-desktop-74/)
-   -   Random image script? (https://www.linuxquestions.org/questions/linux-desktop-74/random-image-script-676345/)

dirk 10-14-2008 03:55 PM

Random image script?
 
Hello,I am trying to make a script that downloads a random image from the internet and sets it as my background.I am not very good at this so any help is much appreciated :).So far i have something like this

Code:

#!/bin/sh
curl http://www.randomimage.us/index.php -o tmp.txt
cat tmp.txt | grep .jpg | xargs curl -o tmp.jpg
fbsetbg tmp.jpg

There is probably a easier way to do this but I dont know lol.
The problem I have here is with grep,I need it to only grep the url and not everything on that line.How can I do this?
Any help much appreciated
Thanks

dirk 10-14-2008 05:08 PM

Thanks to repz on the #linux channel on freenode I have got this to work.
Code:

#!/bin/sh
curl http://www.randomimage.us/index.php -o tmp.txt
curl -o tmp.jpg `egrep -o "http:[^']+\.jpg" tmp.txt`
fbsetbg tmp.jpg

thanks repz :)


All times are GMT -5. The time now is 01:44 AM.