Import Variables into a script HELP! 
Author Message
 Import Variables into a script HELP!

I am trying to write a script to accept the variables HP OpenView spits out
for SNMP.  They are in the format of $1, $2, $5, etc.  etc.  I wrote a
script on Sun Solaris to do what needs to be done and it worked fine.  But I
am trying to move it over to and NT 2000 platform, and my script will not
accept a variable with a $ in front of it.  Does anyone know of a way to
rename the variable so the windows script will see it as valid?  I am
assuming windows scripting does not allow this character as a variable, but
I'm sure I'm not the only one who has come across this.  There has to be a
way to do this but I don't know how.

HELP PLEASE!  Thanks!



Mon, 01 Aug 2005 09:13:04 GMT  
 Import Variables into a script HELP!
Nevell,

In terms of internal variable names, you can use anything that meets th VBScript
documentation's specs, quoted below:

=======================
Variable names follow the standard rules for naming anything in VBScript. A
variable name:
Must begin with an alphabetic character.
Cannot contain an embedded period.
Must not exceed 255 characters.
Must be unique in the scope in which it is declared.
=======================

If your question really is "what's a naming convention I can use which will be
similar?" to recognize things inside the script, you could prepend "hp" to the
name, and use these as internal names:

hp$1, hp$2, etc.

If the problem is something different, post back.  You can download the full WSH
docs (which include VBScript documentation) from here:

http://msdn.microsoft.com/downloads/sample.asp?url=/msdn-files/027/00...

--
Please respond in the newsgroup so everyone may benefit.
 http://dev.remotenetworktechnology.com
(email requests for support contract information welcomed)
 ----------
 Subscribe to Microsoft's Security Bulletins:
 http://www.microsoft.com/technet/security/bulletin/notify.asp


Quote:
> I am trying to write a script to accept the variables HP OpenView spits out
> for SNMP.  They are in the format of $1, $2, $5, etc.  etc.  I wrote a
> script on Sun Solaris to do what needs to be done and it worked fine.  But I
> am trying to move it over to and NT 2000 platform, and my script will not
> accept a variable with a $ in front of it.  Does anyone know of a way to
> rename the variable so the windows script will see it as valid?  I am
> assuming windows scripting does not allow this character as a variable, but
> I'm sure I'm not the only one who has come across this.  There has to be a
> way to do this but I don't know how.

> HELP PLEASE!  Thanks!



Mon, 01 Aug 2005 10:02:56 GMT  
 Import Variables into a script HELP!
Thanks for responding.  If the snmp variable is sent out of HP Openview as a
$1, $2, etc, would it be the same in the script if it is prefixed with hp$1?
I am unsure but if that would work that wouldn't be a problem.  In my Sun
Solaris system my scripts have just the $1, $2 in them.



Quote:
> Nevell,

> In terms of internal variable names, you can use anything that meets th
VBScript
> documentation's specs, quoted below:

> =======================
> Variable names follow the standard rules for naming anything in VBScript.
A
> variable name:
> Must begin with an alphabetic character.
> Cannot contain an embedded period.
> Must not exceed 255 characters.
> Must be unique in the scope in which it is declared.
> =======================

> If your question really is "what's a naming convention I can use which
will be
> similar?" to recognize things inside the script, you could prepend "hp" to
the
> name, and use these as internal names:

> hp$1, hp$2, etc.

> If the problem is something different, post back.  You can download the
full WSH
> docs (which include VBScript documentation) from here:

http://msdn.microsoft.com/downloads/sample.asp?url=/msdn-files/027/00...
sdncompositedoc.xml

- Show quoted text -

Quote:

> --
> Please respond in the newsgroup so everyone may benefit.
>  http://dev.remotenetworktechnology.com
> (email requests for support contract information welcomed)
>  ----------
>  Subscribe to Microsoft's Security Bulletins:
>  http://www.microsoft.com/technet/security/bulletin/notify.asp



> > I am trying to write a script to accept the variables HP OpenView spits
out
> > for SNMP.  They are in the format of $1, $2, $5, etc.  etc.  I wrote a
> > script on Sun Solaris to do what needs to be done and it worked fine.
But I
> > am trying to move it over to and NT 2000 platform, and my script will
not
> > accept a variable with a $ in front of it.  Does anyone know of a way to
> > rename the variable so the windows script will see it as valid?  I am
> > assuming windows scripting does not allow this character as a variable,
but
> > I'm sure I'm not the only one who has come across this.  There has to be
a
> > way to do this but I don't know how.

