nv-l
[Top] [All Lists]

Re: assigning variables in a scripts

To: nv-l@lists.tivoli.com
Subject: Re: assigning variables in a scripts
From: "Ben-Shalom, Omer" <omer.ben-shalom@INTEL.COM>
Date: Wed, 20 Jan 1999 14:07:00 -0800
Reply-to: Discussion of IBM NetView and POLYCENTER Manager on NetView <NV-L@UCSBVM.UCSB.EDU>
Sender: Discussion of IBM NetView and POLYCENTER Manager on NetView <NV-L@UCSBVM.UCSB.EDU>
  being a perl enthusiast I would go for the following options:

  s/^\s+// ;    is a command that will take out any leading spaces in a
  variable.

  open (IN,"<yourfile") ;
  while (<IN>) {
        @words = split (/\s+/,$line) ;
        # or ($word1,$word2,$dontcare,..,$sordx) = split (/\s+/,$line) ; to
        # assign variable names

        # do something with variables where $words[0] is the first and so on
  }

  will take care of the other, as this example shows I think doing perl
  programming for all scripting saves an enormous amount of effort and
should
  be considered.

        Omer





  From: "Lucy Premus" [SMTP:lpremus@METLIFE.COM] at MSXGATE Subject:
  assigning variables in a script
  Date: 1/19/99 7:30:22 AM

  Okay.  I have another question regarding variables and scripts.  But
  before I ask this one, just wondering if anyone knows the answer to my
  previous question?.  How do you remove preceding spaces in a variable?
  Meaning if I have a variable that looks like this
  '                           TRUE', but all I really need is just the word
  TRUE.  How do I get rid of the spaces before the word?

  My other question is if my script is reading a text file and processing
  each line, how do I parse out each word on that line and assign it to a
  variable?  For example, the line looks like this:   'resourcename Jan 15
  10:00:00 EST 1999' and I just want to capture 'resourcename' and assign
  it to one variable and capture  '10:00:00' and assign it to another
  variable.

  BTW....In case anyone is wondering, I do have a Korn Shell programming
  book, but I can't seem to find this information in there.  I'm sure its
  there, in some form, but is it english?   Thanks for all the
  help..................Lucy

<Prev in Thread] Current Thread [Next in Thread>
  • Re: assigning variables in a scripts, Ben-Shalom, Omer <=

Archive operated by Skills 1st Ltd

See also: The NetView Web