Accessing Variables from .conf file

I can't figure out how to access variables that are stored in a separate file. Can someone let me in on the secret? Please, and thank you.

-Kevin

if they're asking for system environment variables, you can echo the variables and find the path, or i believe you can use "set env" commands. i haven't needed to do that very often though. i might also be mis-understanding what you're asking and be completely way off base. :slight_smile: remember to export your variables as well.

I need to define variables in a file called usermon.conf and then read in the variables from my main program to use there. I can do the rest of the program, by defining the variables in the program, but I can't figure out how to read in variables from another file.

Example contents of a config file name my.config
_____________________________
Some config data
_____________________________

In program that needs config file info
___________________
#!/bin/ksh
#my example program
read configline <my.config
echo "The config data is $configline"
___________________

Another example with same config file
_____________________________
#!/bin/ksh
#my second example program
read one two three<my.config
echo "The first word was $one"
echo "The second word was $two"
echo "The third word was $three"
_____________________________

can't you just source the file like this

#!/usr/bin/ksh

. usermon.conf     #reads the file into the current script

usermon.conf should contain something like this:

myvar1="whatever1"
myvar2="whatever2"
myvar3="whatever3"

if you're not using ksh, you'll want to use 'source' instead of '.'

i could be completely wrong... i need to install unix at home so i can
verify the crap i'm trying to remember from work!

so, for example, if I were to do

source usermon.conf

it should work?

or how should I be using it, because at present it doesn't work right.

Thanks.

Thanks for the help. I got it working. I had an error in my conf file that was causing the source usermon.conf to not work.

Thanks

-Kevin

Glad to hear it worked... I wasn't totally sure!