RE: need help w/ simple bash script

2006-06-27 Thread [EMAIL PROTECTED]@mgedv.net
 

> -Original Message-
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On Behalf Of dw
> Sent: Tuesday, June 27, 2006 2:02 PM
> To: freebsd-questions@freebsd.org
> Subject: need help w/ simple bash script
> 
> Hi all,
> 
> I am trying to write a simple bash script that will collate 
> pkg_version 
> reports from all of my servers to generate centralized HTML 
> reports. To 
> format the output, I am trying:
> 
> # REPORT=`pkg_version -v`
> 
> But when I "echo $REPORT", I get:
> 
> Xaw3d-1.5E_1 = up-to-date with port apr-db42-1.2.7_1 = 
> up-to-date with 
> port autoconf-2.13.000227_5 = up-to-date with port autoconf-2.59_2 = 
> up-to-date with port automake-1.9.6 = up-to-date with port 
> bash-3.1.17 = 
> up-to-date with port cvsup-without-gui-16.1h_2 = up-to-date with port 
> db41-4.1.25_3 = up-to-date with port.
> 
> When what I want is:
> 
> Xaw3d-1.5E_1 = up-to-date with port
> apr-db42-1.2.7_1 = up-to-date with port
> autoconf-2.13.000227_5 = up-to-date with port
> autoconf-2.59_2 = up-to-date with port
> automake-1.9.6 = up-to-date with port
> bash-3.1.17 = up-to-date with port
> cvsup-without-gui-16.1h_2 = up-to-date with port
> db41-4.1.25_3 = up-to-date with port
> ...
> ...
> ...
> 
> 
> I've also tried:
> 
> for LINE in `pkg_version -v`; do echo $LINE; done
> 
> but that's even worse; then I get:
> 
> Xaw3d-1.5E_1
> =
> up-to-date
> with
> port
> apr-db42-1.2.7_1
> =
> up-to-date
> with
> port
> autoconf-2.13.000227_5
> =
> up-to-date
> with
> port
> autoconf-2.59_2
> =
> up-to-date
> with
> port
> ...
> ...
> ...
> 
> I know I figured out a technique once before, but I'm banging my head 
> against a wall right now. Thanks for any help.
> 
> -DW
> 
> 
> 


why not just try

pkg_version -v |while read h_line
do
echo "$h_line" >TO SOMEWHERE
done;


you'd be even able to do something like
pkg_version -v |grep -v 'up-to-date with port'|while read h_line
do
blah
done;


have fun ;-)

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


Re: need help w/ simple bash script

2006-06-27 Thread Paul Chvostek
Hiya.

I've been working on a web front-end to aggregate multiple servers'
package update requirements as well.  I'll probably have it ready to
present in another few weeks, if ${DAYJOB} doesn't get in the way.

On Tue, Jun 27, 2006 at 08:01:49AM -0400, dw wrote:
> 
> # REPORT=`pkg_version -v`
> 
> But when I "echo $REPORT", I get:
> 
> Xaw3d-1.5E_1 = up-to-date with port apr-db42-1.2.7_1 = up-to-date with 
...
> When what I want is:
> 
> Xaw3d-1.5E_1 = up-to-date with port
> apr-db42-1.2.7_1 = up-to-date with port
...

Use more quotes.

  REPORT = "`pkg_version -v`"

will protect the newlines.

> for LINE in `pkg_version -v`; do echo $LINE; done

If you feel adventurous, you could to try something like this:

  tmpfile=/tmp/`basename $0`.$$
  trap "rm -f $tmpfile $tmpfile.?" 0 1 2 3 5 15
  pkg_version -v | while read package status text; do
echo "$package $text" >> $tmpfile."$status"
  done

Now you have tempfiles with package lists for the various stati, which
you can parse as you see fit.

Note that you may get better (i.e. more useful) mileage out of something
like:

  pkg_version -vL=

which will show you only what needs to be updated.

-- 
  Paul Chvostek <[EMAIL PROTECTED]>
  it.canadahttp://www.it.ca/

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


need help w/ simple bash script

2006-06-27 Thread dw

Hi all,

I am trying to write a simple bash script that will collate pkg_version 
reports from all of my servers to generate centralized HTML reports. To 
format the output, I am trying:


# REPORT=`pkg_version -v`

But when I "echo $REPORT", I get:

Xaw3d-1.5E_1 = up-to-date with port apr-db42-1.2.7_1 = up-to-date with 
port autoconf-2.13.000227_5 = up-to-date with port autoconf-2.59_2 = 
up-to-date with port automake-1.9.6 = up-to-date with port bash-3.1.17 = 
up-to-date with port cvsup-without-gui-16.1h_2 = up-to-date with port 
db41-4.1.25_3 = up-to-date with port.


When what I want is:

Xaw3d-1.5E_1 = up-to-date with port
apr-db42-1.2.7_1 = up-to-date with port
autoconf-2.13.000227_5 = up-to-date with port
autoconf-2.59_2 = up-to-date with port
automake-1.9.6 = up-to-date with port
bash-3.1.17 = up-to-date with port
cvsup-without-gui-16.1h_2 = up-to-date with port
db41-4.1.25_3 = up-to-date with port
...
...
...


I've also tried:

for LINE in `pkg_version -v`; do echo $LINE; done

but that's even worse; then I get:

Xaw3d-1.5E_1
=
up-to-date
with
port
apr-db42-1.2.7_1
=
up-to-date
with
port
autoconf-2.13.000227_5
=
up-to-date
with
port
autoconf-2.59_2
=
up-to-date
with
port
...
...
...

I know I figured out a technique once before, but I'm banging my head 
against a wall right now. Thanks for any help.


-DW



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