linux-admin.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Scripting question
@ 2003-01-23  5:14 Michael French
  2003-01-23  5:32 ` Andrew B. Cramer
                   ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: Michael French @ 2003-01-23  5:14 UTC (permalink / raw)
  To: linux-admin

    I have a couple of scripts that I am working on that pull data from an
application and print a human readable report from the data.  I have all of
the data pulled and stored in variables, but I am stumped on how to put in
all in one file.  I hope that I can clearly explain this, here goes.

    For one script, I have three pieces of info to report: node name,
customer name, and total data stored.  The first two bits of data are
getting pulled out together and stored in one file.  The third bit is being
calculated and then stored in a second file.  I then get the data in like
this:

NODES=`cat nodeinfo.txt | awk '{print $1}'`
CUSTOMER=`cat nodeinfo.txt | awk '{print $2}'`
MBTOTALS=`cat mbtotals.txt`

I then need to print out a report like:

Nodes        Customer        MB
----------------------------------
node1           customer1        20.0

How can I do this?  I can't seem to figure out how to do it with one for
loop.

    I have another little script I am working on to report restore data and
it has one temp file holding all of the info I need and is greping out about
10 different pieces of data I need before overwriting the temp file with the
info on the next node.  The problem I have run into is that some of the
restores have duplicate data in them so I am going to have to rewrite the
report to put the data in variables and then loop through them to generate a
report just like the one above, except with more variables so you can see
why I am trying to figure out how to do this as cleanly as possible.  Maybe
I am starting off all wrong so feel free to redirect me.  Also, I am using
Korn shell to do this (my only option).

Thanks!

Michael French


^ permalink raw reply	[flat|nested] 11+ messages in thread
* RE: Scripting question
@ 2003-01-23 13:49 johnjulian1
  2003-01-24  2:30 ` Mikhail Romanenko
  0 siblings, 1 reply; 11+ messages in thread
From: johnjulian1 @ 2003-01-23 13:49 UTC (permalink / raw)
  To: "Michael French", linux-admin

I didn't understand all that you were trying to do so here are some general pointers.

Korn shell supports arrays. You could pull your data in seperate arrays for node, cust and mb then do a loop on the array counter.

while loops often work better than for loops.
i=0
while [ -n "$cust[$i]" ]
do print "$node[$i] $cust[$i] $mb[$i]
   i=$(( i + 1 ))
done
"Michael French" <mfrench@ashevillemail.com> wrote:

>    I have a couple of scripts that I am working on that pull data from an
>application and print a human readable report from the data.  I have all of
>the data pulled and stored in variables, but I am stumped on how to put in
>all in one file.  I hope that I can clearly explain this, here goes.
>
>    For one script, I have three pieces of info to report: node name,
>customer name, and total data stored.  The first two bits of data are
>getting pulled out together and stored in one file.  The third bit is being
>calculated and then stored in a second file.  I then get the data in like
>this:
>
>NODES=`cat nodeinfo.txt | awk '{print $1}'`
>CUSTOMER=`cat nodeinfo.txt | awk '{print $2}'`
>MBTOTALS=`cat mbtotals.txt`
>
>I then need to print out a report like:
>
>Nodes        Customer        MB
>----------------------------------
>node1           customer1        20.0
>
>How can I do this?  I can't seem to figure out how to do it with one for
>loop.
>
>    I have another little script I am working on to report restore data and
>it has one temp file holding all of the info I need and is greping out about
>10 different pieces of data I need before overwriting the temp file with the
>info on the next node.  The problem I have run into is that some of the
>restores have duplicate data in them so I am going to have to rewrite the
>report to put the data in variables and then loop through them to generate a
>report just like the one above, except with more variables so you can see
>why I am trying to figure out how to do this as cleanly as possible.  Maybe
>I am starting off all wrong so feel free to redirect me.  Also, I am using
>Korn shell to do this (my only option).
>
>Thanks!
>
>Michael French
>
>-
>To unsubscribe from this list: send the line "unsubscribe linux-admin" in
>the body of a message to majordomo@vger.kernel.org
>More majordomo info at  http://vger.kernel.org/majordomo-info.html
>

__________________________________________________________________
The NEW Netscape 7.0 browser is now available. Upgrade now! http://channels.netscape.com/ns/browsers/download.jsp 

Get your own FREE, personal Netscape Mail account today at http://webmail.netscape.com/

^ permalink raw reply	[flat|nested] 11+ messages in thread
* Scripting Question
@ 2004-03-31 21:15 Scott@Charter
  2004-03-31 22:08 ` Richard Nairn
  0 siblings, 1 reply; 11+ messages in thread
From: Scott@Charter @ 2004-03-31 21:15 UTC (permalink / raw)
  To: Linux-Admin-Group

[-- Attachment #1: Type: text/plain, Size: 459 bytes --]

Thanks for the answers everyone.  Now I need to get a comparison between a
bash script and a Perl script.  I know there probably is no comparison but
it will help me.

Can I get a short script, one in Perl and one in bash that, let's say,
prints the odd numbers between 1 and 10.  That should be pretty short and
sweet.  I don't know Perl, unfortunately.  It's been a while since I
scripted bash too.

So please let me know.

Thanks Again.
Scott  -  Reno, NV

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Scott Smallsreed.vcf --]
[-- Type: text/x-vcard; name="Scott Smallsreed.vcf", Size: 366 bytes --]

BEGIN:VCARD
VERSION:2.1
N:Smallsreed;Scott
FN:Scott Smallsreed
TEL;HOME;VOICE:775-849-8411
TEL;HOME;FAX:775-849-8412
ADR;HOME:;;3030 Chipmunk Dr.;Washoe Valley;Nevada;89704;US
LABEL;HOME;ENCODING=QUOTED-PRINTABLE:3030 Chipmunk Dr.=0D=0AWashoe Valley, Nevada 89704=0D=0AUS
EMAIL;PREF;INTERNET:scott.smallsreed@mindspring.com
REV:20040331T211509Z
END:VCARD

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2004-03-31 22:08 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-01-23  5:14 Scripting question Michael French
2003-01-23  5:32 ` Andrew B. Cramer
2003-01-23  7:40 ` urgrue
2003-01-23  8:38   ` Jude DaShiell
2003-01-24  0:46 ` rich+ml
2003-01-24  0:50   ` rich+ml
2003-01-24  2:34     ` Michael French
  -- strict thread matches above, loose matches on Subject: below --
2003-01-23 13:49 johnjulian1
2003-01-24  2:30 ` Mikhail Romanenko
2004-03-31 21:15 Scripting Question Scott@Charter
2004-03-31 22:08 ` Richard Nairn

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).