The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Accessing PL/SQL OUT variables in Korn Shell Script bright_future UNIX for Advanced & Expert Users 4 2 Days Ago 09:02 AM
Accessing Shell Variables in awk or sed nasersh Shell Programming and Scripting 3 05-05-2008 04:44 AM
snmp ... mib2c.scalar.conf, how manipulate variables zainab IP Networking 0 04-11-2008 09:51 PM
accessing unix variables in oracle ravi raj kumar High Level Programming 1 02-06-2008 08:05 AM
accessing ksh variables from awk trupti wagh Shell Programming and Scripting 1 02-26-2007 01:11 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 01-16-2008
Registered User
 

Join Date: Dec 2007
Posts: 9
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
Reply With Quote
Forum Sponsor
  #2  
Old 01-16-2008
Registered User
 

Join Date: Jul 2007
Posts: 6
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. remember to export your variables as well.
Reply With Quote
  #3  
Old 01-16-2008
Registered User
 

Join Date: Dec 2007
Posts: 9
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.
Reply With Quote
  #4  
Old 01-16-2008
Registered User
 

Join Date: Nov 2007
Posts: 10
One example of many ways to read config data

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"
_____________________________
Reply With Quote
  #5  
Old 01-16-2008
Registered User
 

Join Date: Aug 2006
Posts: 12
can't you just source the file like this
Code:
#!/usr/bin/ksh

. usermon.conf     #reads the file into the current script
usermon.conf should contain something like this:
Code:
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!
Reply With Quote
  #6  
Old 01-30-2008
Registered User
 

Join Date: Dec 2007
Posts: 9
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.
Reply With Quote
  #7  
Old 01-30-2008
Registered User
 

Join Date: Dec 2007
Posts: 9
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
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 06:49 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0