ADSM-L

Re: Need a quick help on a script.

2004-03-22 07:49:56
Subject: Re: Need a quick help on a script.
From: "Doyle, Patrick" <pat.doyle AT EAGLESTAR DOT IE>
To: ADSM-L AT VM.MARIST DOT EDU
Date: Mon, 22 Mar 2004 12:33:34 +0000
Have you tried this with your shell?

substring=${bigstring:0,2}


${parameter:offset}
${parameter:offset:length}
Expands to up to length characters of parameter starting at the character
specified by offset. If length is omitted, expands to the substring of
parameter starting at the character specified by offset. length and offset
are arithmetic expressions (see section 6.5 Shell Arithmetic). This is
referred to as Substring Expansion.
length must evaluate to a number greater than or equal to zero. If offset
evaluates to a number less than zero, the value is used as an offset from
the end of the value of parameter. If parameter is `@', the result is length
positional parameters beginning at offset. If parameter is an array name
indexed by `@' or `*', the result is the length members of the array
beginning with ${parameter[offset]}. Substring indexing is zero-based unless
the positional parameters are used, in which case the indexing starts at 1.



-----Original Message-----
From: VANDEMAN, MIKE (SBCSI) [mailto:mv2371 AT SBC DOT COM]
Sent: 18 March 2004 20:20
To: ADSM-L AT VM.MARIST DOT EDU
Subject: Re: Need a quick help on a script.


It's stupid that UNIX doesn't have a simple way of doing this! Try:

substring = `echo $variable | cut -c 1-2`
if [[ "$substring" = "LT" ]]; then
    ...

If someone knows a simpler way to do this, that is also easy to understand,
I would like to know about it!

Mike Vandeman
510-784-3172
UNIX SSS
>(888) 226-8649 - SSS Helpdesk
>


-----Original Message-----
From: MC Matt Cooper (2838) [mailto:Matt.Cooper AT AMGREETINGS DOT COM]
Sent: Wednesday, March 10, 2004 9:18 AM
To: ADSM-L AT VM.MARIST DOT EDU
Subject: Need a quick help on a script.


 Hello all,
       I am not that good at scripting so this  will be real easy to
someone.   IF anyone knows where I lookup all the scripting commands I
could go a lot further.  I am used to doing things like this in SAS on
the MF.....

I need  to inspect a variable (the node name) for the first 2 characters
= LT or the first 5 characters = CLELT to do the script line otherwise
don't do the sscript line.

something like, but just inspecting the first 2 or 5 characters of the
node name which is the $1 varaible
IF $1 = LT  then  def assoc executives executives-noon $1
IF $1 = CLELT then  def assoc executives executives-noon $1


any help would be greatly appreciated.
Matt





      I scripted the processes for adding new PC nodes to TSM.  It adds
the node and puts it in a backup schedule.  This works fine.  Now things
are differnent and they let me move all PC backups to nights.  Which
works great until you look at 50 or so  DIFFERENT laptops that go home
on occasion.  So what I do is I put a 1 a day limit on backups every
morning ( and take it off in the afternoon).  This lets all PCs try to
backup at night, but if they don't, try again at noon.  So I need my
script to put LAPTOPS  (node name starts with LT or CLELT) in 2 scripts.


**********************************************************************
The contents of this e-mail and possible associated attachments
are for the addressee only. The integrity of this non-encrypted
message cannot be guaranteed on the internet.
Eagle Star Insurance Company (Ireland) Limited is therefore
not responsible for the contents. If you are not the intended recipient,
please delete this e-mail and notify the sender

**********************************************************************

<Prev in Thread] Current Thread [Next in Thread>