The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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 and shell scripting languages 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 12-02-2008 12:02 PM
Accessing Shell Variables in awk or sed nasersh Shell Programming and Scripting 3 05-05-2008 07:44 AM
snmp ... mib2c.scalar.conf, how manipulate variables zainab IP Networking 0 04-12-2008 12:51 AM
accessing unix variables in oracle ravi raj kumar High Level Programming 1 02-06-2008 11:05 AM
accessing ksh variables from awk trupti wagh Shell Programming and Scripting 1 02-26-2007 04:11 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 01-16-2008
wayne1411 wayne1411 is offline
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
  #2 (permalink)  
Old 01-16-2008
psychorugger psychorugger is offline
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.
  #3 (permalink)  
Old 01-16-2008
wayne1411 wayne1411 is offline
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.
  #4 (permalink)  
Old 01-16-2008
n1djs n1djs is offline
Registered User
  
 

Join Date: Nov 2007
Posts: 12
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"
_____________________________
  #5 (permalink)  
Old 01-16-2008
insamniac insamniac is offline
Registered User
  
 

Join Date: Aug 2006
Posts: 14
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!
  #6 (permalink)  
Old 01-30-2008
wayne1411 wayne1411 is offline
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.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 03:37 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0