It is currently Sat, 09 Dec 2023 04:14:07 GMT

Author Message
 How do I read a ini file to initialize variables
I have the following file that I want to read in as variables in a Bourne

$ cat currentip.conf

1.  Is there a way to somehow include that file so that I'll have
$current_ip variable set
to the value of xx.xx.xx.xx?

2.  I am trying to modify a file in a directory owned by ROOT with a script
that will run from cron.  Whats best way to accomplish this?

Thanks in advance,

 Wed, 22 Sep 2004 12:10:28 GMT   
 How do I read a ini file to initialize variables

       . currentip.conf

    But be sure that you have control over the contents of the file,
    and that no-one can introduce malicious code into it.

    If you can't be sure of that, use something that only assigns
    variables you designate, and doesn't execute any other code:

        while read line
            case $line in
               current_ip=*) current_ip=${line#*=} ;;
               other_var=*) other_var=${line#*=} ;;
        done < currentip.conf

    If you don't have a POSIX shell (/bin/sh often is), use:

        var=`echo "$line" | cut -d= -f2-`

    Put the job in root's crontab.

    If you don't have the authority to do that, you probably shouldn't
    be messing around with that directory.

        Chris F.A. Johnson                    

 Wed, 22 Sep 2004 13:27:33 GMT   
   [ 2 post ] 

Similar Threads

1. Accelerated-X 1.3 is not reading the ini-file

2. Reading a Microsoft ini file

3. Reading ini type file

4. How to read .INI files under Linux

5. initialize the global variables in .so files

6. Read Variables from a file (config file)

7. iODBC config not updating odbc.ini ot odbcinst.ini

8. Initializing ksh variables

9. Read line of a file into a variable

10. reading a file into a variable

Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software