News Flash!

LG Ready for FTP!!Yup, I finally got all of this together! :-)
Thanks to all for their patience. I'm sorry that this took so long to organize. I've put the entire set of file together in a tar-gzip'ed format together with a short README. These pages are intended for free usage for any personal, educational, or non-commercial purpose. If that's you, then enjoy! Anyone wanting to use these for commercial purposes just needs to drop me a note and let me know what you'd like to use them for. See the copying.html document above.
My sincerest thanks to the folks at RedHat Commercial Linux and The Linux Journal/SSC who have graciously offered the use of their ftp services! You'll find ftp'able copies of the Linux Gazette pages at the following URL's:
Also, if anyone's interested in mirroring the Linux Gazette pages, there's a very short README included for that. Basically, I'd be delighted to have these pages mirrored and made as accessible as possible. All I ask is that you let me know that you're doing this, send me the URL for your pages, and an email address for the person taking care of them. I'll put together a page of mirror sites so that folks can find a site closest to them. Check the mirror.README for more details.
Linux Gazette now available on
Pacific HiTech's Linux Archive Monthly CD-ROM!The Linux Gazette files are now available in their entirety on Pacific HiTech's monthly "Linux Archive Monthly CD-ROM".
For those of you who haven't heard of this, it's a monthly CD-ROM put out by Pacific HiTech that contains a boatload of the latest Linux related programs and files culled from the Internet. For example, the January edition included:
If you're interested in this kind of offering, give PHT a call at:
+1-800-765-8369
or, +1-801-261-1024
FAX: +1-801-261-0310
So... does this mean that the 'Gazette is going commercial?
Nope.
But, let me quickly add that, as you've all probably noticed, I believe that a strong commercial base is beneficial to the Linux community. I heartily support and encourage the efforts of such folks as Pacific HiTech, RedHat Commercial Linux, the Linux Journal and SSC, and O'Reilly publishers. These enterprises provide valuable services and offerings at VERY competitive rates, and many of them contribute a portion of their profits back into the non-commercial Linux development efforts.
Ok, sermon over. :-)
Have a look and enjoy!
Yup, that's right... I've decided for sanity's sake, to do a bit of renaming here. As of the beginning of this year, the Linux Gazette will be put out by issue, rather than by month. The reason for this is pretty obvious: I'm back in school and things look busy this semester. I honestly can't commit to putting these pages out on a monthly basis.
I'm very much indebted to all those who've written and sent material to be included in the 'Gazette. It helps a LOT and I want to thank these folks once again. However, it still takes a good deal of time to update pages, edit the material sent, and coordinate all that goes into each issue.
So...
I'll make every effort to get something out each month but I definitely can't promise that this will happen. Thanks again for your patience and understanding! Also, you'll notice that I've changed the 'Gazette's main "Table of Contents" page a bit. The father of a child with ADDH (Attention Deficit Disorder / Hyperactivity) wrote and mentioned that this came across as demeaning to those with this condition. I had ADDH as a child and admit that I occasionally tease about this, having struggled with it myself. I want to publically apologize to all for this. I admit that it was inappropriate and in poor taste. My fundamental intention with the Linux Gazette is to provide a means of communicating ideas in a way that makes using Linux more fun, and NOT to insult or demean anyone. So, once again I appreciate your patience and understanding, AND I appreciate your letting me know when I get out of line...
Having said that, let me finish by saying that I hope you really enjoy this month's (oops...! er, this current issue :-) of the 'Gazette. A lot of folks have written in and there's a lot of great reading here! I must admit that I've learned a good deal from all the things that people have written and I hope that you do too. At the risk of sounding like a broken record, let me encourage you to drop the author(s) of these articles a note and let them know what you think! As I mentioned before, the 'Gazette is intended to encourage the free exchange of ideas and so I welcome any comments, suggestions, improvements, or followups that you feel might help.
Thanks for dropping in!
Enjoy!
--John
Salutations and the
MailBagWell, howdy! :-)
Happy 1996! I had a nice, albeit event-filled, Christmas break and am now glad to be back in school and starting a new semester. I wanted, once again, to say a very heart-felt "thanks!" to everyone that took the time to write. I know that y'all are pretty busy and I appreciate the time that many of you took out of busy schedules to write.
I've tried to include a number of interesting and informative letters below. Since my mailbox, at last count, has ballooned to 700+ messages over the past couple months, I can't squeeze all your messages in here :-) although I've tried hard to drop everyone at least a short note of thanks.
Let me encourage you to read these things!
Seriously.
There are a LOT of quick tips and excellent ideas here. I haven't set up a "mailto:" for each person that wrote, but if you find something useful then by all means drop that person a note and let them know about it. Most of all...
Enjoy!
John
Kevin Pearson
Date: Sat, 06 Jan 1996 18:54:10 CST
From: Kevin Pearson <adonis2@localnet.com>
Subject: African American Pioneer Link
On Jan. 1st, was the release of the two newest Black Educational Video. The name of the program is called: "A Salute to Our Black Pioneers" - Profife: Dr. Charles R. Drew, Credited with saving thousands of lives daily due to his invention of plasma * and * Profile: Frederick M. Jones, invented the first refrigeration unit for long haul trucks.
We at Adonis are creating our home page at this time. We are let everyone one know about our company, which is producing Black Educational video programs. We would like to use your like address so that others can link up to your services. Also we would like our infomation be part of your information home page. If you can get back to me and see what we can do. Thank you. Kevin Pearson, President Adonis Productions
P.S. Our Home Page will be online on Martin Luther Kings Birthday
-- ÐÏà¡
Jeremy Laidman
Date: Sat, 23 Dec 1995 22:56:45 CST
From: Jeremy Laidman <JPLaidman@ACSLink.net.au>
Subject: Another user for setterm
John
I hope you find this useful enough to include in the Gazette.
This is something I use in my Unix profiles to guide my eyes to previous command lines. By highlighting the prompt I can quickly tell where output from a command ends and my keystrokes begin.
For a bash shell, in my .profile I have:
export PS1="\[`setterm -foreground green`\]\[`setterm
-bold on`\]\h:\w\\$\[`setterm -default`\] "
My prompt appears as:
hostname:/current/dir$
with the whole prompt a bright green (looks OK on a black screen). If I'm logged in as root, the $ becomes #. For more info on bash-isms, check out the bash man page. I use variants of this technique under other shells and on other versions of UNIX (see example below).
Some explanation for the curious:
The brackets \[ and \] are required to inform bash of escape sequences (as generated by setterm. Otherwise, command-lines that extend to multiple lines will not wrap quite right after a bit of editing.
Note the extra backslash escaping the $. It won't show as # for root without it. I could have enclosed the whole string in single quotes, and not had to use the extra bashslash, but this delays the execution of the 'setterm' commands to when the prompt is displayed (can be useful) rather than when it is set.
For systems without setterm, but with terminfo capabilities, use tput, replacing `setterm -foreground green` with `tput bold`, and `setterm -default` with `tput sgr0`.
For non-bash shells, the brackets \[ and \] for escape-sequences are not needed. For a non-Linux korn-shell (ksh) account I have, I use:
export PS1="`tput bold``hostname`:\$PWD$`tput sgr0` "
This does everything except show # for root.
Congratulations on a fab publication. Most helpful. I like the quick tips idea. So much that makes more Linux useful for me has been shown to me by fellow Linuxers who just discovering things accidentally. Ideal snippets for such a publication.
Cheers
--------------------------------------------------------------------- Jeremy Laidman, Internet/Netware Contractor JPLaidman@ACSLink.net.au Canberra, Australian Capital Territory Phone: (61 6) 241 7969 (ah)
Simon Arthur
Date: Sat, 02 Dec 1995 00:07:33 CST
From: Chroma <chroma@mindspring.com>
Subject: FvwmWinList modification
I thought you might be interested in a cool modification I made to FvwmWinList.
I made a simple change to FvwmWinList for my own use. To make it more like the Windows 95 taskbar, I modified ButtonArray.c
In function DoButton, I changed the line
XDrawString(dpy,win,graph,x+newx,y+3+ButtonFont->ascent,ptr->title,strlen(ptr->title)); to read XDrawString(dpy,win,graph,x+2,y+3+ButtonFont->ascent,ptr->title,strlen(ptr->title));
This removes the centering. I find this works much better if you have FvwmWinList on the left side of the screen as it lets you see the name of the window even if FvwmWinList is partially covered.
Here's what I have in my .fvwmrc:
*FvwmWinListBack #908090
*FvwmWinListFore Black
*FvwmWinListFont -adobe-helvetica-bold-r-*-*-10-*-*-*-*-*-*-*
*FvwmWinListAction Click1 Iconify -1,Focus
*FvwmWinListAction Click2 Iconify
*FvwmWinListAction Click3 Module "FvwmIdent" FvwmIdent
*FvwmWinListUseSkipList
*FvwmWinListGeometry +3-48
Function "InitFunction"
Module "I" FvwmWinList
---------------------------------------------------------------------------- Simon Arthur chroma@mindspring.com http://www.mindspring.com/~chroma/home.html hypemaster@hyper-g.com http://www.mindspring.com/~chroma/hgc/hgc-home.html
Tim Newsome
Date: Fri, 29 Dec 1995 09:38:00 CST
From: Tim Newsome <drz@cybercomm.net>
Subject: RE: Linux Gazette
On Thu, 28 Dec 1995, John M. Fisk wrote:
> >Dunno if the following is in one of the issues I haven't read yet, but here > >goes. To have a background picture for X put the following at the end of your > >xinitrc: > >xv +root -rmode 5 background.gif -quit & > >I can't remember what the -rmode 5 means. Probably centered in the screen. > >Neat thing, anyway. > Thanks for the tip! I've actually run across this and played with > wallpapering the root window using xv -- very cool! Definitely ought > to mention this.As for tips, I wrote this shell-script a while ago:
#!/bin/sh TMP=/tmp/$$_ MAXLENGTH=1000 for logfile; do tail -$MAXLENGTH $logfile > $TMP # Don't use mv to keep the permissions the same. cat $TMP > $logfile rm -f $TMP done
It simple goes through all the logfiles you specify on the commandline and trims them to a 1000 lines. (Nothing really useful, just another 2c one. I actually like the 2c tips a lot.)
> and your taking the time to write. Hope you had a merry Christmas -- > have a Happy New Year!
Same to you!
Tim
Tim Newsome. drz@cybercomm.net. http://www.cybercomm.net/~drz/. HotJava rules. Pretending to work is almost as hard as the real thing. Linux > Windows. question=(be||!be); answer=42; hack!=crack; IRC=fun; cogite ergo rideo. 1+1=3 for large values of 1. CMU here I come! NO CARRIER
Kurt M. Hockenbury
Date: Fri, 08 Dec 1995 21:55:01 CST
From: Kurt M. Hockenbury <kmh@linux.stevens-tech.edu>
Subject: Linux Gazette syslog tip
In the November issue, you meantion syslog.conf. Here's a quick tip: I have a line at the end of my /etc/syslog.conf which reads
# Throw everything on tty8 as well *.* /dev/tty8
This way, I also get a copy of *every* syslog entry on Virtual Console 8 (which I don't otherwise use - no getty running on it, etc). You can use any unused console you want.
It's handier than having to tail the various logging files, and cheaper on memory than running a "tail -f" under some shell, and uses no extra disk space.
When my hard disk makes swapping noises, I can look on VC8 and see the log of the incoming connection or mail. When I'm configuring or debugging daemons, it's easy to check what they're logging. :)
Hopefully, other may find this a useful suggestion.
-Kurt
--
[Place]
snail://USA/07030/NJ/Hoboken/PO Box 5136/Kurt M. Hockenbury [Stamp]
[Here.]
Lee Olds
Date: Fri, 12 Jan 1996 10:40:58 CST
From: Lee Olds <leeo@slmd.com>
Subject: Minor nit in oct LG article on TRAP
Hi. Linux Gazette looks real good!
I have a small correction for the act article on TRAP. You said:
>So, what are the signals that can be trapped? The most common ones, >I'm told are the following: > > 0 - program exit > 1 - hang-up > 2 - user interrupt (ctrl-c) > 9 - kill signal from another process
Those are probably the most commonly sent signals. All except for signal 9 could be the most commonly trapped signals as well. But signal 9 is special and can never be caught, so the shell has no way to trap it.
-- Lee Olds olds@eskimo.com
Brian Matheson
Date: Thu, 21 Dec 1995 22:14:44 CST
From: Brian Matheson <bmath@sirius.com>
Subject: Stuff
Just wanted to drop you a line and say hey again and let you know that I've become another of your avid fans! Since you mentioned that you'd be doing a little work on the ole' toy box, I thought I'd point out something in SunSite's Toys directory that's just too groovey to be overlooked: Xfishtank.
It turns your root window into a fish tank and runs beautifully in the background while I'm doing other stuff on my poor-boy's 486/33 with 8 megs of RAM, and it doesn't even complain about netscape eating up the color palette.
Another thing that I'd forgotten about but came across while trying to set up a ppp connection with our system at work is a little technique for trimming down those pesky syslogs. I don't know about you, but I usually forget about them until something doesn't work and then realize that they've grown to outrageous proportions in my absent-mindedness. So I came up with a one-liner to grep out the lines for a certain date:
grep "`date | cut -b5-10`" /var/adm/syslog | cut -b8-
Just make an alias for it and you're all set. Works great on /var/adm/messages too!
Many thanks for sharing the great work you do with the rest of us, the countless hours you spend aren't going unappreciated!
Happy Hollidays!
Brian
bmath@sirius.com
Liang Ng
Date: Fri, 12 Jan 1996 22:00:14 CST
From: Liang Ng <L.S.Ng@ecs.soton.ac.uk>
Subject: Re: Update of xterm title bar. Solution.
John M. Fisk writes:
> Excellent! I've saved your message and will _definitely_ include it with > the next edition of the LG! Glad to see that you were able to get this > worked out :-) Also, thanks SO much for taking the time to write and > offer this suggestion.
Thanks John. I am very pleased to hear that.
BTW, here is a suggestion about xlock.
I am not using xdm. I use startx to start the X Window. When I used xlock on the X Window, I found that it was actually possible to switch to the Virtual Console (VC) from which I started X Window. i.e. xlock is broken! I, in fact anyone, was able to suspend startx by pressing ctrl-z at the VC, then kill xlock.
Solution to this: log myself out from the virtual console, before I leave my desk.
This solution obviously works. But it is a nuisance to see the closing down message at the VC when X Window is shut down later. So I created a Bash function startx() which redirect the stderr to /dev/null:
startx()
{
/usr/X11/bin/startx $* 2> /dev/null
}
Note that the full path of the actual startx must be used or else Bash will interpret it as recursive function. Note also that alias in Bash does not carry arguments, hence I have to use function instead.
Of course, if you really want, you could do:
startx()
{
/usr/X11/bin/startx $* 2> /dev/null &
clear
logout
}
Which logs you out from the VC as soon as X Window is started.
Cheers
Liang S Ng
Tim Wallace
Date: Sat, 23 Dec 1995 08:43:30 CST
From: Tim Wallace <root@web.tenn.com>
Subject: RE: Stuff
John,
Here's the crontab that comes with RH2.0 and RH2.1.
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
# Run any at jobs every minute
* * * * * root /usr/sbin/atrun
# Make the whatis databases
21 03 * * 1 root /usr/sbin/makewhatis /usr/man /usr/X11R6/man
# Make the find.codes database
47 02 * * * root /usr/bin/updatedb --prunepaths='/tmp /proc /mnt /var/tmp
/dev' 2> /dev/null
# Trim wtmp
45 02 * * * root find /var/log/wtmp -size +32k -exec cp /dev/null {} \;
# Remove /var/tmp files not accessed in 10 days
43 02 * * * root find /var/tmp/* -atime +3 -exec rm -f {} \; 2> /dev/null
# Remove /tmp files not accessed in 10 days
# I commented out this line because I tend to "store" stuff in /tmp
# 41 02 * * * root find /tmp/* -atime +10 -exec rm -f {} \; 2> /dev/null
# Remove formatted man pages not accessed in 10 days
39 02 * * * root find /var/catman/cat?/* -atime +10 -exec rm -f {} \; 2>
/dev/null
# Remove and TeX fonts not used in 10 days
35 02 * * * root find /var/lib/texmf/* -type f -atime +10 -exec rm -f {}
\; 2> /dev/null
# Trim log files
34 02 * * * root find /var/log/maillog -size +16k -exec /bin/mail -s "{}"
root < /var/log/maillog \; -exec cp /dev/null {} \;
33 02 * * * root find /var/log/messages -size +32k -exec /bin/mail -s
"{}" root < /var/log/messages \; -exec cp /dev/null {} \;
32 02 * * * root find /var/log/secure -size +16k -exec /bin/mail -s "{}"
root < /var/log/secure \; -exec cp /dev/null {} \;
31 02 * * * root find /var/log/spooler -size +16k -exec /bin/mail -s "{}"
root < /var/log/spooler \; -exec cp /dev/null {} \;
30 02 * * * root find /var/log/cron -size +16k -exec /bin/mail -s "{}"
root < /var/log/cron \; -exec cp /dev/null {} \;
The wordwrapping should be un-done of course.
Tim
Tim Newsome
Date: Wed, 27 Dec 1995 17:53:03 CST
From: Tim Newsome <drz@cybercomm.net>
Subject: Linux Gazette
Hi,
You're probably getting millions of these, but I just wanted to say the Linux Gazette absolutely positively completely rules. Just discovered it and reading from all of them. You taught me a bunch of stuff about fvwm there. :-) Dunno if the following is in one of the issues I haven't read yet, but here goes. To have a background picture for X put the following at the end of your .xinitrc:
xv +root -rmode 5 background.gif -quit &
I can't remember what the -rmode 5 means. Probably centered in the screen. Neat thing, anyway.
Keep it up!
Tim
Tim Newsome. drz@cybercomm.net. http://www.cybercomm.net/~drz/. HotJava rules. Pretending to work is almost as hard as the real thing. Linux > Windows. question=(be||!be); answer=42; hack!=crack; IRC=fun; cogite ergo rideo. 1+1=3 for large values of 1. CMU here I come! NO CARRIER
Matt Welland
Date: Tue, 12 Dec 1995 15:49:22 CST
From: Matt Welland >welland@node71.tmp.medtronic.COM>
Subject: System configuration - beyound RCS
John,
I've been using RCS for some time to control my system files but I found I needed something more. I wanted to be able to check out an entire machine configuration so I installed cvs. I checked in all the pertinent files in /etc, /usr/lib/uucp, /usr/lib/news and so forth and gave them a module name. Now I can check out any of several machine configurations each with its own hostname and setup. CVS took a little learning but if you know and understand RCS it is pretty easy. Follow the instructions that come with CVS and keep a system backup until you are confident everything is rock solid and predictable.
-Matt
--
,------------------------------------------------------------.
| Matt Welland | Medtronic/Micro-Rel |
| Design Engineer | IC CAE group |
`--------------welland@tmp.medtronic.com---------------------'
Ed Petron
Date: Sat, 30 Dec 1995 11:39:04 -0500
From: Ed Petron <epetron@leba.net>
Subject: Linux
John, I've been looking at your Linux home page and it's really great! I've got a home page devoted to technical and network computing at http://www.leba.net/~epetron. It's always great to "meet" another Linux afficianado. Drop me line if you get a chance. I'll be looking forward to hearing from you.
Ed Petron
Morpheus
Date: Fri, 15 Dec 1995 23:40:26 CST
From: Morpheus <morpheus@markwoon.student.Princeton.EDU>
Subject: RE: Comments and xterm titlebars
On Fri, 15 Dec 1995, John M. Fisk wrote:
> Hmmm... sounds interesting. Are these shell scripts or binaries? I've > seen the pushd and popd programs mentioned before but have never run > across them. Do you recall where you picked these up?
Whoops. I just checked, and pushd and popd are shell built-ins. See how much cooler tcsh is? ;^) (Just joking, don't want to start a my-shell-is- better-than-your-shell flamewar here.)
Another neat tcsh built-in is "where" which searches your path for a file name you provide (eg. "where popd" in which case it returns "popd" is a shell built-in)
And on killing proceses, check out killall, it should come with the standard distribution. It'll kill all proceses with the name you provide (the slay alias I sent you probably only works on the first, I've never tested this). Very handy with runaway processes that spawn child processes faster than rabbits in heat.
> I'm not sure... I've not enough of a guru to know how you'd enter a > control or escape character from the keyboard. I simply used a text > editor to do this and then messed around with it after creating a > small shell program.
BTW, the emacs sequence for inserting control sequences is Control-q, followed by the desired control sequence. Adding this to the Nov. issue of LG will probably help out emacs users, fitting in well with your description on how to do so with vi... ;)
> Have a Merry Christmas and Happy New Year.
You too!
~Morpheus~~~~morpheus@vanaheim.princeton.edu~~~~~~~~E Pluribus Linux~~~~~
Introduction to Tcl/Tk
by Jesper PedersenBy Jesper Pedersen <blackie@imada.ou.dk>
In this article I'll try to describe what Tcl/Tk is, its strong points, and its draw backs. Furthermore, I'll give some examples of using tcl/tk and provide references to materials about Tcl/Tk. Finally, I'll try to help you avoid a few of the common pitfalls with using Tcl/Tk.
Despite this initial intention, Tcl has come to be used heavily as a programming language in itself, and it has turned out to be a very good language for quick and dirty programming. It's much more difficult to use it as a language for larger programs. (This requires much more dicipline and structure)
set var 10, this will set var to the value
10set var, this will read the content of var, ie.
return the value 10.$var, this will expand to the value of
varTo try this, use the command puts, which will write it's argument to standard out (stdout), try this:
set var 10 puts [set var] puts $varThis will write 10 twice to standard out. Well what were those brackets for? In Tcl, commands inside brackets are expanded, so the evaluation strategy for the command
puts [set var], is as follows:
set var which evaluates to
10
puts 10, which write 10 to standard
out.
set var 10
puts "var is $var"
puts {the name of the variable is $var}
Executing the second line prints var is 10, while the
third line prints the name of the variable is $var. Here is how
it works: if the outermost delimiter is a brace,
then everything inside is seen literally, whereas if the outermost
delimiter is a quotion mark, then every thing inside is expanded.
puts {every thing "is [$litterals]"}
puts "here \[things\] shall be \"escaped\" !\$"
This will print every thing "is [$litterals]" and
here [things] shall be "escaped" !$
Different commands require different numbers of parameters, while
braces and quotes are used to group things which are meant as
one parameter! I.e if you want to set
var to "hello world", write set var "hello
world" or set var {hello world}. In this
example there is no difference between using braces or quotes.
However, if you want to set var to the content of var1 plus a
string you would write set var "var1 is $var1". If
you had written set var {var1 is $var1}
var1 wouldn't have been expanded, since it is protected
by the braces.
label .label -text "Hello World" button .button -text "Quit" -command exit pack .label .buttonTry it!
Well what happens? Three Tk functions are called: label, button and pack. The first one creates a label with the text "Hello World". The next one create a button, gives it the title "Quit", and associates it with the Tcl command "exit". The third line maps them in a window, so you can see them on the screen.
Ok let's try to understand what this is all about. To do that, please invoke the manual page for the label command. In this you can see that the label command has several options available. The idea is that you can configure the label in several ways. All the options have a default value You can, for example, configure the color of the text, the font, the text itself (as we did in the example), and so forth. Some of the options are specific for the label command, while others are general for several different Tk functions. The specific ones are listed and described in the manual page for the label command, while the more general ones are listed and described in the manual page called options.
The last thing to understand about the label command is its first argument, which is .label in our example above. This argument is the name of the label. The name is used, when you want to place the label on the screen, or later on when you want to configure some of its properties (eg. change the text of the label).
To fully understand this, we have to learn about the packing strategy of Tk.
To see what you can do with this command, see the manual page for pack. Here are a few examples which will give you an idea of what can be done. Exchange the pack line above with each of these lines, and rerun the example:
pack .label .button -side left
pack .label .button -pady 20
pack .label -pady 100 -padx 100 -anchor cpack .button -anchor e
### creating two frames for the different part of the text
frame .top
frame .middle
frame .bottom
pack .top .middle .bottom
### creating the entry with a label
label .top.label -text "Please type your name:"
entry .top.entry -textvariable name
pack .top.label .top.entry -side left -padx 5
### creating the check button
checkbutton .middle.but -text "I'm good at tcl!" \
-variable good
pack .middle.but
### creating the OK and CANCEL button
button .bottom.ok -text OK -command okCmd
button .bottom.cancel -text Cancel -command exit
pack .bottom.ok .bottom.cancel -side left
### creating the command to call when the OK
### button is pressed
proc okCmd {} {
global name good
puts "Hi $name"
if {$good} {
puts "You are good at tcl...great"
} else {
puts "You should really learn Tcl, before you play with TK"
}
}
In Tk, variables for entries, check buttons, radio buttons and other widgets which require user interaction, are saved in global variables. So when I create an entry with - textvariable name then the contents of this entry is reflected in the global variable name.
In the example above, I create a procedure which is called when the OK button is pressed. The procedure definition is, in fact, very simple and very much like in C. See the manual page for proc for a full description on how it works.
In this procedure I declare the variables name and good for global variables with the global command. (Again, if you want to know more see the manual page!) In the example above you can see an example of a widget which is packed inside another. There is nothing fancy about it. The frame widget is just a container which help you pack the things in a smart way on your screen. When I have created the frame .top I can pack things inside it, and I have to name its sub widget with the .top name prefixed.
The rest of the example should be clear, but if there is something you don't understand, please see the manual page, all the information is located in them!
First of all, don't start creating large applications in Tcl right away. There are several reasons for this, but the the most important one is that Tcl is a very bad language for incremental programming, when you want structure too... The best advice I can give you is to try tcl/tk out, see other applications and read about Tcl and Tk's possibility. When you've done all these things you'll understand what it can do, and then you start to design your applications before you program. The worst thing you can do in Tcl is to program a basic version of your interface, and then start to patch it until it is what you really want! I know that...I've tried it myself :-(
When you have a better understanding of Tcl, you'll find that it lacks composed types: the only types you have in Tcl are strings, list of strings, and associative arrays (also known as maps in other languages). The associative arrays can not contain arrays them self! This is a significant problem if you use Tcl as a programming language for larger programs. One solution for this problem is to create virtual modules. The idea is that you name your variables with a module prefix. If you,for example, have some part of your program which takes care of help, you may see this as a module, and variables used by this part of the program are all name something like help`variable. This strategy makes it a bit harder to expand variables since the pling character is a word separator in variables. This means that if you write $a`b, Tcl will try to expand a variable called $a. So, to expand this variable you would write ${a`b} or [set a`b].
You can view these using the command:
man ./filename.n
or, you can convert these to plain ASCII text files which can be viewed or printed using a BASH shell script such as:
#!/bin/sh
#
for SUFFIX in 1 3 n
do
find -name "*.$SUFFIX" -print |
while read FILE
do
echo -n "converting $FILE to ${FILE%%.$SUFFIX}.txt ..."
groff -Tascii -mandoc $FILE 2>/dev/null | col -b > ${FILE%%.$SUFFIX}.txt
echo "done."
done
done
echo
echo "Finished converting files."
echo
If you wish to convert these to PostScript format for printing, you can use a similar BASH script:
#!/bin/sh
#
for SUFFIX in 1 3 n
do
find -name "*.$SUFFIX" -print |
while read FILE
do
echo -n "converting $FILE to ${FILE%%.$SUFFIX}.ps ..."
groff -Tps -mandoc $FILE > ${FILE%%.$SUFFIX}.ps 2>/dev/null
echo "done."
done
done
echo
echo "Finished converting files."
echo
Well first of all, the USENET group for Tcl/Tk is comp.lang.tcl. The traffic is heavy, but don't fear: it's worth it..!
[I want to publically thank Jesper for his very gracious offer to write this article which was no small feat. Please do not hesitate to drop him a note and send your comments, suggestions, and most of all a very hearty thanks. Also, if you're interested in joining the Dotfile Generator development team, let Jesper know -- he'll be glad to let you know how you can join this effort! Drop him a note at:
Jesper Pedersen <blackie@imada.ou.dk>
Thanks! --John]
Still Yet another
HACK scriptWhile doing a bit of Christmas Break reading over December I ran across a quote that is attributed to Larry Wall, author of the PERL scripting language. He's purported to have said something to the effect:
"There's always another way to do things..."
Whether apocryphal or not, there's a good deal of truth to this little saw and the contributions to an improved HACK script are ample evidence of this. For those of you tuning in late... a couple months ago I made a suggestion that, when modifying all those tricky little configuration files you've got lying around your system, you should use a shell script that would ensure that there's a backup copy of the config file made before you get your grubby little mitts all over it (and whose mom wouldn't agree with this... :-).
The shell script that I offered was the merest skeleton of a suggestion and pretty minimalistic. The November edition of the LG had a couple very significant improvedments to this. Here's a self-avowed "Yet another HACK script" that offers another robust improvement. It's authored by Dean Carpenter who graciously gave permission for this to be printed.
Please drop him a note of thanks! You should also read his opening comments in this file -- RTFM :-)
enjoy!
From: Dean Carpenter <deano@areyes.com>
Subject: Re: Yet another HACK script
Here's hack with the owner/group changes in it.
Now it will maintain correct user and groups perms.
#!/bin/bash
#
# hack file|dir
#
# Edit a file, keeping an original copy in $DIST and a linked
# copy in $CONFIG. Uses RCS to log all changes.
#
# If hacking a dir, simply make a symlink to the dir in $TREE
# in the proper full-path dir.
#
# Creates the following files :
#
# A copy of the original file in /configs/original
# A symlink to the original file in /configs/links
# An RCS control file in /configs/RCS
# A full-path symlink to the original file in /configs/tree
#
# The full-path is to keep the directory structure available for
# backing up with tar -h to dump actual files, not just
# the symlinks.
#
# That is, backing up with the command
#
# (cd /configs/tree ; tar -cvhf configs.tar . )
#
# will create a tar file with all hack'd files in their correct
# original locations with relative paths.
#
# Dean Carpenter
# deano@areyes.com
# Location of directories
# CONFIG Storage dir for links
# DIST Original files go here
# RCS RCS control files go here
# TREE Full path copies of files
#
CONFIG='/configs/links'
DIST='/configs/original'
RCS='/configs/RCS'
TREE='/configs/tree'
# Default to not being a directory
DIR='no'
EDITOR='vi'
CURR_DIR=`pwd`
#
# Make sure only root can hack
#
if [ "$LOGNAME" != "root" ]
then
echo "hack: user not logged in as root"
exit 1
fi
#
# Need a filename to hack
#
if [ "$1" = "" ]
then
echo "hack: filename missing"
exit 2
fi
#
# If it's a directory we need to link to $TREE
#
if [ -d $1 ]
then
echo "hack: " $1 " is a directory"
DIR='yes'
fi
#
# Must be an existing file or a directory
#
if [ ! -f $1 ] && [ ! -d $1 ]
then
echo "hack: bad filename"
exit 3
fi
#
# Must be a real file, not a symlink
#
if [ -L $1 ]
then
echo "hack: Must be a real file, not a symlink"
exit 4
fi
#
# Make sure the repository exists
#
if [ ! -d $CONFIG ]
then
echo "hack: Creating " $CONFIG
mkdir --parents $CONFIG
chmod 711 $CONFIG
fi
#
# And the dir to hold the original files
#
if [ ! -d $DIST ]
then
echo "hack: Creating " $DIST
mkdir --parents $DIST
chmod 711 $DIST
fi
#
# And a place for the RCS files
#
if [ ! -d $RCS ]
then
echo "hack: Creating " $RCS
mkdir --parents $RCS
chmod 711 $RCS
fi
#
# And finally a place for the full pathname files
#
if [ ! -d $TREE ]
then
echo "hack: Creating " $TREE
mkdir --parents $TREE
chmod 711 $TREE
fi
#
# Get the name and dir of the file
#
BASENAME=`basename $1`
DIRNAME=`dirname $1`
#
# If the DIRNAME is just here, then we want the full path
#
if [ "$DIRNAME" = "." ]
then
DIRNAME=$CURR_DIR
fi
#
# If it's only a partial dir in the path to the file, we need
# to get the full path to the file.
#
if [ "$DIRNAME" != "$CURR_DIR" ]
then
if [ -f "$CURR_DIR"/"$DIRNAME"/"$BASENAME" ]
then
DIRNAME=$CURR_DIR/$DIRNAME
fi
fi
#
# If we're off the root, we don't want a doubled up //
#
if [ "$DIRNAME" = "/" ]
then
FILE=$DIRNAME$BASENAME
else
FILE=$DIRNAME/$BASENAME
fi
#
# Get the original owner and group of the file to hack
#
OWNER=`ls -l $1 | awk ' { print $3 } ' `
GROUP=`ls -l $1 | awk ' { print $4 } ' `
#
# If it's a dir, make a link in $TREE then exit
#
if [ "$DIR" = "yes" ]
then
if [ ! -L $TREE$FILE ]
then
mkdir --parents $TREE/$DIRNAME
ln -s "$FILE" "$TREE$FILE"
echo "hack: Linking " $FILE "to" $TREE$FILE
chown $OWNER.$GROUP $TREE$FILE
else
echo "hack: " $TREE$FILE " already exists"
fi
exit 0
fi
#
# Copy the original to save it before hacking it.
# Make sure it's owned/grouped as the original is.
#
if [ ! -f $DIST/$BASENAME.dist ]
then
cp $1 $DIST/$BASENAME.dist
echo "hack: creating file " $DIST/$BASENAME".dist"
chown $OWNER.$GROUP $DIST/$BASENAME.dist
elif [ -f $DIST/$BASENAME.dist ]
then
echo "hack: " $DIST/$BASENAME".dist already exists"
else
echo "hack: fatal error in " $DIST/$BASENAME".dist"
exit 5
fi
#
# Create the symlink and update owner/group.
#
if [ -f $FILE ]
then
if [ ! -L $CONFIG/$BASENAME ]
then
ln -s "$FILE" "$CONFIG/$BASENAME"
echo "hack: linking " $FILE "to " $CONFIG/$BASENAME
chown $OWNER.$GROUP $CONFIG/$BASENAME
fi
if [ ! -L $TREE$FILE ]
then
mkdir --parents $TREE/$DIRNAME
ln -s "$FILE" "$TREE$FILE"
echo "hack: linking " $FILE " to " $TREE$FILE
chown $OWNER.$GROUP $TREE$FILE
fi
else
echo "hack: Whoa, something happened to " $1
exit 6
fi
#
# If it's never been RCS'd before, check the file in and
# create a logging line for it.
#
if [ ! -f $RCS/$BASENAME",v" ]
then
ci -u $1 $RCS/$BASENAME,v
fi
#
# Check the file out and lock it
#
co -l $1 $RCS/$BASENAME,v
#
# Make the changes
#
$EDITOR $CONFIG/$BASENAME
#
# Check the file back in and re-own/group it
#
ci -u $1 $RCS/$BASENAME,v
chown $OWNER.$GROUP $FILE
#############################################################
--
Dean Carpenter deano@areyes.com
Areyes, Inc. dcarpenter@kraft.com
You can drop Dean at note at deano@areyes.com
Caldera Network
Desktop ReviewBy Edward Cameron
[A number of folks have written and asked about reviews of the various Linux distributions -- Slackware, RedHat, Debian, Yggdrasil, Linux-FT, and so forth. Since I honestly don't have the diskspace, time, or technical expertise to do this justice I wanted to thank Edward Cameron for graciously offering to review one of these fine products: the Caldera Network Desktop by the Caldera Corporation.
[Ed very kindly sent a complete set of HTML documents which can be found in their entirety at the links above. The CND Review comes complete with some very nice screen dumps of the various parts of the desktop which will give you a bit of a feel for the product. The Web Surfing page provides some interesting links to Netscape plug-ins, and E-Mail and Linux gives some useful suggestions for setting up popclient and PINE for email service under Linux.
[If you have comments, suggestions, ideas, or just want to chat about this program, please don't hesitate to drop Ed a note! He can be reached at:
Edward Cameron <ecame119@ecity.net>
[If anyone else has experiences they'd like to share with setting up or using any of the various Linux distributions please drop me a note and let me know. The only proviso is that serious OS-bashing will be considered a no-no. (all verbal scuffles will be directed to the comp.os.linux.advocacy group... :-)
[Enjoy! --John]
FVWM and Audio!
By Nic Tjirkalli <nic@pipex-sa.net>
Well, there is no reason why dozing or apparently warping OSs should have the monopoly on this - the same can be done with the FVWM in X. As of verision 1.24 (release r) of the FVWM, an FvwmAudio module has been included, as a standard module. Quoting the FvwmAudio (1.0) man, the FvwmAudio module :-
[To find out which version of fvwm you're using you can enter the following either in an xterm or at the console -- note that what is printed to the screen is actually an error message that happens to contain the Fvwm version number.
fvwm --version
What you'll see might be something like:
Fvwm Ver 1.23b usage: fvwm [-d dpy] [-debug] [-f config_file] [-s] fvwm: another WM is running--John]
Compile - have no fear, Fvwm compiles VERY EASILY and
the included documentation is complete and useful.
To compile Fvwm,
tar -zxvf fvwm-2.0.39.tgz
cd fvwm
xmkmf
make Makefiles make all
make install make install.man
NOTE:-
However, I have opted to use an external audio player (SOX) for a whole host of reasons. Pull down LSOX (the linux version of SOX) from Sunsite or your favourite mirror. The file you need is :- Lsox-linux.tar.gz in the /pub/Linux/apps/sound/convert/ directory. Compile - yes compile as follows :
tar -zxvf Lsox-linux.tar.gz
cd Lsox
cp Makefile Sox/ cp pat.c Sox/
cd Sox make
cp sox /usr/bin/ ln -s /usr/bin/sox /usr/bin/play ln -s /usr/bin/sox /usr/bin/pplay
There are two requirements for activating the FVWM audio features :-
The configuration info for allowing the Fvwm to produce sounds can either be placed in
Add the following statement to the fvwm configuration file, uder the
Function "InitFunction" section :
Module "I" FvwmAudio
*FvwmAudioPlayCmd /usr/bin/play
*FvwmAudioPlayCmd /usr/bin/play
will cause FVWM to use the play program
*FvwmAudioPlayCmd builtin-rplay
will cause FVWM to use the built in rplay support
*FvwmAudioDir /usr/lib/sounds
*FvwmAudioDelay 5
*FvwmAudio window-manager-event sound
Possible window-manager-events include :-
So, for example, if you want to use the /usr/bin/play utility to play audio
files which are loacted in the /usr/local/sounds directory and
have a 6 second sound delay and play the file bang.au when a window
is iconified and play up.wav when a window is raised, you would
add the following statements to your .fvwmrc file :-
*FvwmAudioPlayCmd /usr/bin/play *FvwmAudioDir /usr/local/sounds *FvwmAudioDelay 6 *FvwmAudio iconify bang.au *FvwmAudio raise_window up.wav
[Pretty cool, eh? Betcha always wanted to to hear that gravelly-Dirty-Harry warning "Go ahead... Make my day..." when you reached for the 'ol kill button to zap some ill-mannered program...?
[Well, here's your chance! :-) Don't forget to drop Nic and note and let him know how things worked out. --John]
Using StraceBy Jesper Pedersen <blackie@imada.ou.dk>
This short overview will describe some of the things you can do with strace. First of all, what is strace? Strace is a program which traces system calls, so that you can see what other programs do internally. This article will not describe how strace works, or any of its many options, but rather give some examples of what it can be used for.
open("etc/ld.so.cache" O_RDONLY) = 4
open("home/blackie/.Xauthority" O_RDONLY) = 5
open("usr/X11R6/lib/X11/locale/locale.alias" O_RDONLY) = 5
open("usr/X11R6/lib/X11/locale/locale.alias" O_RDONLY) = 5
open("usr/X11R6/lib/X11/locale/locale.dir" O_RDONLY) = 5
open("usr/X11R6/lib/X11/locale/C/XLC_LOCALE" O_RDONLY) = 5
open("home/blackie/.Xdefaults-blixen" O_RDONLY) = -1 ENOENT (No such
open("usr/X11R6/lib/X11/app-defaults/XTerm" O_RDONLY) = 5
Well what does this mean?
First, you can see that it is the system call open which has been called. Second, you can see which file has been opened (or was tried to open). Next, you can see which mode the file has been open in (see open(2)) And finally, you can see which file handler (if any) was returned from the system call.
Of course it's not xterm which reads all these files, but X11, which allows xterm to map the window. BUT, if you wanted to know where to put your app-default files, you would have found it.
access(".hi", F_OK) = -1 ENOENT (No such file or directory)
access(".hi", F_OK) = -1 ENOENT (No such file or directory)
access(".hi", F_OK) = -1 ENOENT (No such file or directory)
which means that it tries to access the file .hi repeatily. Knowing this,
you may want to check this file.
Kind regards Jesper.
[Again, I want to thank Jesper, and all those who have taken the time to sit down and write up their suggestions and ideas! There's no way that I could write with the breadth of experience that many of you offer. Please don't forget to drop Jesper, or any of these authors, a note and let them know that you appreciate their efforts!
[Thanks! --John]
Connecting Computers
via PLIP
By James McDuffie <mcduffie@scsn.net>
Here I will give an explanation on how I set up a PLIP (Parallel Line IP) connection between a Linux desktop and a DOS/Windows laptop. This can be useful especially if you have a useable laptop that does not have a PCMCIA slot for an ethernet card. Or it can be useful if you're on a tight budget. This is in no way a complete guide to PLIP, (or maybe it is) it is simply an explanation into how I did things.
First of all, you will of course need the right kind of cable. The cable simply needs to be a parallel cable that is compatible with programs such as DOS's InterServer and Interlink or a program such as Lap Link. All I did was go into a local computer specialty store and told them what I wanted. Places such as Wal-Mart and Best Buy will not have the correct cable but a locally owned shop will most likely have one.
After you have the cable you must recompile your kernel to support PLIP. The newer kernels have it built-in so you won't need a patch. For the DOS/Windows computer you will need the packet driver for PLIP. After a bit of searching I did find it here:
ftp://ftp.crynwr.com/drivers/plip.zip
The program runs under DOS and acts like a Ethernet Packet driver. Also, on the Windows computer you will need Trumpet Winsock. This serves as the TCP/IP interface. Otherwise, you can probably find TCP/IP software for DOS. I had WinSock on hand and so that's what I used.
Okay, now we have all the software. Lets start by setting up the Linux computer. First off, you must set up the DOS computer's address in the /etc/hosts. If you do not have a registered IP for it you can use one of the 192.168.*.* private address space IPS. Just make up numbers to you pleasure where the *'s are. I have set it up so that my Linux computer is called `conspiracy` and my Windows computer is called `duncan`. Next, all I did was add the following lines to my /etc/rc.d/rc.inet1:
/sbin/ifconfig plip1 conspiracy pointopoint duncan arp up /sbin/route add duncanThis sets up the interface and then adds a route to it. Simple, eh? Make note that plip1=lpt1, plip2=lpt2 and so on.
Once you have done this you can set up the Windows computer. To do this simply add these lines to the autoexec.bat:
c:\plip\plip.com 0x60 c:\tcpip\winsock\winpkt.com 0x60
This sets the plip.com program on packet vector 0x60 and then loads the winpkt.com program that comes with trumpet winsock on the same vector. If the cable is something other than lpt1 you will have to tell plip.com the irq number and io address. Also, winpkt.com needs to run to make the packet vector avaliable to Windows. From here we go to the actual setup under Trumpet Winsock. All you have to do is unselect SLIP or PPP and enter 60 into the box labeled Packet vector. Then tell it the IP address you gave it, the IP address of the Linux computer as the default gateway and the Name Server as either you computer's ip or your ISP's address for its nameservers if your going to connect it to the Internet (more on this later). Close the setup and re-run Winsock and you should have it! Put winsock in your startup group and you have everything setup automatically!
If you want to access the Internet through the Linux computer on the Windows computer you will need to set up IP Masquerading, for info on this see the NET-2-HOWTO. This simply masquerades the Windows computer with your Linux computer's IP address.
Also I have found a program that lets you run X-Windows programs under Windows! It is located at:
Set it up according to directions and then all you have to do is telnet in from the Windows computer then set the display to the Windows computer (`DISPLAY=duncan:0.0` for instance) and run the program desired. There is nothing cooler than running xv under Windows! Hope all this helped.
James McDuffie
mcduffie@scsn.net
[Kudos to James for an excellent article! I've had a number of y'all (that's "second person plural" here in Nashville :-) write and ask various questions about networking. This is something that I admit to knowing VERY little about.
[I really appreciate Jame's clear and concise write-up. Drop him a note of thanks once you've started cruisin' Linux-Space from your 'Doze laptop via that Linux box of your's...
[Have fun! --John]
Using CronBy Brian Freeze <freezeb@www.deltastar.nb.ca>
Cron lives up to what the computer was designed for. Give it a task, walk away, and know it will get done without any more manual direction from you. Schedule backups, remove old logs, create stats from logs, or, if you run a dialup connection, run a script that will ping a server to ensure the connection is up and, if down, redial your provider in whatever time frame the script is told. The nice thing about cron is you tell it when to run and how often to run. I have a script launched by cron to check my connection every 5 mins and if down redial and another to check mail every 2 hours from a popserver all of which is done behind the scenes and system resources are only called upon at the given time the script must run.
A good source for beginners on this subject is a book by Matt Welsh and Lar Kaufman called Running Linux. Pages 191 to 196 give details on using cron.
www# crontab -ethis will bring up crontab into the "vi editor" which is set as the default editor. You can change this by sending the following command at the prompt.
www# setenv VISUAL=emacs This is for the Bourne-compatable shell. www# setenv VISUAL emacs This is for the C shell.Check out the man page for cron as well as the man page on your shell and how to set the default editor. Once in the editor, we can see that there are already system scripts or programs running from cron. Most have 2 things in common: they have a comment line started with a "#", and the next line is the command line.
Crontab command line:
"minute" "hour" "dayofmonth" "month" "day of week" "script and shell commands go here"
example:
0,5,10,15,20,25,30,35,40,45,50,55 * * * * /usr/local/bin/checkmailAs you can see, I have set cron to run every 5 mins which would not be very efficient unless I got a lot of mail and was at my machine all the time. It would be better to set it as follows using the hour field:
0 6,7,8,9,10,11,12,13,14,15,16,17,18,23 * * * /usr/local/bin/checkmailAs you can see, the fields are seperated by a space and you can put multiple entries in the field, as I have done, seperated by a comma. You can put shell commands in the command field such as this example taken from the book Running Linux:
0 1 1 * * find /tmp -atime 3 -exec rm -f {} \;
This one will run the command at 1AM every month on the 1st day to check
and remove old files from /tmp.
########################################################################
This is a script that I have included that will check a dialup line by
pinging a name server to see if the lines up and if down call up dip to
redial the line. I set cron to run this every 5 mins. My provider has a
limit of 15 mins if the line is inactive and will drop it.
#########################################################################
check-link
#!/bin/sh
PING=/tmp/ping.$$
#check that link is up
ping -q -c 1 131.202.3.3 > $PING 2>1
awk '
/transmitted/ {
if ($1 == $4) {
exit 0
} else {
exit 254
}
} ' $PING
rslt=$?
rm $PING
if [ $rslt -eq 254 ]
then
#restart link
/sbin/dip /etc/dipscript &
fi
#########################################################################
Now that you know how to edit and enter things in cron, experiment with it
as this is what linux is all about and, no, I haven't figured out how to
get cron to let the dogs out at 3am but I'm working on it.
regards
Brian C. Freeze
freezeb@nbnet.nb.ca
freezeb@www.deltastar.nb.ca
[Well, here's another subject about which I admit to knowing very little. I honestly haven't tinkered much with cron and so VERY much appreciate Brian's helpful write up. I'm sure that there are a LOT of things that can be done with cron. If you have any ideas or suggestions please drop a note to Brian or myself!
[Enjoy! --John]
Knews and crontab tips
By Bill Powers <wepprop@nettap.com>
First let me say I love your features. I've gotten a lot of useful information on things to get and things to try from reading them. I especially liked the 'trap /usr/bin/clear EXIT' to clear the screen on logout. Very elegant.
I thought I'd toss a couple of small things back your way. First, I spent a lot of time looking for a fully threaded newsreader that worked halfway well across a serial link. Something that would basically work as well as tin does on a network. I had just about despaired of ever finding something when I came across 'knews'. It's on sunsite in system/Printing, it's fairly easy to set up, and with a couple of resources set in .Xdefaults, it's reasonably fast. If you ever have time to try it out, try setting these resources to start with:
Knews.*.retrieveDescriptions: false Knews.*.readActiveFile: false Knews.*.fillNewsrcFile: true Knews.*.threadEmAll: true
One of the neat things about Linux is there's always more than one way to skin the proverbial cat. I wanted to check for mail every few minutes while connected to my service provider, but I came up with a completely different solution than you did. I added the following line to my ip-up script:
crontab ~/.crontab
Then I created a one line .crontab file in my home directory:
*/5 * * * * /root/mailman > /dev/console 2>&1
/root/mailman is another one line script invoking popclient to retrieve the mail and append it to the calling users mail folder. I put it in /root because it contains my password and userid. /root has _very_ restrictive permissions. The redirected output is necessary, otherwise crontab will sent email to root whenever something happens it doesn't like. If you're using xbiff or xmailbox (which I'm using now, since I read about it in your mag), you can redirect any output to /dev/null instead of /dev/console.
One vital piece of the crontab mail checking scheme: In order to turn it off when you shut down ppp you need the following line in the ip-down script:
crontab -d $USER
I'm sure putting together the Gazette must be hard work. I just want to let you know someone out there appreciates it.
-- Bill Powers wepprop@nettap.com Linux: Resistance is futile...
[Well, I'll have to admit that I'm terminally a creature of habit. I started using skim/xskim a couple months ago and use them almost daily to pick up the news which I can read later. I haven't tried knews and so very much appreciate Bill's offering this suggestion, as well as those for using crontab! -- John]
Emacs tipsBy Paul Lussier < pll@swl.msd.ray.com>
Hi John,
Listen, I must agree with OENT (No such file or directory) access(".hi", F_OK) = -1 ENOENT (No such file or directory) which means that it tries to access the file .hi repeatily. Knowing this, you may want to check this file.
Kind regards Jesper.
[Again, I want to thank Jesper, and all those who have taken the time to sit down and write up their suggestions and ideas! There's no way that I could write with the breadth of experience that many of you offer. Please don't forget to drop Jesper, or any of these authors, a note and let them know that you appreciate their efforts!
[Thanks! --John]
Connecting Computers
via PLIP
By James McDuffie <mcduffie@scsn.net>
Here I will give an explanation on how I set up a PLIP (Parallel Line IP) connection between a Linux desktop and a DOS/Windows laptop. This can be useful especially if you have a useable laptop that does not have a PCMCIA slot for an ethernet card. Or it can be useful if you're on a tight budget. This is in no way a complete guide to PLIP, (or maybe it is) it is simply an explanation into how I did things.
First of all, you will of course need the right kind of cable. The cable simply needs to be a parallel cable that is compatible with programs such as DOS's InterServer and Interlink or a program such as Lap Link. All I did was go into a local computer specialty store and told them what I wanted. Places such as Wal-Mart and Best Buy will not have the correct cable but a locally owned shop will most likely have one.
After you have the cable you must recompile your kernel to support PLIP. The newer kernels have it built-in so you won't need a patch. For the DOS/Windows computer you will need the packet driver for PLIP. After a bit of searching I did find it here:
ftp://ftp.crynwr.com/drivers/plip.zip
The program runs under DOS and acts like a Ethernet Packet driver. Also, on the Windows computer you will need Trumpet Winsock. This serves as the TCP/IP interface. Otherwise, you can probably find TCP/IP software for DOS. I had WinSock on hand and so that's what I used.
Okay, now we have all the software. Lets start by setting up the Linux computer. First off, you must set up the DOS computer's address in the /etc/hosts. If you do not have a registered IP for it you can use one of the 192.168.*.* private address space IPS. Just make up numbers to you pleasure where the *'s are. I have set it up so that my Linux computer is called `conspiracy` and my Windows computer is called `duncan`. Next, all I did was add the following lines to my /etc/rc.d/rc.inet1:
/sbin/ifconfig plip1 conspiracy pointopoint duncan arp up /sbin/route add duncanThis sets up the interface and then adds a route to it. Simple, eh? Make note that plip1=lpt1, plip2=lpt2 and so on.
Once you have done this you can set up the Windows computer. To do this simply add these lines to the autoexec.bat:
c:\plip\plip.com 0x60 c:\tcpip\winsock\winpkt.com 0x60
This sets the plip.com program on packet vector 0x60 and then loads the winpkt.com program that comes with trumpet winsock on the same vector. If the cable is something other than lpt1 you will have to tell plip.com the irq number and io address. Also, winpkt.com needs to run to make the packet vector avaliable to Windows. From here we go to the actual setup under Trumpet Winsock. All you have to do is unselect SLIP or PPP and enter 60 into the box labeled Packet vector. Then tell it the IP address you gave it, the IP address of the Linux computer as the default gateway and the Name Server as either you computer's ip or your ISP's address for its nameservers if your going to connect it to the Internet (more on this later). Close the setup and re-run Winsock and you should have it! Put winsock in your startup group and you have everything setup automatically!
If you want to access the Internet through the Linux computer on the Windows computer you will need to set up IP Masquerading, for info on this see the NET-2-HOWTO. This simply masquerades the Windows computer with your Linux computer's IP address.
Also I have found a program that lets you run X-Windows programs under Windows! It is located at:
Set it up according to directions and then all you have to do is telnet in from the Windows computer then set the display to the Windows computer (`DISPLAY=duncan:0.0` for instance) and run the program desired. There is nothing cooler than running xv under Windows! Hope all this helped.
James McDuffie
mcduffie@scsn.net
[Kudos to James for an excellent article! I've had a number of y'all (that's "second person plural" here in Nashville :-) write and ask various questions about networking. This is something that I admit to knowing VERY little about.
[I really appreciate Jame's clear and concise write-up. Drop him a note of thanks once you've started cruisin' Linux-Space from your 'Doze laptop via that Linux box of your's...
[Have fun! --John]
Using CronBy Brian Freeze <freezeb@www.deltastar.nb.ca>
Cron lives up to what the computer was designed for. Give it a task, walk away, and know it will get done without any more manual direction from you. Schedule backups, remove old logs, create stats from logs, or, if you run a dialup connection, run a script that will ping a server to ensure the connection is up and, if down, redial your provider in whatever time frame the script is told. The nice thing about cron is you tell it when to run and how often to run. I have a script launched by cron to check my connection every 5 mins and if down redial and another to check mail every 2 hours from a popserver all of which is done behind the scenes and system resources are only called upon at the given time the script must run.
A good source for beginners on this subject is a book by Matt Welsh and Lar Kaufman called Running Linux. Pages 191 to 196 give details on using cron.
www# crontab -ethis will bring up crontab into the "vi editor" which is set as the default editor. You can change this by sending the following command at the prompt.
www# setenv VISUAL=emacs This is for the Bourne-compatable shell. www# setenv VISUAL emacs This is for the C shell.Check out the man page for cron as well as the man page on your shell and how to set the default editor. Once in the editor, we can see that there are already system scripts or programs running from cron. Most have 2 things in common: they have a comment line started with a "#", and the next line is the command line.
Crontab command line:
"minute" "hour" "dayofmonth" "month" "day of week" "script and shell commands go here"
example:
0,5,10,15,20,25,30,35,40,45,50,55 * * * * /usr/local/bin/checkmailAs you can see, I have set cron to run every 5 mins which would not be very efficient unless I got a lot of mail and was at my machine all the time. It would be better to set it as follows using the hour field:
0 6,7,8,9,10,11,12,13,14,15,16,17,18,23 * * * /usr/local/bin/checkmailAs you can see, the fields are seperated by a space and you can put multiple entries in the field, as I have done, seperated by a comma. You can put shell commands in the command field such as this example taken from the book Running Linux:
0 1 1 * * find /tmp -atime 3 -exec rm -f {} \;
This one will run the command at 1AM every month on the 1st day to check
and remove old files from /tmp.
########################################################################
This is a script that I have included that will check a dialup line by
pinging a name server to see if the lines up and if down call up dip to
redial the line. I set cron to run this every 5 mins. My provider has a
limit of 15 mins if the line is inactive and will drop it.
#########################################################################
check-link
#!/bin/sh
PING=/tmp/ping.$$
#check that link is up
ping -q -c 1 131.202.3.3 > $PING 2>1
awk '
/transmitted/ {
if ($1 == $4) {
exit 0
} else {
exit 254
}
} ' $PING
rslt=$?
rm $PING
if [ $rslt -eq 254 ]
then
#restart link
/sbin/dip /etc/dipscript &
fi
#########################################################################
Now that you know how to edit and enter things in cron, experiment with it
as this is what linux is all about and, no, I haven't figured out how to
get cron to let the dogs out at 3am but I'm working on it.
regards
Brian C. Freeze
freezeb@nbnet.nb.ca
freezeb@www.deltastar.nb.ca
[Well, here's another subject about which I admit to knowing very little. I honestly haven't tinkered much with cron and so VERY much appreciate Brian's helpful write up. I'm sure that there are a LOT of things that can be done with cron. If you have any ideas or suggestions please drop a note to Brian or myself!
[Enjoy! --John]
Knews and crontab tips
By Bill Powers <wepprop@nettap.com>
First let me say I love your features. I've gotten a lot of useful information on things to get and things to try from reading them. I especially liked the 'trap /usr/bin/clear EXIT' to clear the screen on logout. Very elegant.
I thought I'd toss a couple of small things back your way. First, I spent a lot of time looking for a fully threaded newsreader that worked halfway well across a serial link. Something that would basically work as well as tin does on a network. I had just about despaired of ever finding something when I came across 'knews'. It's on sunsite in system/Printing, it's fairly easy to set up, and with a couple of resources set in .Xdefaults, it's reasonably fast. If you ever have time to try it out, try setting these resources to start with:
Knews.*.retrieveDescriptions: false Knews.*.readActiveFile: false Knews.*.fillNewsrcFile: true Knews.*.threadEmAll: true
One of the neat things about Linux is there's always more than one way to skin the proverbial cat. I wanted to check for mail every few minutes while connected to my service provider, but I came up with a completely different solution than you did. I added the following line to my ip-up script:
crontab ~/.crontab
Then I created a one line .crontab file in my home directory:
*/5 * * * * /root/mailman > /dev/console 2>&1
/root/mailman is another one line script invoking popclient to retrieve the mail and append it to the calling users mail folder. I put it in /root because it contains my password and userid. /root has _very_ restrictive permissions. The redirected output is necessary, otherwise crontab will sent email to root whenever something happens it doesn't like. If you're using xbiff or xmailbox (which I'm using now, since I read about it in your mag), you can redirect any output to /dev/null instead of /dev/console.
One vital piece of the crontab mail checking scheme: In order to turn it off when you shut down ppp you need the following line in the ip-down script:
crontab -d $USER
I'm sure putting together the Gazette must be hard work. I just want to let you know someone out there appreciates it.
-- Bill Powers wepprop@nettap.com Linux: Resistance is futile...
[Well, I'll have to admit that I'm terminally a creature of habit. I started using skim/xskim a couple months ago and use them almost daily to pick up the news which I can read later. I haven't tried knews and so very much appreciate Bill's offering this suggestion, as well as those for using crontab! -- John]
Emacs tipsBy Paul Lussier < pll@swl.msd.ray.com>
Hi John,
Listen, I must agree with OENT (No such file or directory) access(".hi", F_OK) = -1 ENOENT (No such file or directory) which means that it tries to access the file .hi repeatily. Knowing this, you may want to check this file.
Kind regards Jesper.
[Again, I want to thank Jesper, and all those who have taken the time to sit down and write up their suggestions and ideas! There's no way that I could write with the breadth of experience that many of you offer. Please don't forget to drop Jesper, or any of these authors, a note and let them know that you appreciate their efforts!
[Thanks! --John]
Connecting Computers
via PLIP
By James McDuffie <mcduffie@scsn.net>
Here I will give an explanation on how I set up a PLIP (Parallel Line IP) connection between a Linux desktop and a DOS/Windows laptop. This can be useful especially if you have a useable laptop that does not have a PCMCIA slot for an ethernet card. Or it can be useful if you're on a tight budget. This is in no way a complete guide to PLIP, (or maybe it is) it is simply an explanation into how I did things.
First of all, you will of course need the right kind of cable. The cable simply needs to be a parallel cable that is compatible with programs such as DOS's InterServer and Interlink or a program such as Lap Link. All I did was go into a local computer specialty store and told them what I wanted. Places such as Wal-Mart and Best Buy will not have the correct cable but a locally owned shop will most likely have one.
After you have the cable you must recompile your kernel to support PLIP. The newer kernels have it built-in so you won't need a patch. For the DOS/Windows computer you will need the packet driver for PLIP. After a bit of searching I did find it here:
ftp://ftp.crynwr.com/drivers/plip.zip
The program runs under DOS and acts like a Ethernet Packet driver. Also, on the Windows computer you will need Trumpet Winsock. This serves as the TCP/IP interface. Otherwise, you can probably find TCP/IP software for DOS. I had WinSock on hand and so that's what I used.
Okay, now we have all the software. Lets start by setting up the Linux computer. First off, you must set up the DOS computer's address in the /etc/hosts. If you do not have a registered IP for it you can use one of the 192.168.*.* private address space IPS. Just make up numbers to you pleasure where the *'s are. I have set it up so that my Linux computer is called `conspiracy` and my Windows computer is called `duncan`. Next, all I did was add the following lines to my /etc/rc.d/rc.inet1:
/sbin/ifconfig plip1 conspiracy pointopoint duncan arp up /sbin/route add duncanThis sets up the interface and then adds a route to it. Simple, eh? Make note that plip1=lpt1, plip2=lpt2 and so on.
Once you have done this you can set up the Windows computer. To do this simply add these lines to the autoexec.bat:
c:\plip\plip.com 0x60 c:\tcpip\winsock\winpkt.com 0x60
This sets the plip.com program on packet vector 0x60 and then loads the winpkt.com program that comes with trumpet winsock on the same vector. If the cable is something other than lpt1 you will have to tell plip.com the irq number and io address. Also, winpkt.com needs to run to make the packet vector avaliable to Windows. From here we go to the actual setup under Trumpet Winsock. All you have to do is unselect SLIP or PPP and enter 60 into the box labeled Packet vector. Then tell it the IP address you gave it, the IP address of the Linux computer as the default gateway and the Name Server as either you computer's ip or your ISP's address for its nameservers if your going to connect it to the Internet (more on this later). Close the setup and re-run Winsock and you should have it! Put winsock in your startup group and you have everything setup automatically!
If you want to access the Internet through the Linux computer on the Windows computer you will need to set up IP Masquerading, for info on this see the NET-2-HOWTO. This simply masquerades the Windows computer with your Linux computer's IP address.
Also I have found a program that lets you run X-Windows programs under Windows! It is located at:
Set it up according to directions and then all you have to do is telnet in from the Windows computer then set the display to the Windows computer (`DISPLAY=duncan:0.0` for instance) and run the program desired. There is nothing cooler than running xv under Windows! Hope all this helped.
James McDuffie
mcduffie@scsn.net
[Kudos to James for an excellent article! I've had a number of y'all (that's "second person plural" here in Nashville :-) write and ask various questions about networking. This is something that I admit to knowing VERY little about.
[I really appreciate Jame's clear and concise write-up. Drop him a note of thanks once you've started cruisin' Linux-Space from your 'Doze laptop via that Linux box of your's...
[Have fun! --John]
Using CronBy Brian Freeze <freezeb@www.deltastar.nb.ca>
Cron lives up to what the computer was designed for. Give it a task, walk away, and know it will get done without any more manual direction from you. Schedule backups, remove old logs, create stats from logs, or, if you run a dialup connection, run a script that will ping a server to ensure the connection is up and, if down, redial your provider in whatever time frame the script is told. The nice thing about cron is you tell it when to run and how often to run. I have a script launched by cron to check my connection every 5 mins and if down redial and another to check mail every 2 hours from a popserver all of which is done behind the scenes and system resources are only called upon at the given time the script must run.
A good source for beginners on this subject is a book by Matt Welsh and Lar Kaufman called Running Linux. Pages 191 to 196 give details on using cron.
www# crontab -ethis will bring up crontab into the "vi editor" which is set as the default editor. You can change this by sending the following command at the prompt.
www# setenv VISUAL=emacs This is for the Bourne-compatable shell. www# setenv VISUAL emacs This is for the C shell.Check out the man page for cron as well as the man page on your shell and how to set the default editor. Once in the editor, we can see that there are already system scripts or programs running from cron. Most have 2 things in common: they have a comment line started with a "#", and the next line is the command line.
Crontab command line:
"minute" "hour" "dayofmonth" "month" "day of week" "script and shell commands go here"
example:
0,5,10,15,20,25,30,35,40,45,50,55 * * * * /usr/local/bin/checkmailAs you can see, I have set cron to run every 5 mins which would not be very efficient unless I got a lot of mail and was at my machine all the time. It would be better to set it as follows using the hour field:
0 6,7,8,9,10,11,12,13,14,15,16,17,18,23 * * * /usr/local/bin/checkmailAs you can see, the fields are seperated by a space and you can put multiple entries in the field, as I have done, seperated by a comma. You can put shell commands in the command field such as this example taken from the book Running Linux:
0 1 1 * * find /tmp -atime 3 -exec rm -f {} \;
This one will run the command at 1AM every month on the 1st day to check
and remove old files from /tmp.
########################################################################
This is a script that I have included that will check a dialup line by
pinging a name server to see if the lines up and if down call up dip to
redial the line. I set cron to run this every 5 mins. My provider has a
limit of 15 mins if the line is inactive and will drop it.
#########################################################################
check-link
#!/bin/sh
PING=/tmp/ping.$$
#check that link is up
ping -q -c 1 131.202.3.3 > $PING 2>1
awk '
/transmitted/ {
if ($1 == $4) {
exit 0
} else {
exit 254
}
} ' $PING
rslt=$?
rm $PING
if [ $rslt -eq 254 ]
then
#restart link
/sbin/dip /etc/dipscript &
fi
#########################################################################
Now that you know how to edit and enter things in cron, experiment with it
as this is what linux is all about and, no, I haven't figured out how to
get cron to let the dogs out at 3am but I'm working on it.
regards
Brian C. Freeze
freezeb@nbnet.nb.ca
freezeb@www.deltastar.nb.ca
[Well, here's another subject about which I admit to knowing very little. I honestly haven't tinkered much with cron and so VERY much appreciate Brian's helpful write up. I'm sure that there are a LOT of things that can be done with cron. If you have any ideas or suggestions please drop a note to Brian or myself!
[Enjoy! --John]
Knews and crontab tips
By Bill Powers <wepprop@nettap.com>
First let me say I love your features. I've gotten a lot of useful information on things to get and things to try from reading them. I especially liked the 'trap /usr/bin/clear EXIT' to clear the screen on logout. Very elegant.
I thought I'd toss a couple of small things back your way. First, I spent a lot of time looking for a fully threaded newsreader that worked halfway well across a serial link. Something that would basically work as well as tin does on a network. I had just about despaired of ever finding something when I came across 'knews'. It's on sunsite in system/Printing, it's fairly easy to set up, and with a couple of resources set in .Xdefaults, it's reasonably fast. If you ever have time to try it out, try setting these resources to start with:
Knews.*.retrieveDescriptions: false Knews.*.readActiveFile: false Knews.*.fillNewsrcFile: true Knews.*.threadEmAll: true
One of the neat things about Linux is there's always more than one way to skin the proverbial cat. I wanted to check for mail every few minutes while connected to my service provider, but I came up with a completely different solution than you did. I added the following line to my ip-up script:
crontab ~/.crontab
Then I created a one line .crontab file in my home directory:
*/5 * * * * /root/mailman > /dev/console 2>&1
/root/mailman is another one line script invoking popclient to retrieve the mail and append it to the calling users mail folder. I put it in /root because it contains my password and userid. /root has _very_ restrictive permissions. The redirected output is necessary, otherwise crontab will sent email to root whenever something happens it doesn't like. If you're using xbiff or xmailbox (which I'm using now, since I read about it in your mag), you can redirect any output to /dev/null instead of /dev/console.
One vital piece of the crontab mail checking scheme: In order to turn it off when you shut down ppp you need the following line in the ip-down script:
crontab -d $USER
I'm sure putting together the Gazette must be hard work. I just want to let you know someone out there appreciates it.
-- Bill Powers wepprop@nettap.com Linux: Resistance is futile...
[Well, I'll have to admit that I'm terminally a creature of habit. I started using skim/xskim a couple months ago and use them almost daily to pick up the news which I can read later. I haven't tried knews and so very much appreciate Bill's offering this suggestion, as well as those for using crontab! -- John]
Emacs tipsBy Paul Lussier < pll@swl.msd.ray.com>
Hi John,
Listen, I must agree with OENT (No such file or directory) access(".hi", F_OK) = -1 ENOENT (No such file or directory) which means that it tries to access the file .hi repeatily. Knowing this, you may want to check this file.
Kind regards Jesper.
[Again, I want to thank Jesper, and all those who have taken the time to sit down and write up their suggestions and ideas! There's no way that I could write with the breadth of experience that many of you offer. Please don't forget to drop Jesper, or any of these authors, a note and let them know that you appreciate their efforts!
[Thanks! --John]
Connecting Computers
via PLIP
By James McDuffie <mcduffie@scsn.net>
Here I will give an explanation on how I set up a PLIP (Parallel Line IP) connection between a Linux desktop and a DOS/Windows laptop. This can be useful especially if you have a useable laptop that does not have a PCMCIA slot for an ethernet card. Or it can be useful if you're on a tight budget. This is in no way a complete guide to PLIP, (or maybe it is) it is simply an explanation into how I did things.
First of all, you will of course need the right kind of cable. The cable simply needs to be a parallel cable that is compatible with programs such as DOS's InterServer and Interlink or a program such as Lap Link. All I did was go into a local computer specialty store and told them what I wanted. Places such as Wal-Mart and Best Buy will not have the correct cable but a locally owned shop will most likely have one.
After you have the cable you must recompile your kernel to support PLIP. The newer kernels have it built-in so you won't need a patch. For the DOS/Windows computer you will need the packet driver for PLIP. After a bit of searching I did find it here:
ftp://ftp.crynwr.com/drivers/plip.zip
The program runs under DOS and acts like a Ethernet Packet driver. Also, on the Windows computer you will need Trumpet Winsock. This serves as the TCP/IP interface. Otherwise, you can probably find TCP/IP software for DOS. I had WinSock on hand and so that's what I used.
Okay, now we have all the software. Lets start by setting up the Linux computer. First off, you must set up the DOS computer's address in the /etc/hosts. If you do not have a registered IP for it you can use one of the 192.168.*.* private address space IPS. Just make up numbers to you pleasure where the *'s are. I have set it up so that my Linux computer is called `conspiracy` and my Windows computer is called `duncan`. Next, all I did was add the following lines to my /etc/rc.d/rc.inet1:
/sbin/ifconfig plip1 conspiracy pointopoint duncan arp up /sbin/route add duncanThis sets up the interface and then adds a route to it. Simple, eh? Make note that plip1=lpt1, plip2=lpt2 and so on.
Once you have done this you can set up the Windows computer. To do this simply add these lines to the autoexec.bat:
c:\plip\plip.com 0x60 c:\tcpip\winsock\winpkt.com 0x60
This sets the plip.com program on packet vector 0x60 and then loads the winpkt.com program that comes with trumpet winsock on the same vector. If the cable is something other than lpt1 you will have to tell plip.com the irq number and io address. Also, winpkt.com needs to run to make the packet vector avaliable to Windows. From here we go to the actual setup under Trumpet Winsock. All you have to do is unselect SLIP or PPP and enter 60 into the box labeled Packet vector. Then tell it the IP address you gave it, the IP address of the Linux computer as the default gateway and the Name Server as either you computer's ip or your ISP's address for its nameservers if your going to connect it to the Internet (more on this later). Close the setup and re-run Winsock and you should have it! Put winsock in your startup group and you have everything setup automatically!
If you want to access the Internet through the Linux computer on the Windows computer you will need to set up IP Masquerading, for info on this see the NET-2-HOWTO. This simply masquerades the Windows computer with your Linux computer's IP address.
Also I have found a program that lets you run X-Windows programs under Windows! It is located at:
Set it up according to directions and then all you have to do is telnet in from the Windows computer then set the display to the Windows computer (`DISPLAY=duncan:0.0` for instance) and run the program desired. There is nothing cooler than running xv under Windows! Hope all this helped.
James McDuffie
mcduffie@scsn.net
[Kudos to James for an excellent article! I've had a number of y'all (that's "second person plural" here in Nashville :-) write and ask various questions about networking. This is something that I admit to knowing VERY little about.
[I really appreciate Jame's clear and concise write-up. Drop him a note of thanks once you've started cruisin' Linux-Space from your 'Doze laptop via that Linux box of your's...
[Have fun! --John]
Using CronBy Brian Freeze <freezeb@www.deltastar.nb.ca>
Cron lives up to what the computer was designed for. Give it a task, walk away, and know it will get done without any more manual direction from you. Schedule backups, remove old logs, create stats from logs, or, if you run a dialup connection, run a script that will ping a server to ensure the connection is up and, if down, redial your provider in whatever time frame the script is told. The nice thing about cron is you tell it when to run and how often to run. I have a script launched by cron to check my connection every 5 mins and if down redial and another to check mail every 2 hours from a popserver all of which is done behind the scenes and system resources are only called upon at the given time the script must run.
A good source for beginners on this subject is a book by Matt Welsh and Lar Kaufman called Running Linux. Pages 191 to 196 give details on using cron.
www# crontab -ethis will bring up crontab into the "vi editor" which is set as the default editor. You can change this by sending the following command at the prompt.
www# setenv VISUAL=emacs This is for the Bourne-compatable shell. www# setenv VISUAL emacs This is for the C shell.Check out the man page for cron as well as the man page on your shell and how to set the default editor. Once in the editor, we can see that there are already system scripts or programs running from cron. Most have 2 things in common: they have a comment line started with a "#", and the next line is the command line.
Crontab command line:
"minute" "hour" "dayofmonth" "month" "day of week" "script and shell commands go here"
example:
0,5,10,15,20,25,30,35,40,45,50,55 * * * * /usr/local/bin/checkmailAs you can see, I have set cron to run every 5 mins which would not be very efficient unless I got a lot of mail and was at my machine all the time. It would be better to set it as follows using the hour field:
0 6,7,8,9,10,11,12,13,14,15,16,17,18,23 * * * /usr/local/bin/checkmailAs you can see, the fields are seperated by a space and you can put multiple entries in the field, as I have done, seperated by a comma. You can put shell commands in the command field such as this example taken from the book Running Linux:
0 1 1 * * find /tmp -atime 3 -exec rm -f {} \;
This one will run the command at 1AM every month on the 1st day to check
and remove old files from /tmp.
########################################################################
This is a script that I have included that will check a dialup line by
pinging a name server to see if the lines up and if down call up dip to
redial the line. I set cron to run this every 5 mins. My provider has a
limit of 15 mins if the line is inactive and will drop it.
#########################################################################
check-link
#!/bin/sh
PING=/tmp/ping.$$
#check that link is up
ping -q -c 1 131.202.3.3 > $PING 2>1
awk '
/transmitted/ {
if ($1 == $4) {
exit 0
} else {
exit 254
}
} ' $PING
rslt=$?
rm $PING
if [ $rslt -eq 254 ]
then
#restart link
/sbin/dip /etc/dipscript &
fi
#########################################################################
Now that you know how to edit and enter things in cron, experiment with it
as this is what linux is all about and, no, I haven't figured out how to
get cron to let the dogs out at 3am but I'm working on it.
regards
Brian C. Freeze
freezeb@nbnet.nb.ca
freezeb@www.deltastar.nb.ca
[Well, here's another subject about which I admit to knowing very little. I honestly haven't tinkered much with cron and so VERY much appreciate Brian's helpful write up. I'm sure that there are a LOT of things that can be done with cron. If you have any ideas or suggestions please drop a note to Brian or myself!
[Enjoy! --John]
Knews and crontab tips
By Bill Powers <wepprop@nettap.com>
First let me say I love your features. I've gotten a lot of useful information on things to get and things to try from reading them. I especially liked the 'trap /usr/bin/clear EXIT' to clear the screen on logout. Very elegant.
I thought I'd toss a couple of small things back your way. First, I spent a lot of time looking for a fully threaded newsreader that worked halfway well across a serial link. Something that would basically work as well as tin does on a network. I had just about despaired of ever finding something when I came across 'knews'. It's on sunsite in system/Printing, it's fairly easy to set up, and with a couple of resources set in .Xdefaults, it's reasonably fast. If you ever have time to try it out, try setting these resources to start with:
Knews.*.retrieveDescriptions: false Knews.*.readActiveFile: false Knews.*.fillNewsrcFile: true Knews.*.threadEmAll: true
One of the neat things about Linux is there's always more than one way to skin the proverbial cat. I wanted to check for mail every few minutes while connected to my service provider, but I came up with a completely different solution than you did. I added the following line to my ip-up script:
crontab ~/.crontab
Then I created a one line .crontab file in my home directory:
*/5 * * * * /root/mailman > /dev/console 2>&1
/root/mailman is another one line script invoking popclient to retrieve the mail and append it to the calling users mail folder. I put it in /root because it contains my password and userid. /root has _very_ restrictive permissions. The redirected output is necessary, otherwise crontab will sent email to root whenever something happens it doesn't like. If you're using xbiff or xmailbox (which I'm using now, since I read about it in your mag), you can redirect any output to /dev/null instead of /dev/console.
One vital piece of the crontab mail checking scheme: In order to turn it off when you shut down ppp you need the following line in the ip-down script:
crontab -d $USER
I'm sure putting together the Gazette must be hard work. I just want to let you know someone out there appreciates it.
-- Bill Powers wepprop@nettap.com Linux: Resistance is futile...
[Well, I'll have to admit that I'm terminally a creature of habit. I started using skim/xskim a couple months ago and use them almost daily to pick up the news which I can read later. I haven't tried knews and so very much appreciate Bill's offering this suggestion, as well as those for using crontab! -- John]
Emacs tipsBy Paul Lussier < pll@swl.msd.ray.com>
Hi John,
Listen, I must agree with OENT (No such file or directory) access(".hi", F_OK) = -1 ENOENT (No such file or directory) which means that it tries to access the file .hi repeatily. Knowing this, you may want to check this file.
Kind regards Jesper.
[Again, I want to thank Jesper, and all those who have taken the time to sit down and write up their suggestions and ideas! There's no way that I could write with the breadth of experience that many of you offer. Please don't forget to drop Jesper, or any of these authors, a note and let them know that you appreciate their efforts!
[Thanks! --John]
Connecting Computers
via PLIP
By James McDuffie <mcduffie@scsn.net>
Here I will give an explanation on how I set up a PLIP (Parallel Line IP) connection between a Linux desktop and a DOS/Windows laptop. This can be useful especially if you have a useable laptop that does not have a PCMCIA slot for an ethernet card. Or it can be useful if you're on a tight budget. This is in no way a complete guide to PLIP, (or maybe it is) it is simply an explanation into how I did things.
First of all, you will of course need the right kind of cable. The cable simply needs to be a parallel cable that is compatible with programs such as DOS's InterServer and Interlink or a program such as Lap Link. All I did was go into a local computer specialty store and told them what I wanted. Places such as Wal-Mart and Best Buy will not have the correct cable but a locally owned shop will most likely have one.
After you have the cable you must recompile your kernel to support PLIP. The newer kernels have it built-in so you won't need a patch. For the DOS/Windows computer you will need the packet driver for PLIP. After a bit of searching I did find it here:
ftp://ftp.crynwr.com/drivers/plip.zip
The program runs under DOS and acts like a Ethernet Packet driver. Also, on the Windows computer you will need Trumpet Winsock. This serves as the TCP/IP interface. Otherwise, you can probably find TCP/IP software for DOS. I had WinSock on hand and so that's what I used.
Okay, now we have all the software. Lets start by setting up the Linux computer. First off, you must set up the DOS computer's address in the /etc/hosts. If you do not have a registered IP for it you can use one of the 192.168.*.* private address space IPS. Just make up numbers to you pleasure where the *'s are. I have set it up so that my Linux computer is called `conspiracy` and my Windows computer is called `duncan`. Next, all I did was add the following lines to my /etc/rc.d/rc.inet1:
/sbin/ifconfig plip1 conspiracy pointopoint duncan arp up /sbin/route add duncanThis sets up the interface and then adds a route to it. Simple, eh? Make note that plip1=lpt1, plip2=lpt2 and so on.
Once you have done this you can set up the Windows computer. To do this simply add these lines to the autoexec.bat:
c:\plip\plip.com 0x60 c:\tcpip\winsock\winpkt.com 0x60
This sets the plip.com program on packet vector 0x60 and then loads the winpkt.com program that comes with trumpet winsock on the same vector. If the cable is something other than lpt1 you will have to tell plip.com the irq number and io address. Also, winpkt.com needs to run to make the packet vector avaliable to Windows. From here we go to the actual setup under Trumpet Winsock. All you have to do is unselect SLIP or PPP and enter 60 into the box labeled Packet vector. Then tell it the IP address you gave it, the IP address of the Linux computer as the default gateway and the Name Server as either you computer's ip or your ISP's address for its nameservers if your going to connect it to the Internet (more on this later). Close the setup and re-run Winsock and you should have it! Put winsock in your startup group and you have everything setup automatically!
If you want to access the Internet through the Linux computer on the Windows computer you will need to set up IP Masquerading, for info on this see the NET-2-HOWTO. This simply masquerades the Windows computer with your Linux computer's IP address.
Also I have found a program that lets you run X-Windows programs under Windows! It is located at:
Set it up according to directions and then all you have to do is telnet in from the Windows computer then set the display to the Windows computer (`DISPLAY=duncan:0.0` for instance) and run the program desired. There is nothing cooler than running xv under Windows! Hope all this helped.
James McDuffie
mcduffie@scsn.net
[Kudos to James for an excellent article! I've had a number of y'all (that's "second person plural" here in Nashville :-) write and ask various questions about networking. This is something that I admit to knowing VERY little about.
[I really appreciate Jame's clear and concise write-up. Drop him a note of thanks once you've started cruisin' Linux-Space from your 'Doze laptop via that Linux box of your's...
[Have fun! --John]
Using CronBy Brian Freeze <freezeb@www.deltastar.nb.ca>
Cron lives up to what the computer was designed for. Give it a task, walk away, and know it will get done without any more manual direction from you. Schedule backups, remove old logs, create stats from logs, or, if you run a dialup connection, run a script that will ping a server to ensure the connection is up and, if down, redial your provider in whatever time frame the script is told. The nice thing about cron is you tell it when to run and how often to run. I have a script launched by cron to check my connection every 5 mins and if down redial and another to check mail every 2 hours from a popserver all of which is done behind the scenes and system resources are only called upon at the given time the script must run.
A good source for beginners on this subject is a book by Matt Welsh and Lar Kaufman called Running Linux. Pages 191 to 196 give details on using cron.
www# crontab -ethis will bring up crontab into the "vi editor" which is set as the default editor. You can change this by sending the following command at the prompt.
www# setenv VISUAL=emacs This is for the Bourne-compatable shell. www# setenv VISUAL emacs This is for the C shell.Check out the man page for cron as well as the man page on your shell and how to set the default editor. Once in the editor, we can see that there are already system scripts or programs running from cron. Most have 2 things in common: they have a comment line started with a "#", and the next line is the command line.
Crontab command line:
"minute" "hour" "dayofmonth" "month" "day of week" "script and shell commands go here"
example:
0,5,10,15,20,25,30,35,40,45,50,55 * * * * /usr/local/bin/checkmailAs you can see, I have set cron to run every 5 mins which would not be very efficient unless I got a lot of mail and was at my machine all the time. It would be better to set it as follows using the hour field:
0 6,7,8,9,10,11,12,13,14,15,16,17,18,23 * * * /usr/local/bin/checkmailAs you can see, the fields are seperated by a space and you can put multiple entries in the field, as I have done, seperated by a comma. You can put shell commands in the command field such as this example taken from the book Running Linux:
0 1 1 * * find /tmp -atime 3 -exec rm -f {} \;
This one will run the command at 1AM every month on the 1st day to check
and remove old files from /tmp.
########################################################################
This is a script that I have included that will check a dialup line by
pinging a name server to see if the lines up and if down call up dip to
redial the line. I set cron to run this every 5 mins. My provider has a
limit of 15 mins if the line is inactive and will drop it.
#########################################################################
check-link
#!/bin/sh
PING=/tmp/ping.$$
#check that link is up
ping -q -c 1 131.202.3.3 > $PING 2>1
awk '
/transmitted/ {
if ($1 == $4) {
exit 0
} else {
exit 254
}
} ' $PING
rslt=$?
rm $PING
if [ $rslt -eq 254 ]
then
#restart link
/sbin/dip /etc/dipscript &
fi
#########################################################################
Now that you know how to edit and enter things in cron, experiment with it
as this is what linux is all about and, no, I haven't figured out how to
get cron to let the dogs out at 3am but I'm working on it.
regards
Brian C. Freeze
freezeb@nbnet.nb.ca
freezeb@www.deltastar.nb.ca
[Well, here's another subject about which I admit to knowing ve