Re: Stripping trailing blanks?

2003-07-28 Thread Dave O'Neill
On Mon, Jul 28, 2003 at 10:05:26AM -0500, Adam Thornton wrote:
> I believe the Perl function chomp does what you want.
>
> so:
>
> while (<>) {
> chomp;
> print;
> }

Nope, chomp() will only delete a single trailing \n.

For those who like to count rivets, what it really does is removes a
trailing string exactly matching the current value of the input record
separator as defined by the $/ variable -- which is set to "\n" unless
you've changed it yourself.  Other trailing whitespace won't be removed by
chomp.

Dave
--
 ('>  Dave O'Neill <[EMAIL PROTECTED]>,  Staff Scientist, Linuxcare, Inc.
 //\  tel: (613) 562-9949  fax: (613) 562-9304  http://www.linuxcare.com/
 v_/_  Linuxcare.  Simplifying Server Consolidation


Re: Stripping trailing blanks?

2003-07-28 Thread Dave O'Neill
On Mon, Jul 28, 2003 at 09:27:09AM -0500, McKown, John wrote:
> Is there a simple way to strip blanks from all the lines in a file? What I
> am doing is downloading members from my various PDSes. Some of these member
> contain the "standard" sequence number in columns 73-80. I am using Perl to
> strip these off. After stripping off the sequence numbers, I would like to
> strip off any resulting trailing blanks. My current Perl script looks like:

To strip blanks from the end of a string in Perl, a good regular expression
to use is:
s/\s+$//

The \s means "match any whitespace character", including space, tab,
newline, carriage return, and formfeed.  The + character means "match one or
more of the preceeding", and the $ means "anchor this regular expression at
the end of the string.  Together, this will find one or more whitespace
characters at the end of the string, and remove them.

> #!/usr/bin/perl
> while(<>) {
> chop;
> s/(.{0,72}).*/\1/;
> $new1 = reverse($_);
> $_ = $new1;
> s/ *(.*)/\1/;
> $new = reverse($_);
> print $new,"\n";
> }

You can clean this up a little by using substr() and the regular expression
described above.  The code below uses the =~ operator, which binds the
regular expression to the variable $new, instead of to Perl's magic $_
variable.

#!/usr/bin/perl -w
while(<>) {
$new = substr($_, 0, 72); # put first 72 characters into $new
$new =~ s/\s+$//; # Remove trailing space, tab or newline
print "$new\n";
}

Dave
--
 ('>  Dave O'Neill <[EMAIL PROTECTED]>,  Staff Scientist, Linuxcare, Inc.
 //\  tel: (613) 562-9949  fax: (613) 562-9304  http://www.linuxcare.com/
 v_/_  Linuxcare.  Simplifying Server Consolidation


Re: kernel BUG at swap.c:62!

2003-03-26 Thread Dave O'Neill
On Wed, Mar 26, 2003 at 11:26:54AM -0600, Dennis Wicks wrote:
> For anyone who is looking at this problem here is some more info.
>
> It always happens at the same time of day, and that is the same
> time that logrotate runs. But, it doesn't happen every day!
>
> The process is always apache.
>
> NB. My original post is in the archives at:
>
> http://www2.marist.edu/htbin/wlvtype?LINUX-VM.35228

This bug was fixed in 2.4.20.  Check out this thread on the linux-kernel
list for details, and a patch:
http://marc.theaimsgroup.com/?l=linux-kernel&m=103477965829531

Cheers,
Dave
--
 ('>  Dave O'Neill <[EMAIL PROTECTED]>,  Staff Scientist, Linuxcare, Inc.
 //\  tel: (613) 562-9949  fax: (613) 562-9304  http://www.linuxcare.com/
 v_/_  Linuxcare.  Simplifying Server Consolidation


Re: Newbie Xedit Questions

2003-03-10 Thread Dave O'Neill
On Mon, Mar 10, 2003 at 12:39:39PM -0500, Alex deVries wrote:
> I have two xedit questions.  Two.

Only two?

> 1. Is there an xedit for Linux?  You get bonus points if it is open source.

There's THE (The Hessling Editor).  It's GPL'ed and available from
   http://hessling-editor.sourceforge.net/
I haven't used it, though I'm sure others on the list can let you know how
similar (or not) it is to real XEDIT.

> 2. Is there some sort of "Xedit for dummies" or "Xedit for the vi user"?
> Is there a one page cheat sheet?

There's an "Emacs and vi Commands for VM/XEDIT Users" cheatsheet:
   http://www-it.desy.de/support/help/uco_documentation/xedit.ps
It's intended for VM users moving to a Unix system, but it's still very
helpful.

Dave
--
 ('>  Dave O'Neill <[EMAIL PROTECTED]>,  Staff Scientist, Linuxcare, Inc.
 //\  tel: (613) 562-9949  fax: (613) 562-9304  http://www.linuxcare.com/
 v_/_  Linuxcare.  Simplifying Server Consolidation


Re: eServer Magazine

2002-11-25 Thread Dave O'Neill
On Mon, Nov 25, 2002 at 04:10:24PM -0500, Richards.Bob wrote:

> I probably missed it, but is there a URL for this?

The current and previous issues of eServer are available from
http://eservercomputing.com/mainframe/

Cheers,
Dave
--
 ('>  Dave O'Neill <[EMAIL PROTECTED]>,  Staff Scientist,   Linuxcare, Inc.
 //\  tel: (613) 562-9949   fax: (613) 562-9700   http://www.linuxcare.com/
 v_/_   Linuxcare.  Simplifying Server Consolidation



Re: Use SSH instead of TELNET

2002-11-12 Thread Dave O'Neill
On Wed, Nov 13, 2002 at 05:39:20AM +0800, John Summerfield wrote:
> On Tue, 12 Nov 2002 [EMAIL PROTECTED] wrote:
> >  # rpm -qa '*ssh*'
> > rpm: extra arguments given for query of all packages
>
[ snip ]
>
> The oldest system I have is RHL 7.2 and it works there.

Red Hat ships with a newer version of RPM than SuSE.  Red Hat has used RPM
4.x for quite some time, while SuSE still uses RPM 3.x.  The capabilities
are a little different, but using:
   rpm -qa | grep -i ssh
should work just fine regardless of the version of RPM used.

Dave
--
 ('>  Dave O'Neill <[EMAIL PROTECTED]>,  Staff Scientist,   Linuxcare, Inc.
 //\  tel: (613) 562-9949   fax: (613) 562-9700   http://www.linuxcare.com/
 v_/_   Linuxcare.  Simplifying Server Consolidation



Re: Automated PUT

2002-03-26 Thread Dave O'Neill

On Mon, Mar 25, 2002 at 03:44:16PM -0800, Wolfe, Gordon W wrote:
> When I get some service or updates done to my test Linux server, that's
> actually the easy part.  Then I have to move it around to more than a dozen
> other Linux servers, logging on to each one in turn and doing an FTP "get"
> for each file on each server.  As I get more servers running, this problem
> will only get worse.
>
> I'd like to automate this, with a single script to consult a list of servers
> and a list of files to be placed on each server.  Then with a single command
> from my central distribution server, I could automatically update files on
> all the other servers.  This presumes a service userid with the same
> password on all servers, changed frequently.

I'd recommend using ssh, scp, or rsync to do this, rather than FTP.  It's
definitely a more secure solution, and may be more manageable in the long
run.

A simple example:

REMOTE_USER=xfer
SRC_FILE=/path/to/my/file
for host_ip in 100 101 102 105; do
scp $SRC_FILE [EMAIL PROTECTED]$host_ip:/path/to/target/directory
done

The only thing this simple example buys you over an FTP-based solution is a
bit more security.  Your password and your data don't cross the network in
the clear, for example.  However, you still need to type your password every
time, which is a pain.   But... the real timesaving benefits of using SSH
kick in if you start using authentication keys and ssh-agent.

The short explanation is, you generate a public and private key, and place
the public key in the home directory of the appropriate account on the
machine you wish to transfer files to (or remotely run commands on).  Then,
when you want to connect from another machine, such as your test server, you
can connect using the key and its passphrase, rather than a password.  Keys
can be configured with no passphrase to make this entirely automated, but
there's a better way.  If you use ssh-agent, you can cache your passphrases
on the initiating machine, and only need to enter them once (or once an
hour, or once every 15 minutes).

Of course, there's more to it than that, but for more information, you
should read the scp(1), ssh(1), ssh-agent(1), ssh-keygen(1), and sshd(8)
manual pages.  All this documentation can be found at
http://www.openssh.org/ along with the latest source code.

Cheers,
Dave
--
 ('>  Dave O'Neill, Senior Linux Consultant
 //\  Linuxcare, Inc. tel: (613) 562-9949  fax: (613) 562-9700
 v_/_ [EMAIL PROTECTED]  http://www.linuxcare.com/



Re: Couple of problems with RedHat LOADER install

2002-02-19 Thread Dave O'Neill

On Fri, Feb 15, 2002 at 09:48:13AM -0500, Patterson, Ross wrote:

> The Marist and SuSE distributions both run "/sbin/depmod -a" during
> startup (Marist out of /etc/rc.d/rc.sysinit, SuSE out of /etc/rc.d/boot).
> I don't have a Red Hat s390 system close to hand, but I expect it
> does as well - Red Hat i386 certainly does (/etc/rc.d/rc.sysinit).

Yes, Redhat on s390 does run depmod in /etc/rc.d/rc.sysinit.

One thing to note is that Redhat's rc.sysinit runs depmod with the -A
option, not -a. The capital A option checks if any of /etc/modules.conf and
the modules under /lib/modules for the current kernel are newer than the
modules.dep file.  If so, it then behaves like the lowercase a option and
generates a new modules.dep.  This should be faster than blindly doing a
'depmod -a' at each boot.

Dave
--
Dave O'Neill, Senior Linux Consultant
Linuxcare, Inc. tel: (613) 562-9949  fax: (613) 562-9700
dmo at linuxcare.com  http://www.linuxcare.com/



Re: GNU Public Licence

2002-02-01 Thread Dave O'Neill

On Fri, Feb 01, 2002 at 04:48:03PM +0100, Phil Payne wrote:

> It seems quite clear to me that no one can charge extra for a
> distribution that contains their own software, since that is obviously
> a 'work' within the terms of the GNU Public Licence 2(b).

See the bottom of sec. 2 of the GPL:

In addition, mere aggregation of another work not based on the
Program with the Program (or with a work based on the Program) on a
volume of a storage or distribution medium does not bring the other
work under the scope of this License.

I believe Linux distributions qualify as "mere aggregation", and thus there
is no requirement for all of the separate software packages making up a
distribution to be licensed under the GPL.

Cheers,
Dave
(Note:  I'm not a lawyer, this is not legal advice, etc, etc...)
--
Dave O'Neill, Senior Linux Consultant
Linuxcare, Inc. tel: (613) 562-9949  fax: (613) 562-9700
[EMAIL PROTECTED]  http://www.linuxcare.com/



Re: OT: Calendar

2001-12-20 Thread Dave O'Neill

On Thu, Dec 20, 2001 at 12:41:21AM -0500, [EMAIL PROTECTED] wrote:

> In all seriousness, there are other Unix-based tools (like
> the "calendar" program) which would be run daily and send
> little e-mail notices, kind of like a "tickler" (in English,
> I guess, though you could always use Fr...
>
> 
>
> ...uh, well, I'm not sure if that particular tool-set has been
> brought to Linux, but it seems likely.

'Remind' (http://www.roaringpenguin.com/remind.html) can do this as well.

Cheers,
Dave
--
Dave O'Neill, Senior Linux Consultant
Linuxcare, Inc. tel: (613) 562-9949  fax: (613) 562-9700
[EMAIL PROTECTED]  http://www.linuxcare.com/