Weblog entry #43 for Utumno

firefox -new-tab
Posted by Utumno on Wed 24 Sep 2008 at 04:39
Tags:

We sometimes forget that those shiny graphical apps like firefox can be controlled from the commandline, too!

For example, here's a way to automatically open up all articles that are currently on this site's main page, each one in its own tab:

#!/bin/sh

TMPFILE=`mktemp`
URL="http://www.debian-administration.org";

wget -q $URL -O - | sed -n "s#.*<h2 class=\"title\"><a href=\"\(\/articles.*\)\".*#$URL\1#p" > $TMPFILE

I=0

while read line
do
  firefox -new-tab $line &
  if [ $I -eq 0 ]; then
     sleep 5
     let "I+=1"
  fi
done < $TMPFILE

rm -f $TMPFILE

( after opening up the first article we better sleep for 5 seconds, otherwise we end up with many firefoxes)

 

Comments on this Entry

Posted by Anonymous (147.102.xx.xx) on Thu 25 Sep 2008 at 16:58
Why don't you pipe the output of sed to the while loop? No need for a temporary file.

[ Parent | Reply to this comment ]

Posted by Utumno (118.160.xx.xx) on Fri 26 Sep 2008 at 22:34
[ Send Message | View Utumno's Scratchpad | View Weblogs ]

Because I dont know how to pipe multiline input to the loop...

[ Parent | Reply to this comment ]

User Login

Username:

Password:

[ Advanced Login ]

Register Account

Quick Site Search