Client-Side Web Scripting
Once you have managed to extract the text you want and to format it to your taste, there is no reason to limit yourself to a manual use of the script, or to use it only at the console for that matter. If you want to do something else and be informed by the computer only when a new headline about Stallman appears, only three more steps are needed.
First, put the script among your cron entries (man cron will tell you everything about this). After that, add the following check to your Perl script:
if ($HTML_FILE =~ m/Stallman/) {
# INFORM ME!!!
}
This will do what you want only if the remaining text does contain the Stallman string (or whatever else you want to know about, of course).
Next, fill the block with something like this:
open (XMSG, "|/usr/bin/X11/xmessage -title \"NEWS!\" -file -") || die; print XMSG $HTML_FILE; close XMSG;
This will open a UNIX pipe to the xmessage program, which pops up a window with the title given with the corresponding switch and containing the text of the file following the -file option. In our case, “-” tells xmessage to get the text from the standard input. As it is, the Perl script will wait to exit, so that you close the xmessage window. This may or may not be what you want. In the case of a cron script, it's much better to let it start xmessage in the background on a temporary file and exit, like this:
open (XMSG, "> /tmp/gee") || die; print XMSG $HTML_FILE; close XMSG; exec "/usr/bin/X11/xmessage -title \"NEWS!\" -file /tmp/gee&";
If you want to process the page only if the content was changed since the last visit, or in the last two hours, you need the Last-Modified HTTP header. It is already available, expressed in seconds since January 1, 1970, in the third element of our @HEADER array. Hence, if you want to do something only on pages modified in the last two hours, start calculating what the time was in that moment (always in the “seconds since...” unit):
$NOW = time; $TWO_HOURS_AGO = $NOW - (3600*2);
Then compare that time with the modification date of the web page:
if ($HEADER[2] > $TWO_HOURS_AGO) {
# do whatever is needed
}
This is one of the rare exceptions to the do-it-yourself rule stated at the beginning: download WMHeadlines (see Resources), install it, and then configure and modify to suit your taste. Out of the box, it can fetch headlines from more than 120 sites and place them in the root menu of Blackbox, WindowMaker, Enlightenment and GNOME in such a way that you start your browser on the dynamic menu voice you click on.
Netscape can be given several commands from the prompt or any script. Such commands will cause Netscape to start if it wasn't already running or will load the requested URL in the current window, or even in a new one. However, the commands to run change depending on whether Netscape is already running. Look at the nslaunch.pl script in the WMHeadlines distribution to figure out how to check if Netscape is already running.
You also can drive Netscape to perform other actions from a script: to print a page just as Netscape would do if driven manually, make it load the page first:
exec($NETSCAPE, '-noraise', '-remote', "openURL($URL,new-window)");
Then save it as PostScript:
exec($NETSCAPE, '-noraise', '-remote', "saveAs(/tmp/netscape.ps, PostScript)");And finally, print it:
exec("mpage -PYOURPRINTER -1 /tmp/netscape.ps");
Or, even add it to the bookmarks:
exec($NETSCAPE, '-noraise', '-remote', "addBookmark($SOME_URL, $ITS_TITLE)");Konqueror, the KDE web browser, can be started simply by invoking it in this way:
system("/usr/bin/konqueror $URL");
Konqueror can be driven by scripts for many nonweb-related tasks,
such as copying files, starting applications and mounting devices.
Type kfmclient --commands for more details.
Galeon can be started in an almost equal way:
system("/usr/bin/galeon $URL");
As explained in A User's Guide to Galeon (see Resources), you also can decide whether Galeon (if already running) should open the URL in a new tab:
system("/usr/bin/galeon -n $URL");
in a new window:
system("/usr/bin/galeon -w $URL");
or temporarily bookmark the $URL:
system("/usr/bin/galeon -t $URL");
Articles about Digital Rights and more at http://stop.zona-m.net CV, talks and bio at http://mfioretti.com
Realizing the promise of Apache® Hadoop® requires the effective deployment of compute, memory, storage and networking to achieve optimal results. With its flexibility and multitude of options, it is easy to over or under provision the server infrastructure, resulting in poor performance and high TCO. Join us for an in depth, technical discussion with industry experts from leading Hadoop and server companies who will provide insights into the key considerations for designing and deploying an optimal Hadoop cluster.
Sponsored by AMD
Built-in forensics, incident response, and security with Red Hat Enterprise Linux 6
Every security policy provides guidance and requirements for ensuring adequate protection of information and data, as well as high-level technical and administrative security requirements for a system in a given environment. Traditionally, providing security for a system focuses on the confidentiality of the information on it. However, protecting the data integrity and system and data availability is just as important. For example, when processing United States intelligence information, there are three attributes that require protection: confidentiality, integrity, and availability.
Learn more about catching the bad guy in this free white paper.
Sponsored by DLT Solutions
| Designing Electronics with Linux | May 22, 2013 |
| Dynamic DNS—an Object Lesson in Problem Solving | May 21, 2013 |
| Using Salt Stack and Vagrant for Drupal Development | May 20, 2013 |
| Making Linux and Android Get Along (It's Not as Hard as It Sounds) | May 16, 2013 |
| Drupal Is a Framework: Why Everyone Needs to Understand This | May 15, 2013 |
| Home, My Backup Data Center | May 13, 2013 |
Enter to Win an Adafruit Pi Cobbler Breakout Kit for Raspberry Pi

It's Raspberry Pi month at Linux Journal. Each week in May, Adafruit will be giving away a Pi-related prize to a lucky, randomly drawn LJ reader. Winners will be announced weekly.
Fill out the fields below to enter to win this week's prize-- a Pi Cobbler Breakout Kit for Raspberry Pi.
Congratulations to our winners so far:
- 5-8-13, Pi Starter Pack: Jack Davis
- 5-15-13, Pi Model B 512MB RAM: Patrick Dunn
- 5-21-13, Prototyping Pi Plate Kit: Philip Kirby
- Next winner announced on 5-27-13!
Featured Jobs
| Linux Systems Administrator | Houston and Austin, Texas | Host Gator |
| Senior Perl Developer | Austin, Texas | Host Gator |
| Technical Support Rep | Houston and Austin, Texas | Host Gator |
| UX Designer | Austin, Texas | Host Gator |
| Web & UI Developer (JavaScript & j Query) | Austin, Texas | Host Gator |
Free Webinar: Hadoop
How to Build an Optimal Hadoop Cluster to Store and Maintain Unlimited Amounts of Data Using Microservers
Realizing the promise of Apache® Hadoop® requires the effective deployment of compute, memory, storage and networking to achieve optimal results. With its flexibility and multitude of options, it is easy to over or under provision the server infrastructure, resulting in poor performance and high TCO. Join us for an in depth, technical discussion with industry experts from leading Hadoop and server companies who will provide insights into the key considerations for designing and deploying an optimal Hadoop cluster.
Some of key questions to be discussed are:
- What is the “typical” Hadoop cluster and what should be installed on the different machine types?
- Why should you consider the typical workload patterns when making your hardware decisions?
- Are all microservers created equal for Hadoop deployments?
- How do I plan for expansion if I require more compute, memory, storage or networking?




22 min 15 sec ago
39 min 38 sec ago
2 hours 32 min ago
4 hours 26 min ago
11 hours 20 min ago
11 hours 36 min ago
13 hours 27 min ago
19 hours 19 min ago
23 hours 51 min ago
23 hours 51 min ago