small script help

2012-08-23 Thread Jack Stone

Running freebsd-7.0

I use a small script in a jail to check if Apache is running and if 
not, restart it.


#!/bin/sh
#if ps -ax | grep -v grep | grep -i httpd
#then
#echo Apache is alive..
#else
#echo Apache is dead, but will be launched.
#/usr/local/etc/rc.d/apache22 start

However, if I want to check the host's Apache, ps -ax sees all of the 
httpd lines including the jail and the host:


(Jail) 83787  ??  SsJ0:07.71 /usr/local/sbin/httpd -DSSL 
-DNOHTTPACCEPT

(host) 98089  ??  Ss32:49.44 /usr/local/sbin/httpd -DNOHTTPACCEPT

How can I modify my script to see only the host based on the bottom 
line above?


Help appreciated!

Jack




___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: small script help

2012-08-23 Thread Frank Reppin

On 24.08.2012 00:57, Jack Stone wrote:
[...]

How can I modify my script to see only the host based on the bottom line
above?

pgrep(1) has an option (-j jid) to either include jails by
given id or to exclude them (-j none).

HTH,
Frank Reppin

--
43rd Law of Computing:
Anything that can go wr
fortune: Segmentation violation -- Core dumped
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: small script help

2012-08-23 Thread Frank Reppin

On 24.08.2012 02:14, Jack Stone wrote:

Thanks, I tried that but pgrep only displayed the PIDs. I guess I wasn't
using proper switches.

Yes - and this should be enough.
If pgrep returns PIDs - then this is the same as 'true' in your
'if' condition - if it returns nothing, the 'else' part is executed:

#!/bin/sh
# * example for Jack with amavisd instead of apache
# * the ^ means 'match from the beginning'
# * so your content for PROCESS_PATTERN would be
#   PROCESS_PATTERN=^/usr/local/sbin/httpd
#   because ps -ax would show you this in the
#   COMMAND row

PROCESS_PATTERN=^/usr/local/sbin/amavisd
PGREP=/bin/pgrep

if ${PGREP} -q -j none -f ^${PROCESS_PATTERN}; then
  echo -e OK
else
  echo -e FAIL
fi

hth,
Frank Reppin



--
43rd Law of Computing:
Anything that can go wr
fortune: Segmentation violation -- Core dumped
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: small script help

2012-08-23 Thread Frank Reppin

There's an errorneous extra ^ in line 6 - please remove this
character.

Fixed version should look like:

#!/bin/sh

PROCESS_PATTERN=^/usr/local/sbin/saslauthd
PGREP=/bin/pgrep

if ${PGREP} -q -j none -f ${PROCESS_PATTERN}; then
  echo -e OK
else
  echo -e FAIL
fi

frank\

--
43rd Law of Computing:
Anything that can go wr
fortune: Segmentation violation -- Core dumped
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: script help

2011-02-16 Thread Peter Andreev
2011/2/15 RW rwmailli...@googlemail.com:
 On Tue, 15 Feb 2011 12:57:12 +0300
 Peter Andreev andreev.pe...@gmail.com wrote:

 Use of xargs on many files will be much faster than find...exec
 construction

 This is a surprisingly common myth. exec can pass single or multiple
 arguments  according to whether you use ; or +

You are right, use of + makes -exec much faster. Thank you, I
didn't know about this feature.

 find / -type f -name copyright.htm | xargs sed -i .bak -e
 's/2010/2011/g'

 This is much less safe on FreeBSD than it is with the GNU versions
 because print0 is required for paths with spaces.

 find  ... -print0 | xargs -0 ...



 ___
 freebsd-questions@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/freebsd-questions
 To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org




-- 
--
AP
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: script help

2011-02-16 Thread Bernt Hansson

2011-02-14 23:34, Jack L. Stone skrev:

Hello folks:


Hello!


No doubt this will be easy for those with scritping abilities.



# find all of the same filenames (copyright.htm) and then replace the year
2010 with 2011 in each file. Once I have a working script, I should be able
to add it as a cron job to run on the first day of each new year.


cd /your/www/directory rm -rf copyright.htm


Any help appreciated.

Thanks!
Jack

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: script help

2011-02-16 Thread Mike Jeays
On Wed, 16 Feb 2011 16:47:57 +0100
Bernt Hansson be...@bah.homeip.net wrote:

 2011-02-14 23:34, Jack L. Stone skrev:
  Hello folks:
 
 Hello!
 
  No doubt this will be easy for those with scritping abilities.
 
  # find all of the same filenames (copyright.htm) and then replace the year
  2010 with 2011 in each file. Once I have a working script, I should be able
  to add it as a cron job to run on the first day of each new year.
 
 cd /your/www/directory rm -rf copyright.htm
 
  Any help appreciated.
 
  Thanks!
  Jack
 ___
 freebsd-questions@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/freebsd-questions
 To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org

I doubt anyone will be dumb enough to fall for this, but it is not exactly 
constructive. Anyhow, it won't work without a semicolon.
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: script help

2011-02-16 Thread Robert Bonomi

 Date: Wed, 16 Feb 2011 16:47:57 +0100
 From: Bernt Hansson be...@bah.homeip.net
 Subject: Re: script help

 2011-02-14 23:34, Jack L. Stone skrev:
  Hello folks:

 Hello!

  No doubt this will be easy for those with scritping abilities.

  # find all of the same filenames (copyright.htm) and then replace the 
  year 2010 with 2011 in each file. Once I have a working script, I 
  should be able to add it as a cron job to run on the first day of each 
  new year.

 cd /your/www/directory 
 rm -rf copyright.htm

(A) doesn't do what the OP asked.
(B) doesn't do what you -think- it does. (i.e., it will delete at most one file)


___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: script help

2011-02-15 Thread perryh
Jack L. Stone ja...@sage-american.com wrote:

 # find all of the same filenames (copyright.htm) and then replace
 the year 2010 with 2011 in each file. Once I have a working
 script, I should be able to add it as a cron job to run on the
 first day of each new year.

Before actually doing this, you might want to consult a copyright
lawyer.  Seems to me that merely claiming a more recent copyright
date, having made no substantive change to the work for which the
copyright is claimed, could be construed as a fraudulent claim.
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: script help

2011-02-15 Thread erikmccaskey64
my little opinion: first run the changes on a backup, or a copy of the files:

this one works under linux bash fedora:
how to create a shadow of a folder [same filenames in another dir, but with 0 
Byte size]


in the original, A directory:
find . -type f gt; a.txt