> > HELP PLEASE!  Thanks!



Mon, 01 Aug 2005 10:21:45 GMT  
 Import Variables into a script HELP!
How are you trying to import them into your script?

It might be a good idea to post your script so far.

--
Please respond in the newsgroup so everyone may benefit.
 http://dev.remotenetworktechnology.com
(email requests for support contract information welcomed)
 ----------
 Subscribe to Microsoft's Security Bulletins:
 http://www.microsoft.com/technet/security/bulletin/notify.asp


Quote:
> Thanks for responding.  If the snmp variable is sent out of HP Openview as a
> $1, $2, etc, would it be the same in the script if it is prefixed with hp$1?
> I am unsure but if that would work that wouldn't be a problem.  In my Sun
> Solaris system my scripts have just the $1, $2 in them.



> > Nevell,

> > In terms of internal variable names, you can use anything that meets th
> VBScript
> > documentation's specs, quoted below:

> > =======================
> > Variable names follow the standard rules for naming anything in VBScript.
> A
> > variable name:
> > Must begin with an alphabetic character.
> > Cannot contain an embedded period.
> > Must not exceed 255 characters.
> > Must be unique in the scope in which it is declared.
> > =======================

> > If your question really is "what's a naming convention I can use which
> will be
> > similar?" to recognize things inside the script, you could prepend "hp" to
> the
> > name, and use these as internal names:

> > hp$1, hp$2, etc.

> > If the problem is something different, post back.  You can download the
> full WSH
> > docs (which include VBScript documentation) from here:

> http://msdn.microsoft.com/downloads/sample.asp?url=/msdn-files/027/00...
> sdncompositedoc.xml

> > --
> > Please respond in the newsgroup so everyone may benefit.
> >  http://dev.remotenetworktechnology.com
> > (email requests for support contract information welcomed)
> >  ----------
> >  Subscribe to Microsoft's Security Bulletins:
> >  http://www.microsoft.com/technet/security/bulletin/notify.asp



> > > I am trying to write a script to accept the variables HP OpenView spits
> out
> > > for SNMP.  They are in the format of $1, $2, $5, etc.  etc.  I wrote a
> > > script on Sun Solaris to do what needs to be done and it worked fine.
> But I
> > > am trying to move it over to and NT 2000 platform, and my script will
> not
> > > accept a variable with a $ in front of it.  Does anyone know of a way to
> > > rename the variable so the windows script will see it as valid?  I am
> > > assuming windows scripting does not allow this character as a variable,
> but
> > > I'm sure I'm not the only one who has come across this.  There has to be
> a
> > > way to do this but I don't know how.

> > > HELP PLEASE!  Thanks!



Mon, 01 Aug 2005 10:32:29 GMT  
 Import Variables into a script HELP!

Quote:
> Thanks for responding.  If the snmp variable is sent out of HP Openview as a
> $1, $2, etc, would it be the same in the script if it is prefixed with hp$1?
> I am unsure but if that would work that wouldn't be a problem.  In my Sun
> Solaris system my scripts have just the $1, $2 in them.

Actually, I was wrong; I haven't tried to use "$" in a variable name before, and
it does {*filter*}on it in spite of the defined set.

In any case, the real issue here is how you are trying to import the values into
your script.  You can use any naming convention you like internally; you could
make $1-5 into hp1-5.

HOWEVER -

If what you are saying is, "I am running the script and supplying the values as
command line arguments; how do I know inside the script what the first argument
was, what the second argument was, etc.?" then the answer is much simpler.

WSH-hosted scripts have access to WScript's Arguments() collection, which uses a
0-based index.  So if you ran a script like this:

    myscript 1 secondvalue 3rd

inside the script you would have the values accessible as
    WScript.Arguments(0)
which would be 1;
    WScript.Arguments(1)
which would be "secondvalue";
    WScript.Arguments(2)
which would be "3rd".

Is that what you're after?

--
Please respond in the newsgroup so everyone may benefit.
  http://www.*-*-*.com/
(email requests for support contract information welcomed)
 ----------
 Subscribe to Microsoft's Security Bulletins:
  http://www.*-*-*.com/



Mon, 01 Aug 2005 10:44:40 GMT  
 Import Variables into a script HELP!
Well done, Alex. And please keep us posted on you progress, Nevell.

