waveclaw
05-01-2007 10:30:01
Linux SIG 4 January 2007
Expecting a small group due to the holidays.
'Newbie' discussion
- Your desktop is really a directory in your home directory: /home/username/Desktop
- fvwm, Gnome, KDE, WindowMaker, etc are window managers. Window managers != distro, just the desktop. They determine how your desktop looks and are available on almost all distributions of Linux.
- Installing software under Linux is different than in windows (adobe, Java / jre, and apt-get / synaptic)
- usb wireless networking under Linux is 'often fun,' especially for drivers.
- http://linux-wless.passys.nl/
- There are Gigafast drivers, but they are independently packaged source-code only modules
Topic proposal: 'stunt' config next month to put the zd1211 driver on a guests new Linux system if he doesn't get the Gigafast drivers working before then.
Intro Topic: X|K|Ubuntu
Kubuntu
Logged in as the 'admin' user.
- KDE desktop. Most applications' names start with a k
- Default theme is very blue
- Large panel at bottom of the screen with the Application menu
- Menu editing is easy.
Control panel (all tied to your login)
- KDE can style Gnome apps via the control panel
- Hardware setting
- Networking and filesharing settings
- Users, groups, loging, etc managed from here
File Browser
- Knoqueror, also the default web browser
- /home/admin/Desktop holds everything kept or put on the desktop
- Put an xeyes application shortcut on the desktop, can run from desktop
- Sample download of a driver file (.tar.gz) to the /home directory
Ubuntu
Logged in as 'eric'
- Gnome Desktop
- Everything is very brown colored
- Screenshot tools
Applications, Places, and System menus instead of 1 catch-all menu
- Alacarte menu editor vs. shortcuts in /usr/share/applications
- Top and bottom panels, control panel in the System menu
File Browser
- Nautilus
- Uses Firefox as the default web browser
- Put an xeyes application shortcut on the desktop, when run it's window has decorations (window border, max/min/close buttons, titlebar) unlike when under KDE
- Demonstration of KDE applications running under Gnome (katomic)
- Themes: changing folders, window decorations, icons
Xubuntu
Logged in as 'elliot'
- Very lightweight (this is a small 128Mb RAM laptop system)
- xfce Desktop with a blue theme
- looks like a low-resolution Gnome Desktop with few / no icons or artwork
- The system was pre-installed via a network kickstart-type install
File Browser
- Thundar
- Uses firefox as the default web browser
- Demonstration of how slow KDE applications start
- Demonstration of xfmedia for playing videos, music
RedHat 7.2 WindowMaker
Logged in as the presenter on his old workstation
- WindowMaker is very different
- Based on the NetStep environment
- Floating 'dock' instead of panels
- Docks is called a 'Warf' and small applets can be docked to it
- Menu is on the desktop (right click to pop up) and filled with many things
- Windows resize differently, including animated indicators of window dimensions
- Demonstration of window shading when the titlebar is double-clicked
Advanced Topic: Eric Teaches Perl, Part 5
Note that due to copy errors, Part 4 was not labeled as such.
Advanced modules, as demonstrated on an Ubuntu 6.06 system with Perl 5.8
LWP: Lib for Www and Perl, is a package of web browsing utilities for Perl. It is one of the most popular and widely used packages. In general, lwp is better when you need to part the html from a connection to a web server (e.g. when dealing with frontpage extensions causing server crashes by writing an automated apache restart script in Perl). Many screen scrapers are Perl scripts that automate a live human session with a web browser.
Install on Ubuntu is easy:
1. apt-cache search lwp
2. find relevant package (libwww-perl)
3. apt-get install libwww-perl
man lwp
- the manual pages are very helpful
- however, read the examples first, then look at the rest of the manpage for reference
Example of LWP
Syslog is another popular Module available on UNIX platforms.
Example of Syslog
POSIX library is available on UNIX platforms
Gets you access to the standard UNIX system utilities.
Example of POSIX
Lazy Mail sending.
There are many different type of mail libraries with many more-or-less useful interfaces. Mime::Tools and Net::SNMP can be combined to build messages with complex payloads (multi-part, MIME encoded attachments, etc) and be sent directly without access to mail or sendmail commands. Usually the libraries are complex and not more effective than lazy system() commands. System() is very slow and generally indicates lack of programmer awareness of the available modules. In this case, it's par for the course to use it for mail handling.
Example of lazy mailing
All these modules are combined into a simple script that checks for an apache result and starts apache if needed:
A longer and more complex example was given about automating upload of certain files to a certain government website. Due to security considerations for the (horribly designed and poorly implemented) website in question, that discussion is omitted.
Expecting a small group due to the holidays.
'Newbie' discussion
- Your desktop is really a directory in your home directory: /home/username/Desktop
- fvwm, Gnome, KDE, WindowMaker, etc are window managers. Window managers != distro, just the desktop. They determine how your desktop looks and are available on almost all distributions of Linux.
- Installing software under Linux is different than in windows (adobe, Java / jre, and apt-get / synaptic)
- usb wireless networking under Linux is 'often fun,' especially for drivers.
- http://linux-wless.passys.nl/
- There are Gigafast drivers, but they are independently packaged source-code only modules
Topic proposal: 'stunt' config next month to put the zd1211 driver on a guests new Linux system if he doesn't get the Gigafast drivers working before then.
Intro Topic: X|K|Ubuntu
Kubuntu
Logged in as the 'admin' user.
- KDE desktop. Most applications' names start with a k
- Default theme is very blue
- Large panel at bottom of the screen with the Application menu
- Menu editing is easy.
Control panel (all tied to your login)
- KDE can style Gnome apps via the control panel
- Hardware setting
- Networking and filesharing settings
- Users, groups, loging, etc managed from here
File Browser
- Knoqueror, also the default web browser
- /home/admin/Desktop holds everything kept or put on the desktop
- Put an xeyes application shortcut on the desktop, can run from desktop
- Sample download of a driver file (.tar.gz) to the /home directory
Ubuntu
Logged in as 'eric'
- Gnome Desktop
- Everything is very brown colored
- Screenshot tools
Applications, Places, and System menus instead of 1 catch-all menu
- Alacarte menu editor vs. shortcuts in /usr/share/applications
- Top and bottom panels, control panel in the System menu
File Browser
- Nautilus
- Uses Firefox as the default web browser
- Put an xeyes application shortcut on the desktop, when run it's window has decorations (window border, max/min/close buttons, titlebar) unlike when under KDE
- Demonstration of KDE applications running under Gnome (katomic)
- Themes: changing folders, window decorations, icons
Xubuntu
Logged in as 'elliot'
- Very lightweight (this is a small 128Mb RAM laptop system)
- xfce Desktop with a blue theme
- looks like a low-resolution Gnome Desktop with few / no icons or artwork
- The system was pre-installed via a network kickstart-type install
File Browser
- Thundar
- Uses firefox as the default web browser
- Demonstration of how slow KDE applications start
- Demonstration of xfmedia for playing videos, music
RedHat 7.2 WindowMaker
Logged in as the presenter on his old workstation
- WindowMaker is very different
- Based on the NetStep environment
- Floating 'dock' instead of panels
- Docks is called a 'Warf' and small applets can be docked to it
- Menu is on the desktop (right click to pop up) and filled with many things
- Windows resize differently, including animated indicators of window dimensions
- Demonstration of window shading when the titlebar is double-clicked
Advanced Topic: Eric Teaches Perl, Part 5
Note that due to copy errors, Part 4 was not labeled as such.
Advanced modules, as demonstrated on an Ubuntu 6.06 system with Perl 5.8
LWP: Lib for Www and Perl, is a package of web browsing utilities for Perl. It is one of the most popular and widely used packages. In general, lwp is better when you need to part the html from a connection to a web server (e.g. when dealing with frontpage extensions causing server crashes by writing an automated apache restart script in Perl). Many screen scrapers are Perl scripts that automate a live human session with a web browser.
Install on Ubuntu is easy:
1. apt-cache search lwp
2. find relevant package (libwww-perl)
3. apt-get install libwww-perl
man lwp
- the manual pages are very helpful
- however, read the examples first, then look at the rest of the manpage for reference
Example of LWP
#!/usr/bin/perl
use LWP::UserAgent;
use HTTP::Request::COmmon;
.
.
.
my $useragent = LWP:: UserAgent->new();
$useragent->timetout(10); # in seconds
my $request = $useragent('GET url-to-get');
.
.
.
if ( $request->is_success() ) { # some code to run on success (e.g. http code 200) }
if ( $request->content =~ /some regex/ ) { # some code to run when content matches }
if ( $request->is_not_success() ) { # code to run on fail (http codes 404, 305, etc) }
Syslog is another popular Module available on UNIX platforms.
Example of Syslog
#!/usr/bin/perl
use sys::Syslog;
openlog('application', 'pid','user); # replace application with relevant app
syslog('warning','message');
syslog('warning_level','messages format with %s or %d or other','string','123456');
POSIX library is available on UNIX platforms
Gets you access to the standard UNIX system utilities.
Example of POSIX
#!/usr/bin/perl
use POSIX gw/uname/; # note: only getting the uname command from the POSIX library
my (undef, $hostname) = uname; # many parts are output, only wanted 2nd (hostname)
Lazy Mail sending.
There are many different type of mail libraries with many more-or-less useful interfaces. Mime::Tools and Net::SNMP can be combined to build messages with complex payloads (multi-part, MIME encoded attachments, etc) and be sent directly without access to mail or sendmail commands. Usually the libraries are complex and not more effective than lazy system() commands. System() is very slow and generally indicates lack of programmer awareness of the available modules. In this case, it's par for the course to use it for mail handling.
Example of lazy mailing
#!/usr/bin/perl
open(MAIL, '| mail -s topic user@host.domain.com'); # note the use of the pipe (|) char
print(MAIL "my email message which can be really long.\n");
# ^^^ note lack of a comma, just a space here (inconsistent, but important)
close(MAIL);
All these modules are combined into a simple script that checks for an apache result and starts apache if needed:
#!/usr/bin/perl -w
use strict;
use LWP::UserAgent;
use HTTP::Request::Common;
use POSIX qw/uname/;
use sys::Syslog;
openlog('apache_restart', 'pid','user);
my $useragent = LWP:: UserAgent->new();
$useragent->timetout(10);
my $request = $useragent('GET http://localhost/testfile.html');
unless ($request->is_success() && $request->content =~ /some regex/) {
system('/etc/init.d/httpd stop');
sleep(20);
system('/etc/init.d/httpd start');
syslog('warning','Apache was restarted because it failed to return the webpage testfile.html');
my (undef, $hostname) = uname;
open(MAIL, '| mail -sapache_restart user@host.domain.com');
print(MAIL "Apache server on $hostname was restarted.\n");
close(MAIL);
};
A longer and more complex example was given about automating upload of certain files to a certain government website. Due to security considerations for the (horribly designed and poorly implemented) website in question, that discussion is omitted.