B directory:
cat ../a.txt | while read file; do if [[ $file = */* ]]; then mkdir -p 
${file%/*}; fi; touch $file; done




so if something goes wrong, there would be no trouble

 Be Mon, 14 Feb 2011 15:11:19 -0800 Adam Vande More 
lt;amvandem...@gmail.comgt; írta  

On Mon, Feb 14, 2011 at 4:34 PM, Jack L. Stone 
lt;ja...@sage-american.comgt;wrote: 
 
gt; Hello folks: 
gt; 
gt; No doubt this will be easy for those with scritping abilities. 
gt; 
gt; I have a gazillion files by the same name and each contains the same line 
gt; requiring the same change. But the problem is that they are in many 
gt; different directories on a server with numerous domains. While I could 
gt; handle the change using a single directory within my abilities, I'm unsure 
gt; how to do a search and replace throughout the many domains and their 
gt; directories. Don't want to mess up. Here's what I'm trying to do: 
gt; 
gt; # find all of the same filenames (copyright.htm) and then replace the year 
gt; 2010 with 2011 in each file. Once I have a working script, I should be 
able 
gt; to add it as a cron job to run on the first day of each new year. 
gt; 
gt; Any help appreciated. 
gt; 
 
/usr/ports/misc/rpl 
 
-- 
Adam Vande More 
___ 
freebsd-questions@freebsd.org mailing list 
http://lists.freebsd.org/mailman/listinfo/freebsd-questions 
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org 
 





___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: script help

2011-02-15 Thread Peter Andreev
Use of xargs on many files will be much faster than find...exec construction

find / -type f -name copyright.htm | xargs sed -i .bak -e 's/2010/2011/g'

2011/2/15 erikmccaskey64 erikmccaske...@zoho.com:
 my little opinion: first run the changes on a backup, or a copy of the files:

 this one works under linux bash fedora:
 how to create a shadow of a folder [same filenames in another dir, but with 
 0 Byte size]


 in the original, A directory:
 find . -type f gt; a.txt


 B directory:
 cat ../a.txt | while read file; do if [[ $file = */* ]]; then mkdir -p 
 ${file%/*}; fi; touch $file; done




 so if something goes wrong, there would be no trouble

  Be Mon, 14 Feb 2011 15:11:19 -0800 Adam Vande More 
 lt;amvandem...@gmail.comgt; írta 

 On Mon, Feb 14, 2011 at 4:34 PM, Jack L. Stone 
 lt;ja...@sage-american.comgt;wrote:

 gt; Hello folks:
 gt;
 gt; No doubt this will be easy for those with scritping abilities.
 gt;
 gt; I have a gazillion files by the same name and each contains the same line
 gt; requiring the same change. But the problem is that they are in many
 gt; different directories on a server with numerous domains. While I could
 gt; handle the change using a single directory within my abilities, I'm 
 unsure
 gt; how to do a search and replace throughout the many domains and their
 gt; directories. Don't want to mess up. Here's what I'm trying to do:
 gt;
 gt; # find all of the same filenames (copyright.htm) and then replace the 
 year
 gt; 2010 with 2011 in each file. Once I have a working script, I should be 
 able
 gt; to add it as a cron job to run on the first day of each new year.
 gt;
 gt; Any help appreciated.
 gt;

 /usr/ports/misc/rpl

 --
 Adam Vande More
 ___
 freebsd-questions@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/freebsd-questions
 To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org






 ___
 freebsd-questions@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/freebsd-questions
 To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org




-- 
--
AP
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: script help

2011-02-15 Thread Jack L. Stone
At 12:41 AM 2/15/2011 -0800, per...@pluto.rain.com wrote:
Jack L. Stone ja...@sage-american.com wrote:

 # find all of the same filenames (copyright.htm) and then replace
 the year 2010 with 2011 in each file. Once I have a working
 script, I should be able to add it as a cron job to run on the
 first day of each new year.

Before actually doing this, you might want to consult a copyright
lawyer.  Seems to me that merely claiming a more recent copyright
date, having made no substantive change to the work for which the
copyright is claimed, could be construed as a fraudulent claim.
___

Wow! You wandered way off the trail. I own the tech magazine I founded 23
years ago and we publish monthly to 214 countries. I hav also practiced law
for my companies for nearly 40 years, so quit worrying about that stuff.

I just need script help, not other than that.

Jack

(^_^)
Happy trails,
Jack L. Stone

System Admin
Sage-american
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: script help

2011-02-15 Thread Julian H. Stacey
Hi,
per...@pluto.rain.com wrote:
 Jack L. Stone ja...@sage-american.com wrote:
 
  # find all of the same filenames (copyright.htm) and then replace
  the year 2010 with 2011 in each file. Once I have a working
  script, I should be able to add it as a cron job to run on the
  first day of each new year.
 
 Before actually doing this, you might want to consult a copyright
 lawyer.  Seems to me that merely claiming a more recent copyright
 date, having made no substantive change to the work for which the
 copyright is claimed, could be construed as a fraudulent claim.

One might also want to Not delete the earliest Copyright date.

Numerous commercial firms lists several copyright years in same
file or product start up.  

When I was editing some of my stuff recently, I decided to leave
first  last year in, dont know if thats correct though.

I suppose if one really wanted to know what's correct, one could search
 read Bern (Switzerland) International Copyright Convention.

Cheers,
Julian
-- 
Julian Stacey, BSD Unix Linux C Sys Eng Consultants Munich http://berklix.com
 Mail plain text;  Not quoted-printable, Not HTML, Not base 64.
 Reply below text sections not at top, to avoid breaking cumulative context.
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: script help

2011-02-15 Thread RW
On Tue, 15 Feb 2011 12:57:12 +0300
Peter Andreev andreev.pe...@gmail.com wrote:

 Use of xargs on many files will be much faster than find...exec
 construction

This is a surprisingly common myth. exec can pass single or multiple
arguments  according to whether you use ; or + 
 
 find / -type f -name copyright.htm | xargs sed -i .bak -e
 's/2010/2011/g'

This is much less safe on FreeBSD than it is with the GNU versions
because print0 is required for paths with spaces.

find  ... -print0 | xargs -0 ...



___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: script help

2011-02-15 Thread Jack L. Stone
At 02:53 PM 2/15/2011 +, RW wrote:
On Tue, 15 Feb 2011 12:57:12 +0300
Peter Andreev andreev.pe...@gmail.com wrote:

 Use of xargs on many files will be much faster than find...exec
 construction

This is a surprisingly common myth. exec can pass single or multiple
arguments  according to whether you use ; or + 
 
 find / -type f -name copyright.htm | xargs sed -i .bak -e
 's/2010/2011/g'

This is much less safe on FreeBSD than it is with the GNU versions
because print0 is required for paths with spaces.

find  ... -print0 | xargs -0 ...



Forgot to mention: if the string to replace on the text line of the files
includes a connecting dash, like 1988-2010, I suppose rather than using
just the 2010/2011 perhaps should be 1988-2010/1988-2011

Jack

(^_^)
Happy trails,
Jack L. Stone

System Admin
Sage-american
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: script help

2011-02-15 Thread Paul Schmehl
--On February 15, 2011 12:57:12 PM +0300 Peter Andreev 
andreev.pe...@gmail.com wrote:



Use of xargs on many files will be much faster than find...exec
construction

find / -type f -name copyright.htm | xargs sed -i .bak -e 's/2010/2011/g'



I believe you, but can you explain why this is true?  What makes xargs 
faster than exec?


--
Paul Schmehl, Senior Infosec Analyst
As if it wasn't already obvious, my opinions
are my own and not those of my employer.
***
It is as useless to argue with those who have
renounced the use of reason as to administer
medication to the dead. Thomas Jefferson
There are some ideas so wrong that only a very
intelligent person could believe in them. George Orwell

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: script help

2011-02-15 Thread Lowell Gilbert
Paul Schmehl pschmehl_li...@tx.rr.com writes:

 --On February 15, 2011 12:57:12 PM +0300 Peter Andreev
 andreev.pe...@gmail.com wrote:

 Use of xargs on many files will be much faster than find...exec
 construction

 find / -type f -name copyright.htm | xargs sed -i .bak -e 's/2010/2011/g'


 I believe you, but can you explain why this is true?  What makes xargs
 faster than exec?

Classically, exec always spun off a new process for each exec (i.e.,
every single file).

For years now, find(1) has had a POSIX-standard syntax (ending the
command with a '+' syntax for the end of an -exec line, which does
pretty much the same thing in a single command.

Sometimes, the command being used only handles one filename at a time,
and -exec is necessary.
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


script help

2011-02-14 Thread Jack L. Stone
Hello folks:

No doubt this will be easy for those with scritping abilities.

I have a gazillion files by the same name and each contains the same line
requiring the same change. But the problem is that they are in many
different directories on a server with numerous domains. While I could
handle the change using a single directory within my abilities, I'm unsure
how to do a search and replace throughout the many domains and their
directories. Don't want to mess up. Here's what I'm trying to do:

# find all of the same filenames (copyright.htm) and then replace the year
2010 with 2011 in each file. Once I have a working script, I should be able
to add it as a cron job to run on the first day of each new year.

Any help appreciated.

Thanks!
Jack

(^_^)
Happy trails,
Jack L. Stone

System Admin
Sage-american
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: script help

2011-02-14 Thread Roland Smith
On Mon, Feb 14, 2011 at 04:34:37PM -0600, Jack L. Stone wrote:
 # find all of the same filenames (copyright.htm) and then replace the year
 2010 with 2011 in each file. Once I have a working script, I should be able
 to add it as a cron job to run on the first day of each new year.

The following command should do the trick, I think.

find / -type f -name copyright.htm -exec sed -i .bak -e 's/Copyright © 
20../Copyright © 2011/g' {} \;

Basically the find(1) command locates the files you want to change, and than
for every file it calls sed(1) with the -i flag to do the in-place
editing. The originals are saved as copyright.htm.bak. If all goes well, you
can delete those.

Depending on the contents of the files, you might want to just replace 2010 by
2011, or use a little more context as I did in the example, to make sure only
the right numbers are replaced.

Roland
-- 
R.F.Smith   http://www.xs4all.nl/~rsmith/
[plain text _non-HTML_ PGP/GnuPG encrypted/signed email much appreciated]
pgp: 1A2B 477F 9970 BA3C 2914  B7CE 1277 EFB0 C321 A725 (KeyID: C321A725)


pgpW28cbNfx6P.pgp
Description: PGP signature


Re: script help

2011-02-14 Thread Chip Camden
Quoth Jack L. Stone on Monday, 14 February 2011:
 Hello folks:
 
 No doubt this will be easy for those with scritping abilities.
 
 I have a gazillion files by the same name and each contains the same line
 requiring the same change. But the problem is that they are in many
 different directories on a server with numerous domains. While I could
 handle the change using a single directory within my abilities, I'm unsure
 how to do a search and replace throughout the many domains and their
 directories. Don't want to mess up. Here's what I'm trying to do:
 
 # find all of the same filenames (copyright.htm) and then replace the year
 2010 with 2011 in each file. Once I have a working script, I should be able
 to add it as a cron job to run on the first day of each new year.
 
 Any help appreciated.
 
 Thanks!
 Jack
 
 (^_^)
 Happy trails,
 Jack L. Stone
 
 System Admin
 Sage-american
 ___
 freebsd-questions@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/freebsd-questions
 To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org

find /upper-dir -name copyright.htm -exec sed -i '' -e s/2010/2011/g {} \;

-- 
Sterling (Chip) Camden | sterl...@camdensoftware.com | 2048D/3A978E4F
http://chipsquips.com  | http://camdensoftware.com   | http://chipstips.com


pgpNijFWKcFpE.pgp
Description: PGP signature


Re: script help

2011-02-14 Thread Jarrod Slick

On 2/14/11 3:34 PM, Jack L. Stone wrote:

Hello folks:

No doubt this will be easy for those with scritping abilities.

I have a gazillion files by the same name and each contains the same line
requiring the same change. But the problem is that they are in many
different directories on a server with numerous domains. While I could
handle the change using a single directory within my abilities, I'm unsure
how to do a search and replace throughout the many domains and their
directories. Don't want to mess up. Here's what I'm trying to do:

# find all of the same filenames (copyright.htm) and then replace the year
2010 with 2011 in each file. Once I have a working script, I should be able
to add it as a cron job to run on the first day of each new year.

Any help appreciated.

Thanks!
Jack

(^_^)
Happy trails,
Jack L. Stone

System Admin
Sage-american
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org

Something like this should work (*UNTESTED*):

#!/usr/bin/perl
use strict;
use warnings;
use File::Find;

my @directories = qw(/var/www/html /var/www/html2 /etc); #if you don't 
know all the directories and are okay with the script running for a 
while you could just specify /
my $line = quotemeta(Copyright 2010); # Or whatever your line actually 
is . . .

my $copyright_file = quotemeta(copyright.htm);
find(\wanted, @directories);

sub wanted {
if($_ =~ $copyright_file) {
open(my $fh, '', $File::Find::dir.'/'.$copyright_file) or die 
Couldn't create read handle: $!\n;

my $new_file = undef;
while($fh) {
if($_ =~ /^$line$/) {
$_ =~ s/2010/2011/;
}
$new_file .= $_.\n;
}
close($fh);
open($fh, '', $File::Find::dir.'/'.$copyright_file) or die 
Couldn't create write handle: $!\n;

print $fh $new_file;
close($fh);
}
}
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: script help

2011-02-14 Thread Adam Vande More
On Mon, Feb 14, 2011 at 4:34 PM, Jack L. Stone ja...@sage-american.comwrote:

 Hello folks:

 No doubt this will be easy for those with scritping abilities.

 I have a gazillion files by the same name and each contains the same line
 requiring the same change. But the problem is that they are in many
 different directories on a server with numerous domains. While I could
 handle the change using a single directory within my abilities, I'm unsure
 how to do a search and replace throughout the many domains and their
 directories. Don't want to mess up. Here's what I'm trying to do:

 # find all of the same filenames (copyright.htm) and then replace the year
 2010 with 2011 in each file. Once I have a working script, I should be able
 to add it as a cron job to run on the first day of each new year.

 Any help appreciated.


/usr/ports/misc/rpl

-- 
Adam Vande More
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: script help

2011-02-14 Thread Chuck Swiger
On Feb 14, 2011, at 2:34 PM, Jack L. Stone wrote:
 # find all of the same filenames (copyright.htm) and then replace the year
 2010 with 2011 in each file. Once I have a working script, I should be able
 to add it as a cron job to run on the first day of each new year.

  find . -name copyright.htm -exec sed -i .BAK s/2010/2011/ {} \;

Of course, a purely automated replacement of the year without making any other 
change is likely considered de minimus from a copyright perspective.  You'd 
need to make a more substantial change involving some original content for this 
to be genuinely meaningful

Regards,
-- 
-Chuck

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Bash Script Help - File Names With Spaces

2010-08-17 Thread Drew Tomlinson
I have a collection of yearly top 100 Billboard mp3s in this format (all 
one line - sorry if it wraps):


/archive/Multimedia/Audio/Music/Billboard Top USA Singles/1980-028 Kenny 
Loggins - This Is It.mp3


I want to create symbolic links to the top 30 in 1966-1969 in another 
directory for easy migration to a flash card. Thus I invoked 'find' to 
get a list (again, all one line):


find -E /archive/Multimedia/Audio/Music/Billboard Top USA Singles 
-regex '.*19[6-9][0-9]-0[0-2][0-9].*'


(OK, I know this will only return the top 29)

'find' returns the complete filename as above:

/archive/Multimedia/Audio/Music/Billboard Top USA Singles/1980-028 Kenny 
Loggins - This Is It.mp3


Then I attempt to use 'basename' to extract the file name to a variable 
which I can later pass to 'ln'.  This seems to work:


basename /archive/Multimedia/Audio/Music/Billboard Top USA 
Singles/1980-028 Kenny Loggins - This Is It.mp3


returns (all one line):

1980-028 Kenny Loggins - This Is It.mp3

which is what I would expect.  However using it with 'find' give me this 
type of unexpected result:


for i in `find -E /archive/Multimedia/Audio/Music/Billboard Top USA 
Singles -regex '.*19[6-9][0-9]-0[1-2][0-9].*'`; do basename ${i};done


1980-028
Kenny
Loggins
-
This
Is
It.mp3

Why is this different? And more importantly, how can I capture the file 
name to $i?


Thanks,

Drew

--
Like card tricks?

Visit The Alchemist's Warehouse to
learn card magic secrets for free!

http://alchemistswarehouse.com

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: Bash Script Help - File Names With Spaces

2010-08-17 Thread Chip Camden
Quoth Drew Tomlinson on Tuesday, 17 August 2010:
 I have a collection of yearly top 100 Billboard mp3s in this format (all 
 one line - sorry if it wraps):
 
 /archive/Multimedia/Audio/Music/Billboard Top USA Singles/1980-028 Kenny 
 Loggins - This Is It.mp3
 
 I want to create symbolic links to the top 30 in 1966-1969 in another 
 directory for easy migration to a flash card. Thus I invoked 'find' to 
 get a list (again, all one line):
 
 find -E /archive/Multimedia/Audio/Music/Billboard Top USA Singles 
 -regex '.*19[6-9][0-9]-0[0-2][0-9].*'
 
 (OK, I know this will only return the top 29)
 
 'find' returns the complete filename as above:
 
 /archive/Multimedia/Audio/Music/Billboard Top USA Singles/1980-028 Kenny 
 Loggins - This Is It.mp3
 
 Then I attempt to use 'basename' to extract the file name to a variable 
 which I can later pass to 'ln'.  This seems to work:
 
 basename /archive/Multimedia/Audio/Music/Billboard Top USA 
 Singles/1980-028 Kenny Loggins - This Is It.mp3
 
 returns (all one line):
 
 1980-028 Kenny Loggins - This Is It.mp3
 
 which is what I would expect.  However using it with 'find' give me this 
 type of unexpected result:
 
 for i in `find -E /archive/Multimedia/Audio/Music/Billboard Top USA 
 Singles -regex '.*19[6-9][0-9]-0[1-2][0-9].*'`; do basename ${i};done
 
 1980-028
 Kenny
 Loggins
 -
 This
 Is
 It.mp3
 
 Why is this different? And more importantly, how can I capture the file 
 name to $i?

Try:

find -E ... | while read i; do; basename $i; done

When using back-ticks, all the output gets appended together,
space-separated.  Then 'for' can't tell the difference between a space in
a filename and a delimiter.  Using 'read' instead preserves line
boundaries.

 
 Thanks,
 
 Drew
 
 -- 
 Like card tricks?
 
 Visit The Alchemist's Warehouse to
 learn card magic secrets for free!
 
 http://alchemistswarehouse.com
 
 ___
 freebsd-questions@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/freebsd-questions
 To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org

-- 
Sterling (Chip) Camden| sterl...@camdensoftware.com | 2048D/3A978E4F
http://camdensoftware.com | http://chipstips.com| http://chipsquips.com


pgpCHrUZ30LlM.pgp
Description: PGP signature


Re: Bash Script Help - File Names With Spaces -- SOLVED

2010-08-17 Thread Drew Tomlinson

On 8/17/2010 7:47 AM, Drew Tomlinson wrote:
I have a collection of yearly top 100 Billboard mp3s in this format 
(all one line - sorry if it wraps):


/archive/Multimedia/Audio/Music/Billboard Top USA Singles/1980-028 
Kenny Loggins - This Is It.mp3


I want to create symbolic links to the top 30 in 1966-1969 in another 
directory for easy migration to a flash card. Thus I invoked 'find' to 
get a list (again, all one line):


find -E /archive/Multimedia/Audio/Music/Billboard Top USA Singles 
-regex '.*19[6-9][0-9]-0[0-2][0-9].*'


(OK, I know this will only return the top 29)

'find' returns the complete filename as above:

/archive/Multimedia/Audio/Music/Billboard Top USA Singles/1980-028 
Kenny Loggins - This Is It.mp3


Then I attempt to use 'basename' to extract the file name to a 
variable which I can later pass to 'ln'.  This seems to work:


basename /archive/Multimedia/Audio/Music/Billboard Top USA 
Singles/1980-028 Kenny Loggins - This Is It.mp3


returns (all one line):

1980-028 Kenny Loggins - This Is It.mp3

which is what I would expect.  However using it with 'find' give me 
this type of unexpected result:


for i in `find -E /archive/Multimedia/Audio/Music/Billboard Top USA 
Singles -regex '.*19[6-9][0-9]-0[1-2][0-9].*'`; do basename ${i};done


1980-028
Kenny
Loggins
-
This
Is
It.mp3

Why is this different? And more importantly, how can I capture the 
file name to $i?


It finally occurred to me that I needed the shell to see a new line as 
the delimiter and not whitespace. Then a simple search revealed my answer:


O=$IFS
IFS=$(echo -en \n\b)
do stuff
IFS=$O

Sorry for the noise.

Drew

--
Like card tricks?

Visit The Alchemist's Warehouse to
learn card magic secrets for free!

http://alchemistswarehouse.com

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: Bash Script Help - File Names With Spaces

2010-08-17 Thread Drew Tomlinson

On 8/17/2010 8:22 AM, Chip Camden wrote:

Quoth Drew Tomlinson on Tuesday, 17 August 2010:
   

I have a collection of yearly top 100 Billboard mp3s in this format (all
one line - sorry if it wraps):

/archive/Multimedia/Audio/Music/Billboard Top USA Singles/1980-028 Kenny
Loggins - This Is It.mp3

I want to create symbolic links to the top 30 in 1966-1969 in another
directory for easy migration to a flash card. Thus I invoked 'find' to
get a list (again, all one line):

find -E /archive/Multimedia/Audio/Music/Billboard Top USA Singles
-regex '.*19[6-9][0-9]-0[0-2][0-9].*'

(OK, I know this will only return the top 29)

'find' returns the complete filename as above:

/archive/Multimedia/Audio/Music/Billboard Top USA Singles/1980-028 Kenny
Loggins - This Is It.mp3

Then I attempt to use 'basename' to extract the file name to a variable
which I can later pass to 'ln'.  This seems to work:

basename /archive/Multimedia/Audio/Music/Billboard Top USA
Singles/1980-028 Kenny Loggins - This Is It.mp3

returns (all one line):

1980-028 Kenny Loggins - This Is It.mp3

which is what I would expect.  However using it with 'find' give me this
type of unexpected result:

for i in `find -E /archive/Multimedia/Audio/Music/Billboard Top USA
Singles -regex '.*19[6-9][0-9]-0[1-2][0-9].*'`; do basename ${i};done

1980-028
Kenny
Loggins
-
This
Is
It.mp3

Why is this different? And more importantly, how can I capture the file
name to $i?
 

Try:

find -E ... | while read i; do; basename $i; done

When using back-ticks, all the output gets appended together,
space-separated.  Then 'for' can't tell the difference between a space in
a filename and a delimiter.  Using 'read' instead preserves line
boundaries.


Thanks for your reply.  I like this better than manipulating $IFS 
because then I don't have to set it back.


Cheers,

Drew

--
Like card tricks?

Visit The Alchemist's Warehouse to
learn card magic secrets for free!

http://alchemistswarehouse.com

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: Bash Script Help - File Names With Spaces

2010-08-17 Thread Timm Wimmers
Am Dienstag, den 17.08.2010, 08:22 -0700 schrieb Chip Camden:
 find -E ... | while read i; do; basename $i; done

The semicolon behind do isn't necessary.

-- 
Timm

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: Bash Script Help - File Names With Spaces

2010-08-17 Thread Karl Vogel
 On Tue, 17 Aug 2010 07:47:25 -0700, 
 Drew Tomlinson d...@mykitchentable.net said:

D Then I attempt to use 'basename' to extract the file name to a variable
D which I can later pass to 'ln'.  This seems to work:
D   basename /archive/Multimedia/Audio/Music/Billboard Top USA
D   Singles/1980-028 Kenny Loggins - This Is It.mp3

   This is a subset of a larger problem: getting the last field from a set
   of delimited records which may not all have the same number of fields.

   I've used this when I needed basenames for ~500,000 files:
 find . regex-or-print-or-whatever | rev | cut -f1 -d/ | rev

   For dirnames:
 find . regex-or-print-or-whatever | rev | cut -f2- -d/ | rev | sort -u

-- 
Karl Vogel  I don't speak for the USAF or my company

When I'm feeling down, I like to whistle.  It makes the
neighbor's dog run to the end of his chain and gag himself.--unknown
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: Bash Script Help - File Names With Spaces -- SOLVED

2010-08-17 Thread Anonymous
Drew Tomlinson d...@mykitchentable.net writes:

 It finally occurred to me that I needed the shell to see a new line as
 the delimiter and not whitespace. Then a simple search revealed my
 answer:

 O=$IFS
 IFS=$(echo -en \n\b)
 do stuff
 IFS=$O

Old IFS value can be preserved by using `local' keyword or (...) braces, too.
It's a bit better than polluting global scope with temporary variable.

  $ echo -n $IFS | (vis -w; echo)
  \040\^I\^J

  $ for i in $(find . -type f); do echo $i; done
  ./My
  Long
  File
  Name
  ./Another
  File

  $ f() { local IFS=; eval $@; }
  $ f 'for i in $(find . -type f); do echo $i; done'
  ./My Long File Name
  ./Another File

  $ (IFS=; for i in $(find . -type f); do echo $i; done)
  ./My Long File Name
  ./Another File

  $ echo -n $IFS | (vis -w; echo)
  \040\^I\^J
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


script help

2006-09-05 Thread ann kok
Hi all

I would like to ask script question

1/ if i use the script to run within 1 minute, I can't
run it in the cronjob. how can I run this script
automatically?

2/ I have file file.txt as below, there are two
fields.

4 999
10 200
15 400
60 900

I write awk script to exact field 2 if the field 1
less than 10 and put it in the file result.txt. but
i am not successful!

awk '{
if ($1  10)
$2=this is result $2 when the feild 1 less than 10
}'  file.txt  result.txt

result.txt

this is result $2 when the feild 1 less than 10
this is result $2 when the feild 1 less than 10


but i would like the result as

this is result 999 when the feild 1 less than 10
this is result 200 when the feild 1 less than 10

Thank you for your help











__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: script help

2006-09-05 Thread Paul Schmehl



--On Tuesday, September 05, 2006 11:16:26 -0700 ann kok 
[EMAIL PROTECTED] wrote:



Hi all

I would like to ask script question

1/ if i use the script to run within 1 minute, I can't
run it in the cronjob. how can I run this script
automatically?

I don't understand what you mean here.  Are you asking how to run a cronjob 
more than once a minute?



2/ I have file file.txt as below, there are two
fields.

4 999
10 200
15 400
60 900

I write awk script to exact field 2 if the field 1
less than 10 and put it in the file result.txt. but
i am not successful!

awk '{
if ($1  10)
$2=this is result $2 when the feild 1 less than 10
}'  file.txt  result.txt

result.txt

this is result $2 when the feild 1 less than 10
this is result $2 when the feild 1 less than 10


but i would like the result as

this is result 999 when the feild 1 less than 10
this is result 200 when the feild 1 less than 10


awk '{
if ($1  10)
$2=this is result $2 when the feild 1 less than 10
}'  file.txt  result.txt

If you want awk to return the value of $2, don't quote it.

Paul Schmehl ([EMAIL PROTECTED])
Adjunct Information Security Officer
The University of Texas at Dallas
http://www.utdallas.edu/ir/security/


Re: script help

2006-09-05 Thread ann kok
Dear Paul

Thank you for your mail

I want to run a script xx seconds automatically

but cronjob is limited minutes

Thank you

--- Paul Schmehl [EMAIL PROTECTED] wrote:

 
 
 --On Tuesday, September 05, 2006 11:16:26 -0700 ann
 kok 
 [EMAIL PROTECTED] wrote:
 
  Hi all
 
  I would like to ask script question
 
  1/ if i use the script to run within 1 minute, I
 can't
  run it in the cronjob. how can I run this script
  automatically?
 
 I don't understand what you mean here.  Are you
 asking how to run a cronjob 
 more than once a minute?
 
  2/ I have file file.txt as below, there are two
  fields.
 
  4 999
  10 200
  15 400
  60 900
 
  I write awk script to exact field 2 if the field
 1
  less than 10 and put it in the file result.txt.
 but
  i am not successful!
 
  awk '{
  if ($1  10)
  $2=this is result $2 when the feild 1 less than
 10
  }'  file.txt  result.txt
 
  result.txt
 
  this is result $2 when the feild 1 less than 10
  this is result $2 when the feild 1 less than 10
 
 
  but i would like the result as
 
  this is result 999 when the feild 1 less than 10
  this is result 200 when the feild 1 less than 10
 
 awk '{
  if ($1  10)
 $2=this is result $2 when the feild 1 less than
 10
  }'  file.txt  result.txt
 
 If you want awk to return the value of $2, don't
 quote it.
 
 Paul Schmehl ([EMAIL PROTECTED])
 Adjunct Information Security Officer
 The University of Texas at Dallas
 http://www.utdallas.edu/ir/security/
 


__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: script help

2006-09-05 Thread Paul Schmehl
--On Tuesday, September 05, 2006 15:36:09 -0700 ann kok 
[EMAIL PROTECTED] wrote:



Dear Paul

Thank you for your mail

I want to run a script xx seconds automatically

but cronjob is limited minutes

That's correct.  The fastest you can run a cron job is every minute because 
that's how often cron checks for jobs.


Paul Schmehl ([EMAIL PROTECTED])
Adjunct Information Security Officer
The University of Texas at Dallas
http://www.utdallas.edu/ir/security/


Re: script help

2006-09-05 Thread Frank Shute
On Tue, Sep 05, 2006 at 03:36:09PM -0700, ann kok wrote:

 Dear Paul
 
 Thank you for your mail
 
 I want to run a script xx seconds automatically
 
 but cronjob is limited minutes
 
 Thank you

I think what you're after is sleep(1)

-- 

 Frank 


echo f r a n k @ e s p e r a n c e - l i n u x . c o . u k | sed 's/ //g'

  ---PGP keyID: 0x10BD6F4B---  
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: Need /bin/sh script help

2006-04-12 Thread Garrett Cooper

Garrett Cooper wrote:


Hello again all,
   Just making a series of sh scripts to help automate updating and 
whatnot of my fileserver (since I am trying to avoid having mistakes 
occur with my system, and maybe help the community out a bit by 
providing some decent means of updating their own machines), and I was 
wondering if anyone could help me out with the following script I've 
developing (the grep if statements are incorrect..):


#!/bin/sh
#

KC=;

cd /usr/src;

if [ -n `grep -e s/KERNCONF=/ /etc/make.conf` ] # want to look for 
KERNCONF in /etc/make.conf

then
   echo enter in the kernel conf file full pathname:;
   read KERNCONF;
   KC=KERNCONF=$KERNCONF;
fi

if [ -n `grep -e s/NO_CLEAN=*yes*/ /etc/make.conf` ] // want to look 
for NO_CLEAN in /etc/make.conf -- is this really necessary?

then
   cd sys;
   echo cleaning sources
   make clean;
   make cleandir;
   cd ..;
fi

echo building kernel;
make buildkernel $KC;

echo installing kernel;
make installkernel $KC;

echo kernel compile complete. reboot to try new kernel;

TIA,
-Garrett

Thank you all for the replies and the advice. I still need to fix the 
grepping, but I hope that any and all problems will be resolved soon 
once I stick my mind to it. As for what worked and was changed, what 
didn't, and why I am doing this:


What worked/was changed:
-Removing C++ style comment. Lol.
-Adding in a loop for read so the kernconf variable is not set to null.

What didn't work:
-Using make -V (it came up with nothing... oddly enough even though the 
manpage said it would work).
-grep call when I didn't redirect stuff to stderr (suppose I should do 
that).


Why I am doing this:
If you're probably reading the mailing list from time to time, you'll 
have noticed I had some issues last week with cvsup and my system 
sources. I've basically come to the conclusion that the cause for my 
issue is the fact that I had a cron job which would update my 
system/kernel sources, as well as my ports, and my system/kernel sources 
were synced DURING a build, which lead to quite a few issues with the 
build and installworld, I discovered after rebooting the machine the 
next morning (no errors were encountered though, which was odd). So, in 
order to scratch the itch, persay, that exists with cvsup and building 
ports/compiling system stuff, I have created a script which does 'lock' 
a process, if noted correctly, with a 'semaphore lockfile'. Maybe a call 
to ps aux would be better, but I found that dealing with a lockfile 
system would be a much easier way to solve things.


Todo Plan:
Add an rc-script or something that will run in single-user mode which 
will help with mergemaster. People should be at the machine when doing 
this, and my scripts were originally designed so that a person could 
just run the script and it would do function X on a timed basis (say as 
a cron job).


These scripts aren't meant to replace any resources; they're just here 
to help automate junk and ensure that things DO get done properly and 
things DO get updated, with less typing and command memorizing for the 
admin (I will properly annotate which chapters in the handbook to use 
and manpages to read for a more in depth reference of what the script 
does and how it does it).


Furthermore, I plan on possibly coming out with a more up to date 
installcd setup that would have an 'admin pack' as I would call it, or 
apache, bind9, perl, mysql, ipfw, samba, etc, properly configured with a 
set of CGI pages that would help simplify system management for people 
(I am doing this as a project for the house/apt I'm living in since they 
need a NAT box with extras).


So, that's what I have in mind.

Questions, comments :) ?

-Garrett
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: Need /bin/sh script help

2006-04-11 Thread RW
On Tuesday 11 April 2006 06:30, Garrett Cooper wrote:

 cd /usr/src;
 if [ -n `grep -e s/KERNCONF=/ /etc/make.conf` ] # want to look for
 KERNCONF in /etc/make.conf

if [ `make -V KERNCONF`  ]

 read KERNCONF;
 KC=KERNCONF=$KERNCONF;
 fi

You need to check that KC actually exists. IIRC a typo will cause GENERIC to 
build.
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: Need /bin/sh script help

2006-04-11 Thread Parv
in message [EMAIL PROTECTED],
wrote Garrett Cooper thusly...

 I was wondering if anyone could help me out with the following
 script I've developing (the grep if statements are incorrect..):
 
 #!/bin/sh
 #
 
 KC=;
 
 cd /usr/src;
 
 if [ -n `grep -e s/KERNCONF=/ /etc/make.conf` ] # want to look for 

Well, you did not write what exactly is the problem, as executing
the above works as expected.  Why do have 'KERNCONF' surrounded by
's/'  '/'?


In any case, there is not need to see if the returned string length
is nonzero.  Just use the grep return code  send the all the output
to /dev/null ...

  if grep -e '^KERNCONF=' /etc/make.conf /dev/null 21
  then
...
  fi


... or you could also use '-q' and/or '-s' grep options instead of
sending output to /dev/null.  (I personally would do a bit more
strict check to see $KERNCONF is set to value containing characters
meeting some criteria, say '\[-._[:alnum:]]+\'.)


 KERNCONF in /etc/make.conf
 then
echo enter in the kernel conf file full pathname:;

I did not know one can specify the kernel configuration path, not
just the basename.


read KERNCONF;
KC=KERNCONF=$KERNCONF;
 fi
 
 if [ -n `grep -e s/NO_CLEAN=*yes*/ /etc/make.conf` ] // want to look for 
   ^^
   ^^
Wrong kind of comment
character.

See above comments about grep(1) usage.


  - Parv

-- 

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: Need /bin/sh script help

2006-04-11 Thread [EMAIL PROTECTED]
On  Mon, 10 Apr 2006 22:30:32 -0700  Garrett Cooper wrote (my brief response 
follows all of his text):

Just making a series of sh scripts to help automate updating and 
whatnot of my fileserver (since I am trying to avoid having mistakes 
occur with my system, and maybe help the community out a bit by 
providing some decent means of updating their own machines), and I was 
wondering if anyone could help me out with the following script I've 
developing (the grep if statements are incorrect..):

#!/bin/sh
#

KC=;

cd /usr/src;

if [ -n `grep -e s/KERNCONF=/ /etc/make.conf` ] # want to look for 
KERNCONF in /etc/make.conf
then
echo enter in the kernel conf file full pathname:;
read KERNCONF;
KC=KERNCONF=$KERNCONF;
fi

if [ -n `grep -e s/NO_CLEAN=*yes*/ /etc/make.conf` ] // want to look for 
NO_CLEAN in /etc/make.conf -- is this really necessary?
then
cd sys;
echo cleaning sources
make clean;
make cleandir;
cd ..;
fi

echo building kernel;
make buildkernel $KC;

echo installing kernel;
make installkernel $KC;

echo kernel compile complete. reboot to try new kernel;

TIA,
-Garrett

I see a problem in the line
if [ -n `grep -e s/KERNCONF=/ /etc/make.conf` ] # want to look for 
you should have double-quotes around the  `grep  ...  conf`
because it is likely to produce more than one token and so the
 [ -n  ... ]  statement violates the syntax (there should be exactly 1 token 
between the  -n  and the  ] , even no token there is an error, the way that is 
handled is to quote it.
I am writing this quickly without bringing up my  FreeBSD  system to check it.  
Good luck.

Another thing you can do to avoid quoting (and the long strings that may 
result) is use the  -c  option of  grep  and check the number resulting.

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: Need /bin/sh script help

2006-04-11 Thread Jan Grant
On Tue, 11 Apr 2006, [EMAIL PROTECTED] wrote:

 On  Mon, 10 Apr 2006 22:30:32 -0700  Garrett Cooper wrote (my brief response 
 follows all of his text):
 
 Just making a series of sh scripts to help automate updating and 
 whatnot of my fileserver (since I am trying to avoid having mistakes 
 occur with my system, and maybe help the community out a bit by 
 providing some decent means of updating their own machines), and I was 
 wondering if anyone could help me out with the following script I've 
 developing (the grep if statements are incorrect..):

 I see a problem in the line
 if [ -n `grep -e s/KERNCONF=/ /etc/make.conf` ] # want to look for 
 you should have double-quotes around the  `grep  ...  conf`
 because it is likely to produce more than one token and so the
  [ -n ... ] statement violates the syntax (there should be exactly 1 
 token between the -n and the ] , even no token there is an error, the 
 way that is handled is to quote it. I am writing this quickly without 
 bringing up my FreeBSD system to check it.  Good luck.

Or simply use the error status of grep, no [ invocation:

if grep -q ...
then
...
fi

Note that if you're looking at automating the update process you should 
probably pay careful attention to the world/kernel update process 
described in the handbook; there are steps (like an initial mergemaster 
-p) that you will want to include.

-- 
jan grant, ISYS, University of Bristol. http://www.bris.ac.uk/
Tel +44 (0)117 3317661   http://ioctl.org/jan/
If you have received this email in error, do whatever the hell
you want with it. It's not like I can stop you anyway.
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Need /bin/sh script help

2006-04-10 Thread Garrett Cooper

Hello again all,
   Just making a series of sh scripts to help automate updating and 
whatnot of my fileserver (since I am trying to avoid having mistakes 
occur with my system, and maybe help the community out a bit by 
providing some decent means of updating their own machines), and I was 
wondering if anyone could help me out with the following script I've 
developing (the grep if statements are incorrect..):


#!/bin/sh
#

KC=;

cd /usr/src;

if [ -n `grep -e s/KERNCONF=/ /etc/make.conf` ] # want to look for 
KERNCONF in /etc/make.conf

then
   echo enter in the kernel conf file full pathname:;
   read KERNCONF;
   KC=KERNCONF=$KERNCONF;
fi

if [ -n `grep -e s/NO_CLEAN=*yes*/ /etc/make.conf` ] // want to look for 
NO_CLEAN in /etc/make.conf -- is this really necessary?

then
   cd sys;
   echo cleaning sources
   make clean;
   make cleandir;
   cd ..;
fi

echo building kernel;
make buildkernel $KC;

echo installing kernel;
make installkernel $KC;

echo kernel compile complete. reboot to try new kernel;

TIA,
-Garrett
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Shell Script Help

2006-01-29 Thread Angelo Christou
Hello, I am running FreeBSD 6.0 with Bash as my shell. I am trying to automate 
a task and I have been reading a lot about Bash, but I haven't been able to get 
a script working.

I have a program that I need to pass 3 variables. I have a text file called 
list.txt that has the variables separated by a space. There are hundreds of 
lines which is why I am trying to automate this. I'd like to learn shell too :)

list.txt contains:

bob home 9002
jim data 9005
sarah backup 4001
john temp 3001
 
(it's in the format var1 var2 var3)

Running the following for each line is what I'm trying to do:
myprogram bob home 9002
myprogram jim data 9005
and so on..

I need to pass the variables in list.txt to my program. From the docs on shell 
scripting I have been reading, I think I need to run something like this:

# for (not sure what to put here) in list.txt;do myprogram $1 $2 $3;done

Perhaps some experienced users might know how to do this? I am not even sure if 
I'm doing this the right way or if it can be done.

Thank you very much for any help you can provide.
Ang




-
Do you Yahoo!?
 With a free 1 GB, there's more in store with Yahoo! Mail.
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: Shell Script Help

2006-01-29 Thread Proniewski Patrick

On 29 janv. 06, at 16:10, Angelo Christou wrote:


list.txt contains:

bob home 9002
jim data 9005



Running the following for each line is what I'm trying to do:
myprogram bob home 9002
myprogram jim data 9005
and so on..


give this a try:

while read myline; do
   set -- $myline
   myprogram $1 $2 $3
done  list.txt



Patrick PRONIEWSKI
--
Administrateur Système - SENTIER - Université Lumière Lyon 2



Re: Shell Script Help

2006-01-29 Thread Angelo Christou
Hello Patrick,

Your suggestion works perfectly. Thank you very much for helping a learner such 
as myself.

Ang.



Proniewski Patrick [EMAIL PROTECTED] wrote: On 29 janv. 06, at 16:10, Angelo 
Christou wrote:

 list.txt contains:

 bob home 9002
 jim data 9005

 Running the following for each line is what I'm trying to do:
 myprogram bob home 9002
 myprogram jim data 9005
 and so on..

give this a try:

while read myline; do
set -- $myline
myprogram $1 $2 $3
done  list.txt



Patrick PRONIEWSKI
-- 
Administrateur Syst�me - SENTIER - Universit� Lumi�re Lyon 2





-
Do you Yahoo!?
 With a free 1 GB, there's more in store with Yahoo! Mail.
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Perl script help

2006-01-25 Thread Jack Stone
I'm using an old (2001) canned perl script to manage questions to my tech 
site. It is of big help since it can answer common questions from templates 
and a real time saver.


Alas, that time saves is now being diminished by junk mail about cheap drugs 
and I'm trying to figure out how to filter those out of the good questions 
that are submitted by a form to a directory.


I've managed to filter the copy that is sent via sendmail by procmail using 
these tests:

* B ?? .*(cool|site|yousite|(yousite best))
* B ?? .*(http:\/\/.*\.*)|(/a href=*http:\/\/.*\.*/)

However, that still leaves the original stored in the directory that are 
displayed when the admin program is loaded and the questions are matched by 
proper answer template.


Is there any way to insert the same type of tests on those original copies 
in the storage as *.ftf files and just delete them so they aren't there 
when the question manager program is loaded??


I need a couple of perl lines that will either block or delete the questions 
if the body of the question  matches the tests.


Below are the pertinent lines of a sub-process that processes and stores the 
questions submitted via a web form --  ( 
http://www.antennex.com/cgi-bin/qm/Question.cgi ).


# if(open(QUESTION, $Data/questionfiles/$PID.ftf)) {
#   flock(QUESTION, '2');
#   print QUESTION name||$FORM{name}\nemail||$FORM{email}\n;
#   print QUESTION date||$SHOW_TIME on $SHOW_DATE||$time\n\n\n; # 3 new 
lines

#   print QUESTION $FORM{message}\n;
#   close QUESTION;
#   backup($Data/questionfiles/$PID.ftf);
# ...etc., etc.


Any suggestions appreciated.!!

Best regards,
Jack

_
Don’t just search. Find. Check out the new MSN Search! 
http://search.msn.click-url.com/go/onm00200636ave/direct/01/


___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: Perl script help

2006-01-25 Thread Jack Stone

From: Greg Barniskis [EMAIL PROTECTED]
To: Jack Stone [EMAIL PROTECTED]
CC: freebsd-questions@freebsd.org
Subject: Re: Perl script help
Date: Wed, 25 Jan 2006 13:29:39 -0600

Jack Stone wrote:
I'm using an old (2001) canned perl script to manage questions to my tech 
site. It is of big help since it can answer common questions from 
templates and a real time saver.


First, this isn't really a FreeBSD question, so you may certainly have 
better luck getting it answered in a Perl-oriented forum (or best, the help 
forum or the original author of the script in question).


[snip]
Is there any way to insert the same type of tests on those original copies 
in the storage as *.ftf files and just delete them so they aren't there 
when the question manager program is loaded??


If I were you I would be looking at the Perl code just before those lines 
that you quoted in your original message. Inspect the content of 
$FORM{message} earlier in the process and use Perl pattern matching to see 
if it contains taboo content. Something like


if ($FORM{message} =~ /taboophrase/) { msgisjunk; }



First, thanks for the tip as it works using exit; which might be enough, 
but would rather do a redirect to a page just in case one of the good guys 
trips over it in their questions. So, I'll try to figure out how to do that 
without further burden to you or this fine, helpful and usually friendly 
list.


With regard to your other remarks about learning perl and OT, there are many 
questions (like shell scripts here today) that don't quite fit. Of course, 
perl is part of the base OS, so it's not far off for the many script gurus I 
know that are here.


I've been a member of this list for several years and have answered dozens 
if not several 100 questions of all kinds that I do know about. Since I 
probably don't ask more than 3 or 4 question a year, I should be entitled to 
ask them vs my contributions. I enjoy helping when I can OT or not.


IMHO, this is one of the best lists to obtain help about scripts when one 
just doen's have to time to learn a whole scripting language. Going to a 
script list isn't very helpful either.


I'm a Jack of all trades, but no master of perl.

Again, thanks for the help -- but, not the lecture though as it was the 
obvious thing to do IF one really had time or the right skill/talent to 
learn a language.


Regards,
Jack

_
Express yourself instantly with MSN Messenger! Download today - it's FREE! 
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/


___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: Script help for updating routine

2005-11-03 Thread Denny White

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1



On 11/2/05, Denny White [EMAIL PROTECTED] wrote:

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1


I have a script, pasted in below, which does various
things on a daily basis, like cvsup src, docs, ports,
portsdb, portversion, portupgrade,  so on. I finally
figured out how to do the if/then/else thing with the
portversion-portupgrade part of the script, but I can't
figure out what to do to bypass the docs install part
if there are no new docs. Thanks for any help I can
get on it. Script follows:

#!/bin/sh
#
echo Cvsup latest src and doc
cvsup -g -L 2 /root/srcdoc-supfile
#
# THIS THE PART IN QUESTION, THAT DOES
# DOES THE DOCS. CUSTOM MAKEFILE IS FOR
# ENGLISH ONLY.
#G
#send copious output to the bit bucket
echo Updating docs
echo 
cd /usr/doc
cp Makefile.custom Makefile
make install
#make install  /dev/null
#
cd /root
echo Portsnap fetching and updating ports
echo 
portsnap fetch
portsnap update
#
echo Updating INDEX in /usr/ports
echo 
cd /usr/ports
#make fetchindex
portsdb -uUF
#
echo Portaudit checking for vulnerabilities in installed ports
echo Results in file /root/vulnerable
echo 
portaudit -Fda  /root/vulnerable
#
echo Portversion checking if any ports need upgrading
echo Results in file /root/need2upgrade
echo 
portversion -l   /root/need2upgrade
if grep '' /root/need2upgrade; then
echo Portupgrade upgrading out-of-date ports
portupgrade -arR; else
echo Ports already up to date 12
exit 1
fi
echo Finished at `/bin/date`.
exit




Today Andrew P. contributed the following:

1. You can limit docs to custom languages in
make.conf, that's a better way


Yup, did it already. I had just copied it word for
word to see how well it worked. Found it in Dru
Lavigne's at OReilly.



2. You can affor to copy extra 60Mb once a day,
can't you?


Don't quite follow on that. It's all downloaded.
Other langs aren't #'d out in the supfile, just
aren't installed. Time consuming, not about h/d
space.



3. You can grep cvsup output against something
like doc/


That's what I thought. Can't see grepping doc,
maybe update? Don't know quite how, tho. Don't
know enough about scripting yet, as I said. I
don't want to interrupt the cvsup process. I
thought about using tee  grep 'update' or
something to that affect in that secondary
output.



4. Never run portsnap fetch from cron, even if
you chose a very odd time, use portsnap cron



Yup, know about that, but thanks for the warning.
I have it setup like you said, in cron, for times
when I'm too lazy to run the entire script  instead,
just do it piecemeal.

GnuPG key  : 0x1644E79A  |  http://wwwkeys.nl.pgp.net
Fingerprint: D0A9 AD44 1F10 E09E 0E67  EC25 CB44 F2E5 1644 E79A

-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.2 (FreeBSD)
Comment: Made with pgp4pine 1.76

iD8DBQFDal7vy0Ty5RZE55oRAtEcAJ9RJz3f7O6HXaL8KCAAPi4kn5cVewCgtASm
qSJKDVKG3r7SDQ0PDfjk+kU=
=nLco
-END PGP SIGNATURE-

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Script help for updating routine

2005-11-02 Thread Denny White

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1


I have a script, pasted in below, which does various
things on a daily basis, like cvsup src, docs, ports,
portsdb, portversion, portupgrade,  so on. I finally
figured out how to do the if/then/else thing with the
portversion-portupgrade part of the script, but I can't
figure out what to do to bypass the docs install part
if there are no new docs. Thanks for any help I can
get on it. Script follows:

#!/bin/sh
#
echo Cvsup latest src and doc
cvsup -g -L 2 /root/srcdoc-supfile
#
# THIS THE PART IN QUESTION, THAT DOES
# DOES THE DOCS. CUSTOM MAKEFILE IS FOR
# ENGLISH ONLY.
#G
#send copious output to the bit bucket
echo Updating docs
echo 
cd /usr/doc
cp Makefile.custom Makefile
make install
#make install  /dev/null
#
cd /root
echo Portsnap fetching and updating ports
echo 
portsnap fetch
portsnap update
#
echo Updating INDEX in /usr/ports
echo 
cd /usr/ports
#make fetchindex
portsdb -uUF
#
echo Portaudit checking for vulnerabilities in installed ports
echo Results in file /root/vulnerable
echo 
portaudit -Fda  /root/vulnerable
#
echo Portversion checking if any ports need upgrading
echo Results in file /root/need2upgrade
echo 
portversion -l   /root/need2upgrade
if grep '' /root/need2upgrade; then
echo Portupgrade upgrading out-of-date ports
portupgrade -arR; else
echo Ports already up to date 12
exit 1
fi
echo Finished at `/bin/date`.
exit

GnuPG key  : 0x1644E79A  |  http://wwwkeys.nl.pgp.net
Fingerprint: D0A9 AD44 1F10 E09E 0E67  EC25 CB44 F2E5 1644 E79A

-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.2 (FreeBSD)
Comment: Made with pgp4pine 1.76

iD8DBQFDaQ7Ny0Ty5RZE55oRAjYhAKCyDOKGhu86oAVu6Ml2ANf2Rt3vXwCfcs52
2V388qkRXw8Kiun8iR7rbiY=
=Wscs
-END PGP SIGNATURE-

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: Script help for updating routine

2005-11-02 Thread Andrew P.
On 11/2/05, Denny White [EMAIL PROTECTED] wrote:
 -BEGIN PGP SIGNED MESSAGE-
 Hash: SHA1


 I have a script, pasted in below, which does various
 things on a daily basis, like cvsup src, docs, ports,
 portsdb, portversion, portupgrade,  so on. I finally
 figured out how to do the if/then/else thing with the
 portversion-portupgrade part of the script, but I can't
 figure out what to do to bypass the docs install part
 if there are no new docs. Thanks for any help I can
 get on it. Script follows:

 #!/bin/sh
 #
 echo Cvsup latest src and doc
 cvsup -g -L 2 /root/srcdoc-supfile
 #
 # THIS THE PART IN QUESTION, THAT DOES
 # DOES THE DOCS. CUSTOM MAKEFILE IS FOR
 # ENGLISH ONLY.
 #G
 #send copious output to the bit bucket
 echo Updating docs
 echo 
 cd /usr/doc
 cp Makefile.custom Makefile
 make install
 #make install  /dev/null
 #
 cd /root
 echo Portsnap fetching and updating ports
 echo 
 portsnap fetch
 portsnap update
 #
 echo Updating INDEX in /usr/ports
 echo 
 cd /usr/ports
 #make fetchindex
 portsdb -uUF
 #
 echo Portaudit checking for vulnerabilities in installed ports
 echo Results in file /root/vulnerable
 echo 
 portaudit -Fda  /root/vulnerable
 #
 echo Portversion checking if any ports need upgrading
 echo Results in file /root/need2upgrade
 echo 
 portversion -l   /root/need2upgrade
 if grep '' /root/need2upgrade; then
 echo Portupgrade upgrading out-of-date ports
 portupgrade -arR; else
 echo Ports already up to date 12
 exit 1
 fi
 echo Finished at `/bin/date`.
 exit

 GnuPG key  : 0x1644E79A  |  http://wwwkeys.nl.pgp.net
 Fingerprint: D0A9 AD44 1F10 E09E 0E67  EC25 CB44 F2E5 1644 E79A

 -BEGIN PGP SIGNATURE-
 Version: GnuPG v1.4.2 (FreeBSD)
 Comment: Made with pgp4pine 1.76

 iD8DBQFDaQ7Ny0Ty5RZE55oRAjYhAKCyDOKGhu86oAVu6Ml2ANf2Rt3vXwCfcs52
 2V388qkRXw8Kiun8iR7rbiY=
 =Wscs
 -END PGP SIGNATURE-

 ___
 freebsd-questions@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/freebsd-questions
 To unsubscribe, send any mail to [EMAIL PROTECTED]


1. You can limit docs to custom languages in
make.conf, that's a better way

2. You can affor to copy extra 60Mb once a day,
can't you?

3. You can grep cvsup output against something
like doc/

4. Never run portsnap fetch from cron, even if
you chose a very odd time, use portsnap cron

5. etc :)
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: Script help using cut

2005-08-24 Thread antenneX
- Original Message - 
From: antenneX [EMAIL PROTECTED]
To: Giorgos Keramidas [EMAIL PROTECTED]
Cc: freebsd-questions@freebsd.org
Sent: Tuesday, August 23, 2005 8:35 PM
Subject: Re: Script help using cut


 - Original Message - 
 From: Giorgos Keramidas [EMAIL PROTECTED]
 To: antenneX [EMAIL PROTECTED]
 Cc: freebsd-questions@freebsd.org
 Sent: Tuesday, August 23, 2005 8:16 PM
 Subject: Re: Script help using cut


  On 2005-08-23 20:02, antenneX [EMAIL PROTECTED] wrote:
   Been trying to complete a script that I can use to grep spam
 emails
   from the maillog, then trim it to just the plain email address.
 Trying
   to use cut in the script but it's not doing what I want yet.
  
   Here is what the earlier lines have the lines down to so far:
   (envelope-from [EMAIL PROTECTED])  -- no quotes
   ...and I want this clean trimmed result after trim using cut
 or
   anything else that works to trim/cut:
  
   [EMAIL PROTECTED]  --- no underlines of course
  
   That's a TAB space at beginning of the line.
  
   The envelope lines are in a tmp file in colum format (one line
 below
   the other).
   (envelope-from [EMAIL PROTECTED])
   (envelope-from [EMAIL PROTECTED])
   (envelope-from [EMAIL PROTECTED])
  
   All ideas appreciated
 
  Does it have to be cut(1)?
 
  $ awk '{print $2}' tmpfile | sed -e 's/)[[:space:]]*$//' | sort |
 uniq
 


Just woke up this morning and realized I needed to chop off more -- 
everything except the domain.

So, instead of [EMAIL PROTECTED] I need the result badguy.com

How could the above awk line be expanded to chop off the username@
portion as well?

Sorry, must have been really tired.

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: Script help using cut

2005-08-24 Thread Giorgos Keramidas
On 2005-08-24 07:58, antenneX [EMAIL PROTECTED] wrote:
antenneX [EMAIL PROTECTED] wrote:
Giorgos Keramidas [EMAIL PROTECTED] wrote:
 (envelope-from [EMAIL PROTECTED])
 (envelope-from [EMAIL PROTECTED])
 (envelope-from [EMAIL PROTECTED])

 All ideas appreciated

 $ awk '{print $2}' tmpfile | sed -e 's/)[[:space:]]*$//' | sort | uniq

 Just woke up this morning and realized I needed to chop off more --
 everything except the domain.

 So, instead of [EMAIL PROTECTED] I need the result badguy.com

 How could the above awk line be expanded to chop off the username@
 portion as well?

sed(1) can do more than one substitutions in one line:

sed -e 's/)[[:space:]]*$//' -e 's/^.*@//'

or you can use as complex regular expressions as necessary to cut
specific parts of the line:

sed -e 's/[EMAIL PROTECTED]([^)]*\))[[:space:]]*$/\1/'

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: Script help using cut

2005-08-24 Thread antenneX

- Original Message - 
From: Giorgos Keramidas [EMAIL PROTECTED]
To: antenneX [EMAIL PROTECTED]
Cc: freebsd-questions@freebsd.org
Sent: Wednesday, August 24, 2005 8:04 AM
Subject: Re: Script help using cut


 On 2005-08-24 07:58, antenneX [EMAIL PROTECTED] wrote:
 antenneX [EMAIL PROTECTED] wrote:
 Giorgos Keramidas [EMAIL PROTECTED] wrote:
  (envelope-from [EMAIL PROTECTED])
  (envelope-from [EMAIL PROTECTED])
  (envelope-from [EMAIL PROTECTED])
 
  All ideas appreciated
 
  $ awk '{print $2}' tmpfile | sed -e 's/)[[:space:]]*$//' | sort
| uniq
 
  Just woke up this morning and realized I needed to chop off
more --
  everything except the domain.
 
  So, instead of [EMAIL PROTECTED] I need the result badguy.com
 
  How could the above awk line be expanded to chop off the username@
  portion as well?

 sed(1) can do more than one substitutions in one line:

 sed -e 's/)[[:space:]]*$//' -e 's/^.*@//'

 or you can use as complex regular expressions as necessary to cut
 specific parts of the line:

 sed -e 's/[EMAIL PROTECTED]([^)]*\))[[:space:]]*$/\1/'


In fact, my very next script line uses sed(1) to add the TAB and the
RHS to the sendmail access file:
sed 's/$/   REJECT/g' tmpfile  /etc/mail/access

I'll bet my line could be incorporated with yours.


___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: Script help using cut

2005-08-24 Thread Giorgos Keramidas
On 2005-08-24 11:41, antenneX [EMAIL PROTECTED] wrote:
Giorgos Keramidas [EMAIL PROTECTED] wrote:
 sed -e 's/)[[:space:]]*$//' -e 's/^.*@//'

 or you can use as complex regular expressions as necessary to cut
 specific parts of the line:

 sed -e 's/[EMAIL PROTECTED]([^)]*\))[[:space:]]*$/\1/'

 In fact, my very next script line uses sed(1) to add the TAB and the
 RHS to the sendmail access file:
 sed 's/$/   REJECT/g' tmpfile  /etc/mail/access

 I'll bet my line could be incorporated with yours.

Sure.  It's probably also a good idea to use mv(1) with a temporary file
residing under /etc/mail too, to make sure the update to the access map
is as close to being an ``atomic operation'' as possible:

% accesstmp=`mktemp /etc/mail/access.tmp.XX`
% if [ -z ${accesstmp} ]; then
%   exit 1
% fi
%
% ( cat /etc/mail/access ;
%   awk '{whatever else here}' tmpfile | \
%   sed -e 's/[EMAIL PROTECTED]([^)]*\))[[:space:]]*$/\1REJECT/' )  
${accesstmp}
% if [ $? -ne 0 ]; then
%   exit 1
% fi
% mv ${accesstmp} /etc/mail/access
% cd /etc/mail  make access.db

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: Script help using cut

2005-08-24 Thread antenneX
- Original Message - 
From: Giorgos Keramidas [EMAIL PROTECTED]
To: antenneX [EMAIL PROTECTED]
Cc: freebsd-questions@freebsd.org
Sent: Wednesday, August 24, 2005 11:52 AM
Subject: Re: Script help using cut


 On 2005-08-24 11:41, antenneX [EMAIL PROTECTED] wrote:
 Giorgos Keramidas [EMAIL PROTECTED] wrote:
  sed -e 's/)[[:space:]]*$//' -e 's/^.*@//'
 
  or you can use as complex regular expressions as necessary to cut
  specific parts of the line:
 
  sed -e 's/[EMAIL PROTECTED]([^)]*\))[[:space:]]*$/\1/'
 
  In fact, my very next script line uses sed(1) to add the TAB and
the
  RHS to the sendmail access file:
  sed 's/$/   REJECT/g' tmpfile  /etc/mail/access
 
  I'll bet my line could be incorporated with yours.

 Sure.  It's probably also a good idea to use mv(1) with a temporary
file
 residing under /etc/mail too, to make sure the update to the access
map
 is as close to being an ``atomic operation'' as possible:

 % accesstmp=`mktemp /etc/mail/access.tmp.XX`
 % if [ -z ${accesstmp} ]; then
 % exit 1
 % fi
 %
 % ( cat /etc/mail/access ;
 %   awk '{whatever else here}' tmpfile | \
 %   sed -e 's/[EMAIL PROTECTED]([^)]*\))[[:space:]]*$/\1 REJECT/' ) 
${accesstmp}
 % if [ $? -ne 0 ]; then
 % exit 1
 % fi
 % mv ${accesstmp} /etc/mail/access
 % cd /etc/mail  make access.db


Giorgos, that's pretty snazzy compared to my crude script. Will now
work on weaving it all together. Eliminates a bit more manual effort.

I like it  appreciate the extra help!

Best regards,
Jack L. Stone

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Script help using cut

2005-08-23 Thread antenneX
Been trying to complete a script that I can use to grep spam emails
from the maillog, then trim it to just the plain email address. Trying
to use cut in the script but it's not doing what I want yet.

Here is what the earlier lines have the lines down to so far:
(envelope-from [EMAIL PROTECTED])  -- no quotes
...and I want this clean trimmed result after trim using cut or
anything else that works to trim/cut:

[EMAIL PROTECTED]  --- no underlines of course

That's a TAB space at beginning of the line.

The envelope lines are in a tmp file in colum format (one line below
the other).
(envelope-from [EMAIL PROTECTED])
(envelope-from [EMAIL PROTECTED])
(envelope-from [EMAIL PROTECTED])

All ideas appreciated

Best regards,

Jack L. Stone

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: Script help using cut

2005-08-23 Thread Giorgos Keramidas
On 2005-08-23 20:02, antenneX [EMAIL PROTECTED] wrote:
 Been trying to complete a script that I can use to grep spam emails
 from the maillog, then trim it to just the plain email address. Trying
 to use cut in the script but it's not doing what I want yet.

 Here is what the earlier lines have the lines down to so far:
 (envelope-from [EMAIL PROTECTED])  -- no quotes
 ...and I want this clean trimmed result after trim using cut or
 anything else that works to trim/cut:

 [EMAIL PROTECTED]  --- no underlines of course

 That's a TAB space at beginning of the line.

 The envelope lines are in a tmp file in colum format (one line below
 the other).
 (envelope-from [EMAIL PROTECTED])
 (envelope-from [EMAIL PROTECTED])
 (envelope-from [EMAIL PROTECTED])

 All ideas appreciated

Does it have to be cut(1)?

$ awk '{print $2}' tmpfile | sed -e 's/)[[:space:]]*$//' | sort | uniq

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: Script help using cut

2005-08-23 Thread antenneX
- Original Message - 
From: Giorgos Keramidas [EMAIL PROTECTED]
To: antenneX [EMAIL PROTECTED]
Cc: freebsd-questions@freebsd.org
Sent: Tuesday, August 23, 2005 8:16 PM
Subject: Re: Script help using cut


 On 2005-08-23 20:02, antenneX [EMAIL PROTECTED] wrote:
  Been trying to complete a script that I can use to grep spam
emails
  from the maillog, then trim it to just the plain email address.
Trying
  to use cut in the script but it's not doing what I want yet.
 
  Here is what the earlier lines have the lines down to so far:
  (envelope-from [EMAIL PROTECTED])  -- no quotes
  ...and I want this clean trimmed result after trim using cut
or
  anything else that works to trim/cut:
 
  [EMAIL PROTECTED]  --- no underlines of course
 
  That's a TAB space at beginning of the line.
 
  The envelope lines are in a tmp file in colum format (one line
below
  the other).
  (envelope-from [EMAIL PROTECTED])
  (envelope-from [EMAIL PROTECTED])
  (envelope-from [EMAIL PROTECTED])
 
  All ideas appreciated

 Does it have to be cut(1)?

 $ awk '{print $2}' tmpfile | sed -e 's/)[[:space:]]*$//' | sort |
uniq


No, it doesn't have to be cut.
I'll give this a try...
Thanks and,
Best regards,

Jack L. Stone

 ___
 freebsd-questions@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/freebsd-questions
 To unsubscribe, send any mail to
[EMAIL PROTECTED]

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: Script help using cut

2005-08-23 Thread antenneX
- Original Message - 
From: Giorgos Keramidas [EMAIL PROTECTED]
To: antenneX [EMAIL PROTECTED]
Cc: freebsd-questions@freebsd.org
Sent: Tuesday, August 23, 2005 8:16 PM
Subject: Re: Script help using cut


 On 2005-08-23 20:02, antenneX [EMAIL PROTECTED] wrote:
  Been trying to complete a script that I can use to grep spam
emails
  from the maillog, then trim it to just the plain email address.
Trying
  to use cut in the script but it's not doing what I want yet.
 
  Here is what the earlier lines have the lines down to so far:
  (envelope-from [EMAIL PROTECTED])  -- no quotes
  ...and I want this clean trimmed result after trim using cut
or
  anything else that works to trim/cut:
 
  [EMAIL PROTECTED]  --- no underlines of course
 
  That's a TAB space at beginning of the line.
 
  The envelope lines are in a tmp file in colum format (one line
below
  the other).
  (envelope-from [EMAIL PROTECTED])
  (envelope-from [EMAIL PROTECTED])
  (envelope-from [EMAIL PROTECTED])
 
  All ideas appreciated

 Does it have to be cut(1)?

 $ awk '{print $2}' tmpfile | sed -e 's/)[[:space:]]*$//' | sort |
uniq


Yep! That looks good!

Many thanks again for the tip.

Best regards,
Jack L. Stone

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Shell script help

2005-07-30 Thread Paul Schmehl
I'm working on a new port, and the one thing I can't seem to solve is the 
man pages.  They install fine, but they're not formatted right.


In the Makefile that is built from configure, this is the section that 
handles the man pages:


@cd $(TOP_DIR)/doc; for i in *.n; \
   do \
   rm -f $(MAN_INSTALL_DIR)/`basename $$i`; \
   rm -f $(MAN_INSTALL_DIR)/`basename iwidgets_$$i`; \
   sed -e '/man\.macros/r man.macros' -e '/man\.macros/d' \
   $$i  $(MAN_INSTALL_DIR)/`basename iwidgets_$$i`; \
   chmod 444 $(MAN_INSTALL_DIR)/`basename iwidgets_$$i`; \
   done;

Running what I *thought* was the same sed command in the Makefile of the 
port doesn't solve the problem of the formatting of the man pages, but it 
doesn't generate any errors either:


@${SED} -e '/man\.macros/r man.macros' -e '/man\.macros/d' 
${WRKSRC}/doc/${f} \

${WRKDIR}/${f}

Can someone explain what the sed command is doing?  The man page isn't much 
help.


Paul Schmehl ([EMAIL PROTECTED])
Adjunct Information Security Officer
University of Texas at Dallas
AVIEN Founding Member
http://www.utdallas.edu/
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: Shell script help

2005-07-30 Thread Parv
in message [EMAIL PROTECTED],
wrote Paul Schmehl thusly...

 Running what I *thought* was the same sed command in the Makefile
 of the port doesn't solve the problem of the formatting of the man
 pages, but it doesn't generate any errors either:
 
 @${SED} -e '/man\.macros/r man.macros' -e '/man\.macros/d' 
 ${WRKSRC}/doc/${f} \
 ${WRKDIR}/${f}
 
 Can someone explain what the sed command is doing?  The man page
 isn't much help.

In the 1st part, sed sends the output of file 'man.macros' to
standard out if it exists (otherwise no worries) when sed sees the
'man\.macros' pattern.

And the 2d part, just deletes that pattern.

There in the sed(1) man page all is.  Or, line by line try this ...

  rm -f q ; echo polka  p
  { echo p  ; echo q; echo p; } | sed -e '/p/r p' -e '/p/d'
  { echo p  ; echo q; echo p; } | sed -e '/p/r q' -e '/p/d'


  - Parv

-- 

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: Shell script help

2005-07-30 Thread Parv
in message [EMAIL PROTECTED], wrote Parv
thusly...

 in message
 [EMAIL PROTECTED], wrote
 Paul Schmehl thusly...
 
  @${SED} -e '/man\.macros/r man.macros'
...
 In the 1st part, sed sends the output of file 'man.macros' to
 ^ ^ ^ ^ ^ ^ ^
 ^ ^ ^ ^ ^ ^ ^
 standard out

[O]utput of file should have been contents of file.


  - Parv

-- 

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: Shell script help

2005-07-30 Thread Paul Schmehl

--On July 30, 2005 2:57:57 AM -0400 Parv [EMAIL PROTECTED] wrote:


in message [EMAIL PROTECTED],
wrote Paul Schmehl thusly...


Running what I *thought* was the same sed command in the Makefile
of the port doesn't solve the problem of the formatting of the man
pages, but it doesn't generate any errors either:

@${SED} -e '/man\.macros/r man.macros' -e '/man\.macros/d'
${WRKSRC}/doc/${f} \
${WRKDIR}/${f}

Can someone explain what the sed command is doing?  The man page
isn't much help.


In the 1st part, sed sends the output of file 'man.macros' to
standard out if it exists (otherwise no worries) when sed sees the
'man\.macros' pattern.

And the 2d part, just deletes that pattern.

There in the sed(1) man page all is.  Or, line by line try this ...

  rm -f q ; echo polka  p
  { echo p  ; echo q; echo p; } | sed -e '/p/r p' -e '/p/d'
  { echo p  ; echo q; echo p; } | sed -e '/p/r q' -e '/p/d'

Thanks!  That was the answer.  I had to fiddle with it for a while before I 
understood what it was doing, but it does exactly what I need it to do now.


Paul Schmehl ([EMAIL PROTECTED])
Adjunct Information Security Officer
University of Texas at Dallas
AVIEN Founding Member
http://www.utdallas.edu/
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: Shell script help

2005-07-30 Thread Parv
in message [EMAIL PROTECTED],
wrote Paul Schmehl thusly...

 --On July 30, 2005 2:57:57 AM -0400 Parv [EMAIL PROTECTED] wrote:
 
 in message [EMAIL PROTECTED],
 wrote Paul Schmehl thusly...
...
 @${SED} -e '/man\.macros/r man.macros' -e '/man\.macros/d'
 ${WRKSRC}/doc/${f} \
 ${WRKDIR}/${f}
...
 In the 1st part, sed sends the output of file 'man.macros' to
 standard out if it exists (otherwise no worries) when sed sees
 the 'man\.macros' pattern.
 
 And the 2d part, just deletes that pattern.
...
 Thanks!  That was the answer.  I had to fiddle with it for a while
 before I understood what it was doing, but it does exactly what I
 need it to do now.

Your welcome; i apologize if my reply was cryptic.

But then i was working direclty from the man page as my sed-fu is ok
but not great. (:


  - Parv

-- 

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: Shell script help

2005-06-30 Thread Kevin Kinsey

Norberto Meijome wrote:


Kevin Kinsey wrote:



=

# Rule number variable
  RuleNum=100

#
# this function increments $RulNum var by 100... #
#

inc () {
  RuleNum=$(expr $1 + 100)
}


##
#   LET'S GET STARTED   #
##

# flush the ruleset ...
  /sbin/ipfw -q flush

# set up the loopback ...
  $FW $RuleNum allow ip from any to any via $loopback
  inc $RuleNum

# deny localhost traffic on other interfaces
  $FW $RuleNum deny ip from 127.0.0.0/8 to any
  inc $RuleNum
  $FW $RuleNum deny ip from any to 127.0.0.0/8
  inc $RuleNum

==



nice use...but what's the point ? ipfw assigns rule #s automatically.

I agree that you may want to hardcode your rule #s (0-100
for localhost, 200 - 5000 for LAN, etc) but using your inc() process
defeats the purpose of this.

just my $0.02
Beto



Well, I was tired of hardcoding rule numbers, and wanted
the script to do it for me and still have gaps.

IIRC, when I wrote this one, I wanted a gap larger than 100
between certain sets of rules, so I needed to have control
over $RuleNum instead of letting ipfw do it.  A do...while
farther down allows for addition of new rules in the
upper section while keeping the next section starting at
foo-thousand.

I did say I didn't know if it was a great script, but it's
a slightly more advanced example of sh(1) scripting.
In part, it was a learning exercise for me

HAND,

Kevin Kinsey
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: Shell script help

2005-06-29 Thread Björn König

Mike Jeays wrote:


man expr to give the short answer to your first question:

As an example, x=`expr $x + 1`

536 ~ $ x=4
537 ~ $ x=`expr $x + 1`
538 ~ $ echo $

Note the back-quotes to execute a command and return the result, and the
need for spaces between each token in the expr command.


sh(1) is able to evaluate arithmetic expressions too, e.g.

  x=$(($x+1))



Björn
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Shell script help

2005-06-28 Thread fbsd_user
My sh shell script ability is not that good.
Have 2 simple coding problems.

How do I code a statement to subtract one from a field.

$rulenum = $rulenum - 1
$rulenum = '$rulenum - 1'

one='1'
$rulenum = $rulenum - $one
$rulenum='$rulenum - $one'

None of that works. must really be simple.

I also have this line
inruleno=`ipfw list | sed -n -e s/00\([0-9]*\) $inblock/\1/p`

This works ok, the search argument  is  s/00\ but that is not good enough
because the number can be 0 to 65535. The sed -n -e s/00\([0-9]*\ needs to
be changed to just return the first word.


Thanks for any help you can give.


___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: Shell script help

2005-06-28 Thread Mike Jeays
On Tue, 2005-06-28 at 22:52, fbsd_user wrote:
 My sh shell script ability is not that good.
 Have 2 simple coding problems.
 
 How do I code a statement to subtract one from a field.
 
 $rulenum = $rulenum - 1
 $rulenum = '$rulenum - 1'
 
 one='1'
 $rulenum = $rulenum - $one
 $rulenum='$rulenum - $one'
 
 None of that works. must really be simple.
 
 I also have this line
 inruleno=`ipfw list | sed -n -e s/00\([0-9]*\) $inblock/\1/p`
 
 This works ok, the search argument  is  s/00\ but that is not good enough
 because the number can be 0 to 65535. The sed -n -e s/00\([0-9]*\ needs to
 be changed to just return the first word.
 
 
 Thanks for any help you can give.
 
 
 ___
 freebsd-questions@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/freebsd-questions
 To unsubscribe, send any mail to [EMAIL PROTECTED]

man expr to give the short answer to your first question:

As an example, x=`expr $x + 1`

536 ~ $ x=4
537 ~ $ x=`expr $x + 1`
538 ~ $ echo $

Note the back-quotes to execute a command and return the result, and the
need for spaces between each token in the expr command.


___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: Shell script help

2005-06-28 Thread Kevin Kinsey

Mike Jeays wrote:


On Tue, 2005-06-28 at 22:52, fbsd_user wrote:
 


My sh shell script ability is not that good.
Have 2 simple coding problems.

How do I code a statement to subtract one from a field.

$rulenum = $rulenum - 1
$rulenum = '$rulenum - 1'

one='1'
$rulenum = $rulenum - $one
$rulenum='$rulenum - $one'

None of that works. must really be simple.

I also have this line
inruleno=`ipfw list | sed -n -e s/00\([0-9]*\) $inblock/\1/p`

This works ok, the search argument  is  s/00\ but that is not good enough
because the number can be 0 to 65535. The sed -n -e s/00\([0-9]*\ needs to
be changed to just return the first word.

Thanks for any help you can give.

   


man expr to give the short answer to your first question:

As an example, x=`expr $x + 1`

536 ~ $ x=4
537 ~ $ x=`expr $x + 1`
538 ~ $ echo $

Note the back-quotes to execute a command and return the result, and the
need for spaces between each token in the expr command.

 



Hi, Joe, Mike:

Mike's right, of course.  I dunno if this is a neat trick,
or not, but here's a small sample of my fw script that
shows not only another use of expr(1), but also the use of
expr(1) in a function, since by its very nature it will be
called many times (once for each rule, I assume)

=

# Rule number variable
  RuleNum=100

#
# this function increments $RulNum var by 100... #
#

inc () {
  RuleNum=$(expr $1 + 100)
}


##
#   LET'S GET STARTED   #
##

# flush the ruleset ...
  /sbin/ipfw -q flush

# set up the loopback ...
  $FW $RuleNum allow ip from any to any via $loopback
  inc $RuleNum

# deny localhost traffic on other interfaces
  $FW $RuleNum deny ip from 127.0.0.0/8 to any
  inc $RuleNum
  $FW $RuleNum deny ip from any to 127.0.0.0/8
  inc $RuleNum

==

HTH,

Kevin Kinsey
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: Shell script help

2005-06-28 Thread Norberto Meijome

Kevin Kinsey wrote:


=

# Rule number variable
  RuleNum=100

#
# this function increments $RulNum var by 100... #
#

inc () {
  RuleNum=$(expr $1 + 100)
}


##
#   LET'S GET STARTED   #
##

# flush the ruleset ...
  /sbin/ipfw -q flush

# set up the loopback ...
  $FW $RuleNum allow ip from any to any via $loopback
  inc $RuleNum

# deny localhost traffic on other interfaces
  $FW $RuleNum deny ip from 127.0.0.0/8 to any
  inc $RuleNum
  $FW $RuleNum deny ip from any to 127.0.0.0/8
  inc $RuleNum

==


nice use...but what's the point ? ipfw assigns rule #s automatically.

I agree that you may want to hardcode your rule #s (0-100 for localhost, 
200 - 5000 for LAN, etc) but using your inc() process defeats the 
purpose of this.


just my $0.02
Beto
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


perl script help

2004-04-16 Thread JJB

I need $timezone to hold the time zone in this format  -00:00
The command  date +%z  will give it as  -

I know nothing about writing perl scripts.

Can somebody show me how to  add the : in the output 
of the date command in the simple following script?

The cat statement is just so I can see results are correct.


#!/usr/bin/perl
$timezone=date +%z;
cat $timezone




___
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: perl script help

2004-04-16 Thread Remko Lodder
JJB wrote:
I need $timezone to hold the time zone in this format  -00:00
The command  date +%z  will give it as  -
I know nothing about writing perl scripts.

Can somebody show me how to  add the : in the output 
of the date command in the simple following script?

The cat statement is just so I can see results are correct.

#!/usr/bin/perl
$timezone=date +%z;
cat $timezone
Not that i am very good in perl,
In KSH scripting it's like this:
%H:%M for a 00:00 output instead of 

Perhaps that will help you:-)

(Oh the command date +%H:%M)

Cheers



___
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


--

Kind regards,

Remko Lodder
Elvandar.org/DSINet.org
www.mostly-harmless.nl A Dutch community for helping newcomers on the 
hackerscene
___
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: perl script help

2004-04-16 Thread Remko Lodder
Not that i am very good in perl,
In KSH scripting it's like this:
%H:%M for a 00:00 output instead of 

Perhaps that will help you:-)

(Oh the command date +%H:%M)

Cheers

Well that does not work (FYI)

Cheers (perhaps Matthew's comments on this are better ;-) )



--

Kind regards,

Remko Lodder
Elvandar.org/DSINet.org
www.mostly-harmless.nl A Dutch community for helping newcomers on the 
hackerscene
___
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: perl script help

2004-04-16 Thread Shaun Friedle
On Fri, 2004-04-16 at 17:05, JJB wrote:
 I know nothing about writing perl scripts.
 
 Can somebody show me how to  add the : in the output 
 of the date command in the simple following script?

Try this:

#!/usr/bin/perl
$timezone=`date +\%z`;  #Gets the offset in $timezone
$timezone =~ s/(\+[0-9][0-9])/$1:/; #Replaces ±NN with ±NN:
print $timezone;#Prints $timezone


-- 
Shaun Friedle
[EMAIL PROTECTED]

___
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: perl script help

2004-04-16 Thread Warren Block
On Fri, 16 Apr 2004, Shaun Friedle wrote:

 #!/usr/bin/perl
 $timezone=`date +\%z`;#Gets the offset in $timezone
 $timezone =~ s/(\+[0-9][0-9])/$1:/;   #Replaces ±NN with ±NN:
 print $timezone;  #Prints $timezone

The regex should allow either a plus or a minus as the first character:
s/([+-][0-9]{2})/$1:/

I like Perl a lot, and use it often, but it seems a bit much for this.
If there were easy shell substring operations...  Anyway, shell-only:

date +%z | sed 's/.../:/'  # insert colon after first three chars

-Warren Block * Rapid City, South Dakota USA
___
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


drive space shell script help ?

2003-09-15 Thread Brent Bailey
Im trying to write  a script that will email me when drive space on any
given partition is above a certain value.

i was trying this ...but no working ...

#!/bin/sh
# this is a script to check drive space and email HSD dept.
#
cd ~bbailey
rm ~bbailey/drvspc.txt
df -k  | awk '{print$5}' ~bbailey/drvspc.txt
cat drvspc.txt
while read i
do
if [$i  '89'];  then
mail -s check drive space on core [EMAIL PROTECTED]
fi
echo done

ME not being that great at shell scripting yet ...i was wondering what im
doing wrong here ??

any and all help is greatly appreciated

thanx
-- 
Brent Bailey CCNA
Bmyster LLC
Computer Networking and Webhosting
Network Engineer, Webmaster, President
http://www.bmyster.com
[EMAIL PROTECTED]
207-247-8330



___
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


RE: drive space shell script help ?

2003-09-15 Thread Charles Howse
 #!/bin/sh
 # this is a script to check drive space and email HSD dept.
 #
 cd ~bbailey
 rm ~bbailey/drvspc.txt
 df -k  | awk '{print$5}' ~bbailey/drvspc.txt
 cat drvspc.txt
 while read i
 do
 if [$i  '89'];  then

This line should be:
if [ $i -gt 89 ] ; then

The spaces between the leading and trailing brackets are mandatory, and
you had 2 spaces between the ; and 'then', and the comparison operator
for integers is '-gt' for 'greater than'.  I don't believe you need the
ticks around 89 either.

A great source for help: http://www.tldp.org/LDP/abs/html/


___
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


RE: drive space shell script help ?

2003-09-15 Thread Charles Howse
The more I play with your script, the more fun it becomes.

#!/bin/sh
# this is a script to check drive space and email HSD dept.
#
cd ~bbailey
rm drvspc.txt # Once I'm in ~bbailey, I don't need the complete path to
any files there.

df -k  | 
# You have to get rid of the word 'Capacity' or your comparison will
fail,
grep -v Capacity |
# There's no need to check the /proc filesystem, it'll always be full,
grep -v /proc | 
awk '{print$5}' | 
# You have to use sed to eliminate the % from df -k or the comparison
will fail.
sed -e 's/%//'  drvspc.txt 
cat drvspc.txt | 
while read i
do
if [ $i -gt 89 ] ; then
mail -s check drive space on core [EMAIL PROTECTED]
fi
done
# Quotes not necessary when echoing a single word, but I wouldn't do
this, you
# might want to schedule this with cron and it'll clutter up your screen
# if you tell it to say 'done' every time it runs.
echo done 
exit 0


Thanks,
Charles

Got a computer with idle CPU time?
Join [EMAIL PROTECTED] and help make history!
http://setiathome.ssl.berkeley.edu/


___
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


RE: drive space shell script help ?

2003-09-15 Thread Brent Bailey
Awesome that worked ..Im also going to try some of the other options you
had mentioned..I wanted to thank you for your help :-)

This has got to be the best dam mailing list there is :-)
-- 
Brent Bailey CCNA
Bmyster LLC
Computer Networking and Webhosting
Network Engineer, Webmaster, President
http://www.bmyster.com
[EMAIL PROTECTED]
207-247-8330


 The more I play with your script, the more fun it becomes.

 #!/bin/sh
 # this is a script to check drive space and email HSD dept.
 #
 cd ~bbailey
 rm drvspc.txt # Once I'm in ~bbailey, I don't need the complete path to
 any files there.

 df -k  |
 # You have to get rid of the word 'Capacity' or your comparison will
 fail,
 grep -v Capacity |
 # There's no need to check the /proc filesystem, it'll always be full,
 grep -v /proc |
 awk '{print$5}' |
 # You have to use sed to eliminate the % from df -k or the comparison
 will fail.
 sed -e 's/%//'  drvspc.txt
 cat drvspc.txt |
 while read i
 do
   if [ $i -gt 89 ] ; then
   mail -s check drive space on core [EMAIL PROTECTED]
   fi
 done
 # Quotes not necessary when echoing a single word, but I wouldn't do
 this, you
 # might want to schedule this with cron and it'll clutter up your screen
 # if you tell it to say 'done' every time it runs.
 echo done
 exit 0


 Thanks,
 Charles

 Got a computer with idle CPU time?
 Join [EMAIL PROTECTED] and help make history!
 http://setiathome.ssl.berkeley.edu/


 ___
 [EMAIL PROTECTED] mailing list
 http://lists.freebsd.org/mailman/listinfo/freebsd-questions
 To unsubscribe, send any mail to
 [EMAIL PROTECTED]


___
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: Script help needed please

2003-08-14 Thread Alexander Haderer
At 08:49 14.08.2003 -0500, Jack L. Stone wrote:
...
When we started providing the articles 6-7 years ago, folks used browsers
to read the articles. Now, the trend has become a more lazy approach and
there is an increasing use of those download utilities which can be left
unattended to download entire web sites taking several hours to do so.
Multiply this by a number of similar downloads and there goes the
bandwidth, denying those other normal online readers the speed needed for
loading and browsing in the manner intended. Several hundred will be
reading at a time and several 1000 daily.

A possible solution?
What comes to my mind:

- Offer zip/tar.gz archives via an ftp server to your customers.
- allow customer's server to mirror your ftp-server
- probably: setup a mailing list to inform your customers about changes/updates
Of course you can additionally install some bandwith limitation stuff. (But 
I don't know one, sorry).

Alexander

___
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: Script help needed please

2003-08-14 Thread Jack L. Stone
At 03:44 PM 8.14.2003 +0100, Jez Hancock wrote:
On Thu, Aug 14, 2003 at 08:49:49AM -0500, Jack L. Stone wrote:
 Server Version: Apache/1.3.27 (Unix) FrontPage/5.0.2.2510 PHP/4.3.1
 The above is typical of the servers in use, and with csh shells employed,
 plus IPFW.
 
 My apologies for the length of this question, but the background seems
 necessary as brief as I can make it so the question makes sense.
 
 The problem:
 We have several servers that provide online reading of Technical articles
 and each have several hundred MB to a GB of content.
 
 When we started providing the articles 6-7 years ago, folks used browsers
 to read the articles. Now, the trend has become a more lazy approach and
 there is an increasing use of those download utilities which can be left
 unattended to download entire web sites taking several hours to do so.
 Multiply this by a number of similar downloads and there goes the
 bandwidth, denying those other normal online readers the speed needed for
 loading and browsing in the manner intended. Several hundred will be
 reading at a time and several 1000 daily.
snip
There is no easy solution to this, but one avenue might be to look at
bandwidth throttling in an apache module.

One that I've used before is mod_throttle which is in the ports:

/usr/ports/www/mod_throttle

which allows you to throttle users by ip address to a certain number of
documents and/or up to a certain transfer limit.  IIRC it's fairly
limited though in that you can only apply per IP limits to _every_
virtual host - ie in the global httpd.conf context.

A more finegrained solution (from what I've read, haven't tried it) is
mod_bwshare - this one isn't in the ports but can be found here:

http://www.topology.org/src/bwshare/

this module overcomes some of the shortfalls of mod_throttle and allows
you to specify finer granularity over who consumes how much bandwidth
over what time period.

 Now, my question: Is it possible to write a script that can constantly scan
 the Apache logs to look for certain footprints of those downloaders,
 perhaps the names, like HTTRACK, being one I see a lot. Whenever I see
 one of those sessions, I have been able to abort them by adding a rule to
 the firewall to deny the IP address access to the server. This aborts the
 downloading, but have seen the attempts constantly continue for a day or
 two, confirming unattended downloads.
 
 Thus, if the script could spot an offender and then perhaps make use of
 the firewall to add a rule containing the offender's IP address and then
 flush to reset the firewall, this would at least abort the download and
 free up the bandwidth (I already have a script that restarts the firewall).
 
 Is this possible and how would I go about it???
If you really wanted to go down this route then I found a script someone
wrote a while back to find 'rude robots' from a httpd logfile which you
could perhaps adapt to do dynamic filtering in conjunction with your
firewall:

http://stein.cshl.org/~lstein/talks/perl_conference/cute_tricks/log9.html

If you have any success let me know.

-- 
Jez


Interesting. Looks like a step in the right direction. Will weigh this one
along the possibilities.

Many thanks...!

Best regards,
Jack L. Stone,
Administrator

SageOne Net
http://www.sage-one.net
[EMAIL PROTECTED]
___
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: Script help needed please

2003-08-14 Thread Michael Conlen
Jack,

You can setup Apache to deny access to people using that browser. The 
catch is that it's easy to work around it by changing the browser 
string. If they are that desperate to do this after you deny access to 
people using HTTRACK or other clients you can place a link that no human 
would access that runs a CGI that runs the firewall rule to deny them 
access. You probably want it to return some data and wait a bit so the 
user can't figure out easily what URL is killing their access.

You can also put on your website that users are not allowed to use the 
site using non interactive browsers. Then when you find them you send a 
nasty gram to their ISP and notify them that continued abuse could be a 
crime under the Computer Fraud and Abuse Act (if you and they are in the 
US) and let their ISP take care of it.

--
Michael Conlen
Jack L. Stone wrote:

Server Version: Apache/1.3.27 (Unix) FrontPage/5.0.2.2510 PHP/4.3.1
The above is typical of the servers in use, and with csh shells employed,
plus IPFW.
My apologies for the length of this question, but the background seems
necessary as brief as I can make it so the question makes sense.
The problem:
We have several servers that provide online reading of Technical articles
and each have several hundred MB to a GB of content.
When we started providing the articles 6-7 years ago, folks used browsers
to read the articles. Now, the trend has become a more lazy approach and
there is an increasing use of those download utilities which can be left
unattended to download entire web sites taking several hours to do so.
Multiply this by a number of similar downloads and there goes the
bandwidth, denying those other normal online readers the speed needed for
loading and browsing in the manner intended. Several hundred will be
reading at a time and several 1000 daily.
Further, those download utilities do not discriminate on the files
downloaded unless the user sets them to exclude certain types of files they
don't need for the articles. All or most don't bother to set the
parameters. They just turn them loose and go about their day. Essentially a
DoS for normal readers who notice the slowdown, but not with malice.
This method downloads a tremendous amount of unnecessary content. Some
downloaders have been contacted to stop (if we spot an email address from a
login) and in response they simply weren't aware of the problems they were
making and agreed to at least spread downloads over longer periods of time.
I can live with that.
A possible solution?
Now, my question: Is it possible to write a script that can constantly scan
the Apache logs to look for certain footprints of those downloaders,
perhaps the names, like HTTRACK, being one I see a lot. Whenever I see
one of those sessions, I have been able to abort them by adding a rule to
the firewall to deny the IP address access to the server. This aborts the
downloading, but have seen the attempts constantly continue for a day or
two, confirming unattended downloads.
Thus, if the script could spot an offender and then perhaps make use of
the firewall to add a rule containing the offender's IP address and then
flush to reset the firewall, this would at least abort the download and
free up the bandwidth (I already have a script that restarts the firewall).
Is this possible and how would I go about it???

Many thanks for any ideas on this!

Best regards,
Jack L. Stone,
Administrator
SageOne Net
http://www.sage-one.net
[EMAIL PROTECTED]
___
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]
 

___
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: Script help needed please

2003-08-14 Thread Jez Hancock
On Thu, Aug 14, 2003 at 08:49:49AM -0500, Jack L. Stone wrote:
 Server Version: Apache/1.3.27 (Unix) FrontPage/5.0.2.2510 PHP/4.3.1
 The above is typical of the servers in use, and with csh shells employed,
 plus IPFW.
 
 My apologies for the length of this question, but the background seems
 necessary as brief as I can make it so the question makes sense.
 
 The problem:
 We have several servers that provide online reading of Technical articles
 and each have several hundred MB to a GB of content.
 
 When we started providing the articles 6-7 years ago, folks used browsers
 to read the articles. Now, the trend has become a more lazy approach and
 there is an increasing use of those download utilities which can be left
 unattended to download entire web sites taking several hours to do so.
 Multiply this by a number of similar downloads and there goes the
 bandwidth, denying those other normal online readers the speed needed for
 loading and browsing in the manner intended. Several hundred will be
 reading at a time and several 1000 daily.
snip
There is no easy solution to this, but one avenue might be to look at
bandwidth throttling in an apache module.

One that I've used before is mod_throttle which is in the ports:

/usr/ports/www/mod_throttle

which allows you to throttle users by ip address to a certain number of
documents and/or up to a certain transfer limit.  IIRC it's fairly
limited though in that you can only apply per IP limits to _every_
virtual host - ie in the global httpd.conf context.

A more finegrained solution (from what I've read, haven't tried it) is
mod_bwshare - this one isn't in the ports but can be found here:

http://www.topology.org/src/bwshare/

this module overcomes some of the shortfalls of mod_throttle and allows
you to specify finer granularity over who consumes how much bandwidth
over what time period.

 Now, my question: Is it possible to write a script that can constantly scan
 the Apache logs to look for certain footprints of those downloaders,
 perhaps the names, like HTTRACK, being one I see a lot. Whenever I see
 one of those sessions, I have been able to abort them by adding a rule to
 the firewall to deny the IP address access to the server. This aborts the
 downloading, but have seen the attempts constantly continue for a day or
 two, confirming unattended downloads.
 
 Thus, if the script could spot an offender and then perhaps make use of
 the firewall to add a rule containing the offender's IP address and then
 flush to reset the firewall, this would at least abort the download and
 free up the bandwidth (I already have a script that restarts the firewall).
 
 Is this possible and how would I go about it???
If you really wanted to go down this route then I found a script someone
wrote a while back to find 'rude robots' from a httpd logfile which you
could perhaps adapt to do dynamic filtering in conjunction with your
firewall:

http://stein.cshl.org/~lstein/talks/perl_conference/cute_tricks/log9.html

If you have any success let me know.

-- 
Jez

http://www.munk.nu/
___
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Script help needed please

2003-08-14 Thread Jack L. Stone
Server Version: Apache/1.3.27 (Unix) FrontPage/5.0.2.2510 PHP/4.3.1
The above is typical of the servers in use, and with csh shells employed,
plus IPFW.

My apologies for the length of this question, but the background seems
necessary as brief as I can make it so the question makes sense.

The problem:
We have several servers that provide online reading of Technical articles
and each have several hundred MB to a GB of content.

When we started providing the articles 6-7 years ago, folks used browsers
to read the articles. Now, the trend has become a more lazy approach and
there is an increasing use of those download utilities which can be left
unattended to download entire web sites taking several hours to do so.
Multiply this by a number of similar downloads and there goes the
bandwidth, denying those other normal online readers the speed needed for
loading and browsing in the manner intended. Several hundred will be
reading at a time and several 1000 daily.

Further, those download utilities do not discriminate on the files
downloaded unless the user sets them to exclude certain types of files they
don't need for the articles. All or most don't bother to set the
parameters. They just turn them loose and go about their day. Essentially a
DoS for normal readers who notice the slowdown, but not with malice.

This method downloads a tremendous amount of unnecessary content. Some
downloaders have been contacted to stop (if we spot an email address from a
login) and in response they simply weren't aware of the problems they were
making and agreed to at least spread downloads over longer periods of time.
I can live with that.

A possible solution?
Now, my question: Is it possible to write a script that can constantly scan
the Apache logs to look for certain footprints of those downloaders,
perhaps the names, like HTTRACK, being one I see a lot. Whenever I see
one of those sessions, I have been able to abort them by adding a rule to
the firewall to deny the IP address access to the server. This aborts the
downloading, but have seen the attempts constantly continue for a day or
two, confirming unattended downloads.

Thus, if the script could spot an offender and then perhaps make use of
the firewall to add a rule containing the offender's IP address and then
flush to reset the firewall, this would at least abort the download and
free up the bandwidth (I already have a script that restarts the firewall).

Is this possible and how would I go about it???

Many thanks for any ideas on this!

Best regards,
Jack L. Stone,
Administrator

SageOne Net
http://www.sage-one.net
[EMAIL PROTECTED]
___
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


shell script help

2003-07-23 Thread David Bear
I'm trying to clean up a script that controls my tape better.  Among
other things it sets some variable to use later.  I've made an error
somewhere and I'm thinking that I'm missing the obvious since I cant
find the error.  I want to set command line options for tar.  Below
taroptions has what I want.  Line 12 echo's the command.  When I use
what line echo's to the console tar works.  However, something is
happening with line 13 that makes tar mad.  It tells me 

tar can't open the archive /dev/sa0 /var/log

Please advice -- I'm going blind trying understand this one.


1 #!/bin/sh
2 PATH=/bin:/usr/bin
3 backupadmin=[EMAIL PROTECTED]
4 starttime=`date +DATE: %Y-%m-%d%nTIME: %H:%M`
5 wrkdir=/root
6 tmpfile=${wrkdir}/cat.tmp
7 curfile=${wrkdir}/tapelabel
8 catalog=${wrkdir}/level1Tar.cat
9 datetime=`date +DATE: %Y-%m-%d%nTIME: %H:%M`
0 taroptions=--create --verbose --block-size 1 --read-full-blocks --block-compress 
--gzip --file 
1 tapedev=/dev/sa0
2 echo tar ${taroptions}${tapedev} /var/log
3 tar ${taroptions}${tapedev} /var/log
4 exit

-- 
David Bear
phone:  480-965-8257
fax:480-965-9189
College of Public Programs/ASU
Wilson Hall 232
Tempe, AZ 85287-0803
 Beware the IP portfolio, everyone will be suspect of trespassing
___
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: shell script help

2003-07-23 Thread Joe Marcus Clarke
On Wed, 2003-07-23 at 02:04, David Bear wrote:
 I'm trying to clean up a script that controls my tape better.  Among
 other things it sets some variable to use later.  I've made an error
 somewhere and I'm thinking that I'm missing the obvious since I cant
 find the error.  I want to set command line options for tar.  Below
 taroptions has what I want.  Line 12 echo's the command.  When I use
 what line echo's to the console tar works.  However, something is
 happening with line 13 that makes tar mad.  It tells me 
 
 tar can't open the archive /dev/sa0 /var/log
 
 Please advice -- I'm going blind trying understand this one.
 
 
 1 #!/bin/sh
 2 PATH=/bin:/usr/bin
 3 backupadmin=[EMAIL PROTECTED]
 4 starttime=`date +DATE: %Y-%m-%d%nTIME: %H:%M`
 5 wrkdir=/root
 6 tmpfile=${wrkdir}/cat.tmp
 7 curfile=${wrkdir}/tapelabel
 8 catalog=${wrkdir}/level1Tar.cat
 9 datetime=`date +DATE: %Y-%m-%d%nTIME: %H:%M`
 0 taroptions=--create --verbose --block-size 1 --read-full-blocks --block-compress 
 --gzip --file 
 1 tapedev=/dev/sa0
 2 echo tar ${taroptions}${tapedev} /var/log
 3 tar ${taroptions}${tapedev} /var/log
 4 exit

How about:

0 taroptions=--create --verbose --block-size 1 --read-full-blocks
--block-compress --gzip --file
1 tapedev=/dev/sa0
2 echo tar ${taroptions} ${tapedev} /var/log
3 tar ${taroptions} ${tapedev} /var/log

Works for me.

Joe

-- 
PGP Key : http://www.marcuscom.com/pgp.asc


signature.asc
Description: This is a digitally signed message part


Script Help

2002-10-08 Thread Brendan McAlpine

Hey all,

I am poring over mail logs and trying to pull out all the email 
addresses contained in the log.  Does anyone have any idea how I could 
do this with a shell script?

Thanks

Brendan


To Unsubscribe: send mail to [EMAIL PROTECTED]
with unsubscribe freebsd-questions in the body of the message



Re: Script Help

2002-10-08 Thread Fernando Gleiser

On Tue, 8 Oct 2002, Brendan McAlpine wrote:

 Hey all,

 I am poring over mail logs and trying to pull out all the email
 addresses contained in the log.  Does anyone have any idea how I could
 do this with a shell script?

Untested, and asuming sendmail log format:

#!/usr/bin/perl -w

while () {
if (m/=([^@]+@[^]+)/) {
print $1 \n;
}
}

Translation: for every line, if line matches a '=', followed by a '',
followed by (one or more of anything but a '@' or a '' followed by a '@'
and then one or more of anything but a '')

print the part that matches between the parens



Fer

 Thanks

 Brendan


 To Unsubscribe: send mail to [EMAIL PROTECTED]
 with unsubscribe freebsd-questions in the body of the message



To Unsubscribe: send mail to [EMAIL PROTECTED]
with unsubscribe freebsd-questions in the body of the message