Just a few quick comments about VBScript variables:
1. Variables are declared using the VBScript Dim statement.
2. Declaring variables prior to use is optional providing the Option
Explicit directive is not used.
3. Variable names cannot exceed 255 characters and must start with an upper
or lower case a-z (sorry, no dollar signs:).
4. Kind of a no brainer, but variable names must be unique within the scope
in which the variable is defined.
5. VBScript supports one primary variable -or- data type called the Variant.
Variants can be thought of as general-purpose variables that are not bound
to a specific type. That is, variants can contain many different types of
data, e.g. boolean, integer, long, string, object references, etc. VBScript
automatically selects the most appropriate type based on the context in
which the variable is used.
6. Unlike Visual Basic, you cannot declare a VBScript variable as a specific
type.

-Bob
The System Administration Scripting Guide Team

Microsoft TechNet Script Center
http://www.microsoft.com/technet/scriptcenter

ONLINE version of the 1328 page
Microsoft Windows 2000 Scripting Guide, Automating System Administration
http://www.microsoft.com/technet/scriptcenter/scrguide/sagsas_overvie...



Quote:
> Nevell,

> I'm including the new "microsoft.public.windows.server.scripting"
newsgroup in
> this response.  This group is a new one focused on Windows administrative
> scripting issues, and fits well with the topic of your post.

> I also re-attached your attachment.  My response is at the bottom.



> > Ok, attached is my script in text format that I currently run in my Sun
> > Solaris System. Its in a log file text format for purposes here.  This
does
> > a variety of things with variables like logging things to a text file,
> > holding pages till a specific time, and paging immediately.   I'm trying
to
> > convert it over to Win NT using a vbs script because I am converting
from
> > Sun to NT.  Basically, its pretty easy to understand, but if you look at
the
> > $1 and $2 etc variables, these are passed from HP Openview as SNMP
traps,
> > which mean something, and I get paged via pager.  The $1 node down would
> > mean this...the variable of the node would be passed from Openview and I
> > would get the node name instead of $1 node down.  I would get ROUTER
node
> > down.  The variables get passed from Openview and are standard Trap snmp
> > variables.  Is there a way to do this
> > with Windows Scripting.  I am stuck with this one this is a real
thinker.

> > Anyone ... any help is greatly appreciated on this one, I am out of
ideas.

> > Thanks!



> > > I am trying to write a script to accept the variables HP OpenView
spits
> > out
> > > for SNMP.  They are in the format of $1, $2, $5, etc.  etc.  I wrote a
> > > script on Sun Solaris to do what needs to be done and it worked fine.
But
> > I
> > > am trying to move it over to and NT 2000 platform, and my script will
not
> > > accept a variable with a $ in front of it.  Does anyone know of a way
to
> > > rename the variable so the windows script will see it as valid?  I am
> > > assuming windows scripting does not allow this character as a
variable,
> > but
> > > I'm sure I'm not the only one who has come across this.  There has to
be a
> > > way to do this but I don't know how.

> > > HELP PLEASE!  Thanks!

> I'm not sure what you're using VBScript-side to do this, but from glancing
at
> that file (what scripting language is it - a bash shellscript?) it appears
that
> you call it with two command line arguments.

> # Called with $1 - Ip address or Nodename
> #             $2 - Message

> Your scripting language apparently keeps any commandline arguments it had
at
> execution stuck in variables named $1, $2, etc.

> WSH-hosted scripting languages have that available to them as WScript's
> Arguments() collection.  If you will use the same calling syntax, the
> IP/nodename will be available inside the script as WScript.Arguments(0)
and the
> message will be available as WScript.Arguments(1).

> I've answered the precise question you asked, but I think there may be
more
> details to this.  Reading behind the lines, here is what I think you are
doing
> right now.  You probably started similarly to what I would have done
coming to
> WSH and VBScript "cold"; if you know a little bit of some version of
Basic, you
> would have tried rewriting the script in chunks which "looked" Basicish.
You
> immediately ran into problems because variable names don't work the same
way.

> If this is roughly true, then you will have several other problems as you
go.
> First, you want to get the WSH documentation to help you understand
things:

http://msdn.microsoft.com/downloads/sample.asp?url=/msdn-files/027/00...
sdncompositedoc.xml

- Show quoted text -

Quote:

> Second, you need to understand the difference between WSH and VBScript.

