Re: .ini file to read script values

From: Nic Roche (nicroche_at_hotmail.com)
Date: 03/09/05


Date: Wed, 9 Mar 2005 22:58:02 +1000


> using a .ini file to hold the values which in turn can be
> read by my scripts. I.E:

XML is a natural for things like this.

With the MSXML Parser:

    For reading - SelectSingleNode.
    If a web app use FreeThreadedDOMDocument
    if not use DOMDocument.

If you want to learn more code can be posted.

Nic Roche

"wouter" <anonymous@discussions.microsoft.com> wrote in message
news:5d6e01c52496$4764f460$a601280a@phx.gbl...
> Hi,
>
> I have created a few scripts for monitoring purposes that
> need input like hostname, logfile path name, etc. Instead
> of hardcoding all values into each script I thought about
> using a .ini file to hold the values which in turn can be
> read by my scripts. I.E:
>
> ********** start .ini file **********
> [hostname]
> myserver1
>
> [logfile path]
> C:\folder\logfiles
>
> ********** end .ini file **********
>
> The scripts use the following code to read the .ini file:
>
> ********** script example **********
>
> Set objFSO = CreateObject("Scripting.FileSystemObject")
>
> strINIfile = "C:\folder\file.ini"
>
> ' Open INI file to retrieve string values
> Set objFSO = CreateObject("Scripting.FileSystemObject")
> Set objTextFile = objFSO.OpenTextFile(strINIfile,
> OPEN_FILE_FOR_READING)
>
> Do Until objTextFile.AtEndOfStream
>
> strText = objTextFile.ReadLine
>
> If Instr(strText, "[hostname]") Then
> strLogPath = objTextFile.ReadLine
> End If
>
> If Instr(strText, "[logfile path]") Then
> strSchemaPath = objTextFile.Readline
> Exit Do
> End If
>
> Loop
>
> objTextFile.Close
>
> Set objTextFile = Nothing
> Set objFSO = Nothing
>
> ********** end script example **********
>
> This all works very nice, but to me it looks like a little
> bit of spaghetti-programming; does anyone know a nicer
> (more professional) way of achieving the same result?
>
> TIA,
> Wouter



Relevant Pages

  • Re: Idea for FreeBSD
    ... I am A FreeBSD administrator as well as a Solaris Administrator. ... is take all the rc.d scripts and puts them into ... Everything is converted to XML ... better format, you need to start by showing that said format is better ...
    (freebsd-hackers)
  • Re: cgi and headers
    ... i'm starting to work with python cgi scripts using ajax. ... explorer thing doesn;t process the xml unless it gets back the xml header. ...
    (comp.lang.python)
  • Re: Sorting
    ... Here's how to load an XSLT stylesheet into an XslTransform object ... > I am not familiar with sorting using XSL. ... >>> I have an xml file as listed below. ... This is a list of scripts. ...
    (microsoft.public.dotnet.framework)
  • Re: Sorting
    ... Here's how to load an XSLT stylesheet into an XslTransform object ... > I am not familiar with sorting using XSL. ... >>> I have an xml file as listed below. ... This is a list of scripts. ...
    (microsoft.public.dotnet.general)
  • Re: Sorting
    ... Here's how to load an XSLT stylesheet into an XslTransform object ... > I am not familiar with sorting using XSL. ... >>> I have an xml file as listed below. ... This is a list of scripts. ...
    (microsoft.public.dotnet.framework.clr)