howto: bash.org quotes at logon
Hi all,
Many ppl like to have a fortune cookie displayed at console logon, which can be done by installing the 'fortune' package. But here's an alternative, displaying a random IRC quote from bash.org, with a 'funny' rating above 0. Prerequisites: - Internet connection - coreutils, gawk, grep, links - change the $workdir to your liking Here's the script to get a list of URL's pointing to random bash.org quotes: Code:
#!/bin/bash Code:
#!/bin/bash |
Hey jbarelds, it works like a charm, thank you! I enhanced the filter with a sed oneliner instead of more pipes so it outputs only the quote and runs faster. Here:
Code:
# Prerequisites: |
Better
In a frantic state of sed addiction i've polished it to a better version yet:
Code:
#!/bin/bash 1 */2 * * * /bin/bash -c /home/me/scripts/randomquote/bash.org gimmemore and in .bashrc/.profile/profile, well just /home/me/scripts/randomquote/bash.org It will connect only to grab a page o'quotes. The delay before getting the prompt was starting to getting on my nerves :( EXPLANATION with "gimmemore" it fetches the page with all the quotes, and filters everything before and after the quotes, leaving only the entries and between them certain strings that appear after every quote (you can see them in the saved file). I'll use those "special lines" as markers. when you call it w/o arguments it 1) count the total number of markers (aka number of quotes+1), pick a number between 1 and total markers-1, and saves it in $quote 2) print the quotefile with linenumbers, filtering only markers, filtering again for the one i've picked, and saves the *real* line number again in $quote 3) finally it prints everything in between that linenumber and the next marker |
Quote:
Your second take is basically a new script, looks good! |
Quote:
Yes i'm using the new one now and it's good. It'd be nice to add more things, like filters, autoconfig, exporting to "fortune" and whatnot. I think $random can have random values also, and there also other params in the site that can be used as options. I suggest that changes or variations of any kind keep being posted to this thread as an aid to the poor unix admins of the world staring at prompt most of their time (like this one :() |
Why not use the wget utility:
Code:
wget http://bash.org/?random1 -O - |
Quote:
But they can get filtered with sed though, and <p class="quote"></p> might be a better wrapper too. I'm at my work right now, but i'll try that later. Of course, if you feel like it, would kick to see the mod already posted :) |
All times are GMT -5. The time now is 10:50 AM. |