> VBScript is a language, and can manipulate any information directly
available to
> it, either already written into the script or imported somehow. WSH, on
the
> other hand, is a host.  That means that it controls the interfaces for
> interacting with everything "out there".  This will eventually be
important to
> you.

> The externals you need to access will be files and possibly executables.
Since
> your Windows system can't run the /usr/pagexxx executables or scripts on
the Sun
> system, I assume you have something local to Windows you will be using
from HP.

> Post back as you need to, or even just to say "huh?".  This is not an easy
> script for a beginner to "port" due to some details, but it is very short
and
> illustrates some important fundamentals of Windows scripting, so if we can
talk
> you through it you should find it an excellent learning experience.

> In any case, here is a direct translation of the first functional lines of
your
> script.  I quit before the if-then statements because you are using a flag
file
> and the details of that are hard to determine; I also have no clue what
> filesystem your files will be stored on...

> '*****************************************
> ' Called with WScript.Arguments(0) - Ip address or Nodename
> '             WScript.Arguments(1) - Message
> '
> '****************************************
> ' Now() gives date and time both
> Fulldat = Now()

> ' Let's get the first argument into a variable named "nodename"
> nodename = WScript.Arguments(0)
> ' ... and the second into a variable named "message"
> message = WScript.Arguments(1)

> --
> Please respond in the newsgroup so everyone may benefit.
>  http://dev.remotenetworktechnology.com
> (email requests for support contract information welcomed)
>  ----------
>  Subscribe to Microsoft's Security Bulletins:
>  http://www.microsoft.com/technet/security/bulletin/notify.asp



Mon, 01 Aug 2005 23:02:55 GMT  
 Import Variables into a script HELP!
Doh! Perhaps I should have also mentioned VBScript variable names are NOT
case sensitive.



Quote:
> Well done, Alex. And please keep us posted on you progress, Nevell.

> Just a few quick comments about VBScript variables:
> 1. Variables are declared using the VBScript Dim statement.
> 2. Declaring variables prior to use is optional providing the Option
> Explicit directive is not used.
> 3. Variable names cannot exceed 255 characters and must start with an
upper
> or lower case a-z (sorry, no dollar signs:).
> 4. Kind of a no brainer, but variable names must be unique within the
scope
> in which the variable is defined.
> 5. VBScript supports one primary variable -or- data type called the
Variant.
> Variants can be thought of as general-purpose variables that are not bound
> to a specific type. That is, variants can contain many different types of
> data, e.g. boolean, integer, long, string, object references, etc.
VBScript
> automatically selects the most appropriate type based on the context in
> which the variable is used.
> 6. Unlike Visual Basic, you cannot declare a VBScript variable as a
specific
> type.

> -Bob
> The System Administration Scripting Guide Team

> Microsoft TechNet Script Center
> http://www.microsoft.com/technet/scriptcenter

> ONLINE version of the 1328 page
> Microsoft Windows 2000 Scripting Guide, Automating System Administration
> http://www.microsoft.com/technet/scriptcenter/scrguide/sagsas_overvie...



> > Nevell,

> > I'm including the new "microsoft.public.windows.server.scripting"
> newsgroup in
> > this response.  This group is a new one focused on Windows
administrative
> > scripting issues, and fits well with the topic of your post.

> > I also re-attached your attachment.  My response is at the bottom.



> > > Ok, attached is my script in text format that I currently run in my
Sun
> > > Solaris System. Its in a log file text format for purposes here.  This
> does
> > > a variety of things with variables like logging things to a text file,
> > > holding pages till a specific time, and paging immediately.   I'm
trying
> to
> > > convert it over to Win NT using a vbs script because I am converting
> from
> > > Sun to NT.  Basically, its pretty easy to understand, but if you look
at
> the
> > > $1 and $2 etc variables, these are passed from HP Openview as SNMP
> traps,
> > > which mean something, and I get paged via pager.  The $1 node down
would
> > > mean this...the variable of the node would be passed from Openview and
I
> > > would get the node name instead of $1 node down.  I would get ROUTER
> node
> > > down.  The variables get passed from Openview and are standard Trap
snmp
> > > variables.  Is there a way to do this
> > > with Windows Scripting.  I am stuck with this one this is a real
> thinker.

> > > Anyone ... any help is greatly appreciated on this one, I am out of
> ideas.

> > > Thanks!



