From sechrest at peak.org Wed Nov 1 17:28:41 2000 From: sechrest at peak.org (John Sechrest) Date: Wed Aug 4 00:05:14 2004 Subject: Intro and two questions Message-ID: <200011012328.PAA28800@spock.peak.org> Hello, I recently heard about this list and signed up a little bit ago. I am principle of a small ISP in Corvallis and I teach at Oregon State University (currently web design and system administration). I would like to ask you two questions: 1) In my Unix System admin class, I like to do a bit of perl programming. I like to use that perl as a way to learn more system administration. I need to come up with 30 short perl scripts that I would use as an assignment. Every now and then I like to ask others for ideas about what scripts they can think of. Here is the scenario.... We have 30 students. All of them like to do things by themselves. The assignment is to use 4 hours to write a perl program to do something... They are supposed to work together. I say this but they don't do it. And so in order to make working together work, I need to give each student a different task. Tasks are things like: 1 Count the number of people in the password file using each different shell by looking at their passwd entry 2 Check given a time, who was logged in at that time by looking at the out put of last 3 Given a list of active tcp services run out of inetd, report if there are services other than this list running out of inetd. 4 Print out the hardware ethernet address (check /var/log/messages)(dmesg) for each ethernet card installed. 5 Summarize the number of hours a user has used since X where X is the dat e/time provided as an option (last) 6 Given a program like mysql that should be running, check to see if it is working, then restart it if it is not. Report an error to root if it triggers a n action. 7 Calculate the %uptime this month by looking at the last log 8 Build a list of the number of email messages processed each hour by the system over the last day. (maillog) Make this plottable over time. .... The point is... 1) they learn a bit of perl 2) They have to talk to each other to get it done 3) The get useful bits out of the execise So... The question: Do you have any interesting ideas for perl programs that would ask people to do a simple (5-20 line program) system administration task? Question number two... Thru a trick of fate, I have a system that has perl 5.6.0 on it, but all the libraries are 5.005.0... So when I go to /usr/lib/perl5/site_perl I have two directories. Rather than going bit by bit and getting the parts I need, I wonder if there is a fast way to say: Go look at the 5.005 directory and get all the same packages for the 5.6 directory.... Any fast oneliner solutions? ----- John Sechrest . Helping people use CEO PEAK - . computers and the Internet Public Electronic . more effectively Access to Knowledge,Inc . 1600 SW Western ,suite 180 . Internet: sechrest@peak.org Corvallis Oregon 97333 . (541) 754-7325 . http://www.peak.org/~sechrest TIMTOWTDI From jkeroes at eli.net Wed Nov 1 18:03:22 2000 From: jkeroes at eli.net (Joshua Keroes) Date: Wed Aug 4 00:05:14 2004 Subject: Intro and two questions Message-ID: <20001101160322.F19425@surly.eli.net> ++ 01/11/00 15:28 -0800 - John Sechrest: > 1) In my Unix System admin class, [...] I need to come up with 30 > short perl scripts that I would use as an assignment. Off the top of my head: 1. You can play with df and du output. 2. You can muck about with processes, how about a program that displays processes, in a tree, with parents at the left? 3. reimplement lesser-versions of cron, locate, ls, find, & sort. Note: make sure your students don't cheat and use the implementations from the Perl Power Tools. > 2) Thru a trick of fate, I have a system that has perl 5.6.0 on it, > but all the libraries are 5.005.0... [How do I update 5.6.0 with the > 5.005 modules?] /path/to/perl5.005 -MCPAN -e autobundle `perldoc CPAN` for more info. /path/to/perldoc/in/5.005_dist perllocal +--------------------------------------------------------------------+ | Joshua Keroes, Sr. Software Engineer, Electric Lightwave, Inc | +--------------------------------------------------------------------+ "To be creative, it's not necessary that you're seeing a new thing, but that you're looking at the same things in a new way." Dieter Gruen, ultrananocrystalline diamond film inventor TIMTOWTDI From belman at subdimension.com Wed Nov 1 23:47:13 2000 From: belman at subdimension.com (Belgarion) Date: Wed Aug 4 00:05:14 2004 Subject: Intro and two questions References: <20001101160322.F19425@surly.eli.net> Message-ID: <003301c04490$59d22ea0$0200000a@potlnd1.or.home.com> mm.. good idea. i've attached a small utility I use on the solaris systems at work that don't have GNU grep, it's a recursive grep, which is very useful with the wonderful disorganization we call the development server. :) it could also use improvements, such as using file or such to test if it's text, following symlinks for linked items not within the scope, etc. hopefully this will help a bit. Erik Hollensbe ----- Original Message ----- From: "Joshua Keroes" To: Sent: Wednesday, November 01, 2000 4:03 PM Subject: Re: Intro and two questions > ++ 01/11/00 15:28 -0800 - John Sechrest: > > > 1) In my Unix System admin class, [...] I need to come up with 30 > > short perl scripts that I would use as an assignment. > > Off the top of my head: > 1. You can play with df and du output. > > 2. You can muck about with processes, how about a program that > displays processes, in a tree, with parents at the left? > > 3. reimplement lesser-versions of cron, locate, ls, find, & sort. > Note: make sure your students don't cheat and use the implementations > from the Perl Power Tools. > > > 2) Thru a trick of fate, I have a system that has perl 5.6.0 on it, > > but all the libraries are 5.005.0... [How do I update 5.6.0 with the > > 5.005 modules?] > > /path/to/perl5.005 -MCPAN -e autobundle > > `perldoc CPAN` for more info. > > /path/to/perldoc/in/5.005_dist perllocal > > +--------------------------------------------------------------------+ > | Joshua Keroes, Sr. Software Engineer, Electric Lightwave, Inc | > +--------------------------------------------------------------------+ > "To be creative, it's not necessary that you're seeing a new thing, > but that you're looking at the same things in a new way." > Dieter Gruen, ultrananocrystalline diamond film inventor > TIMTOWTDI > -------------- next part -------------- A non-text attachment was scrubbed... Name: rgrep Type: application/octet-stream Size: 961 bytes Desc: not available Url : http://mail.pm.org/archives/pdx-pm-list/attachments/20001101/d4df33bb/rgrep.obj From rtanner at cheshire.onlinemac.com Thu Nov 2 00:54:09 2000 From: rtanner at cheshire.onlinemac.com (Rob Tanner) Date: Wed Aug 4 00:05:14 2004 Subject: Time and date set? Message-ID: <3710000.973148049@cheshire.onlinemac.com> Hi, I'm on too many mailing lists for my own good and have gotten gobs of email lately. Since I have not yet seen any mail with a firm time and date for a social or a technical gathering, that makes me concerned. Have I accidentally deleted something that I failed to read --- oops! Could someone please update me with the status of those events. Thanks, Rob _ _ _ _ _ _ _ _ _ _ /\_\_\_\_\ /\_\ /\_\_\_\_\_\ /\/_/_/_/_/ /\/_/ \/_/_/_/_/_/ QUIDQUID LATINE DICTUM SIT, /\/_/__\/_/ __ /\/_/ /\/_/ PROFUNDUM VIDITUR /\/_/_/_/_/ /\_\ /\/_/ /\/_/ /\/_/ \/_/ /\/_/_/\/_/ /\/_/ (Whatever is said in Latin \/_/ \/_/ \/_/_/_/_/ \/_/ appears profound) Rob Tanner McMinnville, Oregon rtanner@cheshire.onlinemac.com TIMTOWTDI From daniel at chetlin.com Fri Nov 3 12:34:41 2000 From: daniel at chetlin.com (Daniel Chetlin) Date: Wed Aug 4 00:05:14 2004 Subject: Tuesday the 14th, 7pm Message-ID: <20001103103441.A17548@darkstar.chetlin.org> Folks, Thanks to Tom Keller's generosity and legwork, we'll be meeting at OHSU on Tuesday the 14th of November, starting at 7pm. We will have details of how to get there, where at OHSU, and what the agenda will be out to you soon -- just make sure to keep that evening marked on your calendars for now. Please contact Paul, Joshua, and/or myself if you have any questions or concerns. Thanks! -- s/TIMTOWTDI/-dlc/ && print while ; __DATA__ TIMTOWTDI From merlyn at stonehenge.com Sat Nov 4 06:51:55 2000 From: merlyn at stonehenge.com (Randal L. Schwartz) Date: Wed Aug 4 00:05:14 2004 Subject: Tuesday the 14th, 7pm In-Reply-To: Daniel Chetlin's message of "Fri, 3 Nov 2000 10:34:41 -0800" References: <20001103103441.A17548@darkstar.chetlin.org> Message-ID: >>>>> "Daniel" == Daniel Chetlin writes: Daniel> Folks, Daniel> Thanks to Tom Keller's generosity and legwork, we'll be meeting at OHSU Daniel> on Tuesday the 14th of November, starting at 7pm. Do you think you'll still be chatting onward at 8:30? I'm getting out of class at OGI around then, and could scurry to where y'all are. Or if you think you'll be retreating to a bar, I can do that instead. -- Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095 Perl/Unix/security consulting, Technical writing, Comedy, etc. etc. See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training! TIMTOWTDI From daniel at chetlin.com Sat Nov 11 20:44:17 2000 From: daniel at chetlin.com (Daniel Chetlin) Date: Wed Aug 4 00:05:14 2004 Subject: Technical meeting details Message-ID: <20001111184417.D924@darkstar.chetlin.org> As promised, we will be having a technical meeting this coming Tuesday (the 14th) at 7pm at OHSU. Here are the details: Who: Portland Perl Mongers What: November Technical Meeting When: Tuesday, November 14th, 2000 at 7:00pm Where: OHSU, BICC Library room BICC122 The planned agenda is as follows: 7pm-7:30 Administrivia, announcements, future plans, etc. 7:30-8:30 Parsing HTML 8:30-9pm Open discussion, questions, etc. 9pm-onward Adjourn to Hillsdale pub You can find directions to OHSU here: http://www.ohsu.edu/library/direct.shtml A map of the campus is here: http://www.ohsu.edu/library/ohsumap.html As above, we're in the main library (which is prominently highlighted on the map). The room is on the first floor, and it is room BICC122. If there are any questions about the agenda or the plans for the meeting, please don't hesitate to ask. Tom Keller is our gracious host for the meeting, and I'm hoping he'll follow up to this message if I've missed anything as far as the location information goes. I hope to see everyone there. Thanks! #!/usr/bin/perl -P #define TIMTOWTDI print "-dlc\n"; TIMTOWTDI From kellert at ohsu.edu Sun Nov 12 16:45:00 2000 From: kellert at ohsu.edu (Tom Keller) Date: Wed Aug 4 00:05:14 2004 Subject: Technical meeting details Message-ID: Greetings and welcome perlmongers, Just a note about parking: There are two free and convenient lots near the library. An outdoor lot is up the hill about 50 yards on the right. The other one is covered and you take a left, if your coming up the hill on Sam Jackson Park Rd, at the three way intersection right at the corner the library is on. The entrance is about 50 yards down the road, which I believe is called Veterans Hospital Way. They are available after 4:30 without an OHSU permit. See you Tuesday, Tom Keller Thomas J. Keller, Ph.D. Oregon Health Sciences University MMI Core Facility 503-494-2442 kellert@ohsu.edu http://www.ohsu.edu/core TIMTOWTDI From merlyn at stonehenge.com Tue Nov 14 14:57:48 2000 From: merlyn at stonehenge.com (Randal L. Schwartz) Date: Wed Aug 4 00:05:14 2004 Subject: Technical meeting details In-Reply-To: Daniel Chetlin's message of "Sat, 11 Nov 2000 18:44:17 -0800" References: <20001111184417.D924@darkstar.chetlin.org> Message-ID: >>>>> "Daniel" == Daniel Chetlin writes: Daniel> 9pm-onward Adjourn to Hillsdale pub This is the part I can do. :) See ya there. -- Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095 Perl/Unix/security consulting, Technical writing, Comedy, etc. etc. See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training! TIMTOWTDI From jkeroes at eli.net Wed Nov 15 16:29:19 2000 From: jkeroes at eli.net (Joshua Keroes) Date: Wed Aug 4 00:05:14 2004 Subject: Nov. Meeting Debriefing In-Reply-To: ; from kellert@ohsu.edu on Sun, Nov 12, 2000 at 02:45:00PM -0800 References: Message-ID: <20001115142918.J314@surly.eli.net> Topics were brought up at the meeting: 1. A contest-to-have-a-contest 2. HTML::Parser 3. An intro to CFG and Parse::RecDescent 4. An intro to HTML::Widget::Meter (ne HTML::Scale) 5. Dec 5 social meeting #------------------------------ # 1. Contests #------------------------------ Speaker: Joshua Keroes in lieu of Paul Blair pdx.pm is hosting not one but *two* contests to give you O'Reilly books. There's a copy of both _Perl_for_Systems_Administration_ and the Camel, 3rd e. Contest 1: "The contest-to-have-a-contest" Deadline: 3 weeks from now, Dec. 5 (next meeting!) The deal: We're lazy. You should think up neat contests for us. To enter: Send your contest ideas to the list or masque@pound.perl.org Prizes: o/' Fame. You're gonna live forever! o/' oh, and a book, too. Contest 2: "The contest of the contest-to-have-a-contest" The deal: First things first, get crackin' with contest 1! #------------------------------ # 2. HTML::Parser #------------------------------ Speaker: Daniel Chetlin Daniel did a spiffy job talking about the issues surrounding HTML parsing. HTML::Parser and HTML::TreeBuilder are [now] your friends. There will be a link to the paper[1] from the pdx.pm website Real Soon Now. :-) [1] http://chetlin.com/perl/html_parsing.html #------------------------------ # 3. An intro to CFG and Parse::RecDescent #------------------------------ Speaker: Daniel Chetlin A context-free grammar is a set of recursive rewriting rules (or productions) used to generate patterns of strings. Context-free grammars are often used to define the syntax of programming languages. [2] Parse::RecDescent incrementally generates top-down recursive-descent text parsers from simple yacc-like grammar specifications. [3] Damian's own tutorial, reprinted from The Perl Journal, entitled "the man(1) of descent" [4] is a terrific introduction to parsing. It includes the Abbot & Costello parser that reproduces their "Who's On First" routine. [2] http://www.cs.rochester.edu/u/nelson/courses/csc_173/grammars/ [3] from the Parse::RecDescent docs [4] http://search.cpan.org/doc/DCONWAY/Parse-RecDescent-1.78/tutorial/tutorial.html #------------------------------ # 4. An intro to HTML::Widget::Meter (n? HTML::Scale) #------------------------------ Speaker: Joshua Keroes + Prints HTML meter widgets. + Uses either 1-dot graphics or 2-d segmented graphics. + Also renders ascii-based meters in the ALT tag (e.g. [===>...]) + Display meters in different colors depending on value. + Much faster than GD::Graph. + ...and more! To beta-test a copy, email me. #------------------------------ # 5. Dec 5 social meeting #------------------------------ On Dec 5, the Portland Perl Mongers will have a social meeting. On the agenda: the announcement of the contest-to-have-a-contest winner. Want Free Stuff and Fame? GET YOUR IDEAS IN! +--------------------------------------------------------------------+ | Joshua Keroes, Sr. Software Engineer, Electric Lightwave, Inc | +--------------------------------------------------------------------+ "To be creative, it's not necessary that you're seeing a new thing, but that you're looking at the same things in a new way." Dieter Gruen, ultrananocrystalline diamond film inventor TIMTOWTDI From daniel at chetlin.com Thu Nov 16 04:27:15 2000 From: daniel at chetlin.com (Daniel Chetlin) Date: Wed Aug 4 00:05:14 2004 Subject: Nov. Meeting Debriefing In-Reply-To: <20001115142918.J314@surly.eli.net>; from jkeroes@eli.net on Wed, Nov 15, 2000 at 02:29:19PM -0800 References: <20001115142918.J314@surly.eli.net> Message-ID: <20001116022715.A999@darkstar.chetlin.org> On Wed, Nov 15, 2000 at 02:29:19PM -0800, Joshua Keroes wrote: > Speaker: Daniel Chetlin > > [1] http://chetlin.com/perl/html_parsing.html FYI, this link is not particularly complete at this point. I do intend to clean it up and break it into slides and paper, but I won't have time until the 28th at the earliest. If you're interested, under the same diretory is the beginnings of the paper part, although it's not too much different at this point. It's called html_mystuff.html. Thanks! -dlc (Can we get the auto-TIMTOWTDI thing turned off? I'm running out of clever things to do with it...) TIMTOWTDI From masque at pound.perl.org Thu Nov 16 16:07:51 2000 From: masque at pound.perl.org (Masque) Date: Wed Aug 4 00:05:14 2004 Subject: HTML::TreeBuilder, Tidy.exe Message-ID: <20001116160751.M20733@pound.perl.org> Majordomo doesn't seem to like subroutine declarations. :] I'm commenting out the line that caused majordomo to reject this and passing the rest on untouched. Paul. ----- Forwarded message from owner-pdx-pm-list@pm.org ----- Date: Thu, 16 Nov 2000 16:22:05 -0500 (EST) From: owner-pdx-pm-list@pm.org To: owner-pdx-pm-list@pm.org Subject: BOUNCE pdx-pm-list@pm.org: Admin request of type /^sub\b/i at line 8 Date: Thu, 16 Nov 2000 13:20:28 -0800 From: Jeff Zucker X-Mailer: Mozilla 4.7 [en] (Win98; U) MIME-Version: 1.0 To: Daniel Chetlin CC: pdx-pm-list@pm.org Subject: HTML::TreeBuilder, Tidy.exe References: <20001115142918.J314@surly.eli.net> <20001116022715.A999@darkstar.chetlin.org> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Daniel, thanks for a great talk the other night. I've been experimenting with TreeBuilder. Here's a snippet that will change the base href if one exists, or insert one if none exists. (Not that I ever use base hrefs, I did it up in response to the clpm user who requested it, but he was too rude to Randal for me to send it to him.) Is this how you'd do it? # sub insert_base { my($html_string,$new_URI) = @_; use HTML::TreeBuilder; my $tree = HTML::TreeBuilder->new; $tree->parse($html_string); $tree->eof; my $head = $tree->look_down('_tag','head'); my $base = $tree->look_down('_tag','base') || $head->new('base'); $base->{href} = $new_URI; $head->push_content($base); $html_string = $tree->as_HTML; $tree->delete; return($html_string); } Interestingly this works regardless of whether the original HTML includes a head tag or not, since TreeBuilder seems to insert one if none exists. Also, I wanted to mention a great resource one might want to use in conjunction with HTML::Parser or HTML::TreeBuilder -- the w3's tidy.exe program that does a good job of cleaning up bad HTML and producing XHTML and several other tasks. -- Jeff ----- End forwarded message ----- TIMTOWTDI From drulea at grassvalleygroup.com Mon Nov 27 20:02:01 2000 From: drulea at grassvalleygroup.com (drulea@grassvalleygroup.com) Date: Wed Aug 4 00:05:14 2004 Subject: Hash table Questions ... Message-ID: <0F84424E68F6D111A77B0008C7244C6504EB61AB@us-bv-m04.grassvalleygroup.com> Hi, Quick question here. I have a hash table with the following fields: $log_hash->{time} = $time; $log_hash->{email} = $email; $log_hash->{name} = $name; $log_hash->{update} = $update; $log_hash->{tag} = $tag; $log_hash->{log} = $log; $log_hash->{cr} = $CRnumber; I set searchable hash key value to the "$time" field in the following manner: "$LOG_HASH { $log_hash->{time} } = $log_hash;" The creation and print out of the hash table is OK. For print out, I use the following: foreach $elem ( keys %LOG_HASH ) # Print out the hash table { print OUT_HASH ("CR:$LOG_HASH{$elem}{cr} checked in to: "); print OUT_HASH ("$LOG_HASH{$elem}{tag} on: "); print OUT_HASH ("$LOG_HASH{$elem}{time} by: "); print OUT_HASH ("$LOG_HASH{$elem}{name}\n"); } However, I'd like to print out each element of the hash according to its CR value, not its time value. For example, I want all the hash values with CR values = 1 printed first, next those with CR = 2, etc. Several elements in the hash have identical CR values. Any ideas how to do this? thanks, Sherban ______________________________________________________ Sherban Drulea * sherban.drulea@grassvalleygroup.com TIMTOWTDI From merlyn at stonehenge.com Mon Nov 27 21:07:11 2000 From: merlyn at stonehenge.com (Randal L. Schwartz) Date: Wed Aug 4 00:05:14 2004 Subject: Hash table Questions ... In-Reply-To: drulea@grassvalleygroup.com's message of "Mon, 27 Nov 2000 18:02:01 -0800" References: <0F84424E68F6D111A77B0008C7244C6504EB61AB@us-bv-m04.grassvalleygroup.com> Message-ID: >>>>> "drulea" == drulea writes: drulea> Hi, drulea> Quick question here. I have a hash table with the following fields: drulea> $log_hash->{time} = $time; drulea> $log_hash->{email} = $email; drulea> $log_hash->{name} = $name; drulea> $log_hash->{update} = $update; drulea> $log_hash->{tag} = $tag; drulea> $log_hash->{log} = $log; drulea> $log_hash->{cr} = $CRnumber; drulea> I set searchable hash key value to the "$time" field in the following drulea> manner: "$LOG_HASH { $log_hash->{time} } = $log_hash;" drulea> The creation and print out of the hash table is OK. For print out, I use the drulea> following: drulea> foreach $elem ( keys %LOG_HASH ) # Print out the hash table drulea> { drulea> print OUT_HASH ("CR:$LOG_HASH{$elem}{cr} checked in to: "); drulea> print OUT_HASH ("$LOG_HASH{$elem}{tag} on: "); drulea> print OUT_HASH ("$LOG_HASH{$elem}{time} by: "); drulea> print OUT_HASH ("$LOG_HASH{$elem}{name}\n"); drulea> } drulea> However, I'd like to print out each element of the hash according to its CR drulea> value, not its time value. For example, I want all the hash values with CR drulea> values = 1 printed first, next those with CR = 2, etc. Several elements in drulea> the hash have identical CR values. Any ideas how to do this? if the possible CR values are known ahead of time: for my $cr (qw(1 2 3 5 10)) { for my $elem (sort grep { $cr == $LOG_HASH{$_}{cr} } keys %LOG_HASH) { # your stuff above } } If you don't know the possible cr values, and want them in numeric order: my %temp = map { $LOG_HASH{$_}{cr}, 1 } keys %LOG_HASH; for my $cr ( sort {$a <=> $b} keys %temp ) { ... # as above } There. Wasn't so hard, eh? -- Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095 Perl/Unix/security consulting, Technical writing, Comedy, etc. etc. See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training! TIMTOWTDI