> > > > I am trying to write a script to accept the variables HP OpenView
> spits
> > > out
> > > > for SNMP.  They are in the format of $1, $2, $5, etc.  etc.  I wrote
a
> > > > script on Sun Solaris to do what needs to be done and it worked
fine.
> But
> > > I
> > > > am trying to move it over to and NT 2000 platform, and my script
will
> not
> > > > accept a variable with a $ in front of it.  Does anyone know of a
way
> to
> > > > rename the variable so the windows script will see it as valid?  I
am
> > > > assuming windows scripting does not allow this character as a
> variable,
> > > but
> > > > I'm sure I'm not the only one who has come across this.  There has
to
> be a
> > > > way to do this but I don't know how.

> > > > HELP PLEASE!  Thanks!

> > I'm not sure what you're using VBScript-side to do this, but from
glancing
> at
> > that file (what scripting language is it - a bash shellscript?) it
appears
> that
> > you call it with two command line arguments.

> > # Called with $1 - Ip address or Nodename
> > #             $2 - Message

> > Your scripting language apparently keeps any commandline arguments it
had
> at
> > execution stuck in variables named $1, $2, etc.

> > WSH-hosted scripting languages have that available to them as WScript's
> > Arguments() collection.  If you will use the same calling syntax, the
> > IP/nodename will be available inside the script as WScript.Arguments(0)
> and the
> > message will be available as WScript.Arguments(1).

> > I've answered the precise question you asked, but I think there may be
> more
> > details to this.  Reading behind the lines, here is what I think you are
> doing
> > right now.  You probably started similarly to what I would have done
> coming to
> > WSH and VBScript "cold"; if you know a little bit of some version of
> Basic, you
> > would have tried rewriting the script in chunks which "looked" Basicish.
> You
> > immediately ran into problems because variable names don't work the same
> way.

> > If this is roughly true, then you will have several other problems as
you
> go.
> > First, you want to get the WSH documentation to help you understand
> things:

http://msdn.microsoft.com/downloads/sample.asp?url=/msdn-files/027/00...

- Show quoted text -

Quote:
> sdncompositedoc.xml

> > Second, you need to understand the difference between WSH and VBScript.

> > VBScript is a language, and can manipulate any information directly
> available to
> > it, either already written into the script or imported somehow. WSH, on
> the
> > other hand, is a host.  That means that it controls the interfaces for
> > interacting with everything "out there".  This will eventually be
> important to
> > you.

> > The externals you need to access will be files and possibly executables.
> Since
> > your Windows system can't run the /usr/pagexxx executables or scripts on
> the Sun
> > system, I assume you have something local to Windows you will be using
> from HP.

> > Post back as you need to, or even just to say "huh?".  This is not an
easy
> > script for a beginner to "port" due to some details, but it is very
short
> and
> > illustrates some important fundamentals of Windows scripting, so if we
can
> talk
> > you through it you should find it an excellent learning experience.

> > In any case, here is a direct translation of the first functional lines
of
> your
> > script.  I quit before the if-then statements because you are using a
flag
> file
> > and the details of that are hard to determine; I also have no clue what
> > filesystem your files will be stored on...

> > '*****************************************
> > ' Called with WScript.Arguments(0) - Ip address or Nodename
> > '             WScript.Arguments(1) - Message
> > '
> > '****************************************
> > ' Now() gives date and time both
> > Fulldat = Now()

> > ' Let's get the first argument into a variable named "nodename"
> > nodename = WScript.Arguments(0)
> > ' ... and the second into a variable named "message"
> > message = WScript.Arguments(1)

> > --
> > Please respond in the newsgroup so everyone may benefit.
> >  http://dev.remotenetworktechnology.com
> > (email requests for support contract information welcomed)
> >  ----------
> >  Subscribe to Microsoft's Security Bulletins:
> >  http://www.microsoft.com/technet/security/bulletin/notify.asp



Mon, 01 Aug 2005 23:18:58 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. Assigning Client Script Variables to Application level variables inside of a Client Script

2. Pass client script variable to server script variable

3. Help: problem passing variable between client/server scripts

4. Help: problem passing variable between client/server scripts

5. scripting help needed__newbie question on variables

6. Help with importing excel into access using VBscript

7. help: how to import an image file in a PS file

8. Help import Directory and file names into a Doc file

9. HELP! Importing EPS in WFW6

10. Help a new kid import delimted file into Excel using WSH

11. Help: Import *.eps into Designer 3.1

12. HELP: EPS importing to WINWORD

 

 
Powered by phpBB® Forum Software