![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Advanced & Expert Users Expert-to-Expert. Learn advanced UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to Read a config file and Assign to Variable | redlotus72 | UNIX for Dummies Questions & Answers | 1 | 11-13-2006 12:14 PM |
| rename files using shell scripting | gfhgfnhhn | Shell Programming and Scripting | 4 | 07-04-2006 04:37 PM |
| why shell scripting takes more time to read a file | brkavi_in | Shell Programming and Scripting | 1 | 06-23-2006 08:20 AM |
| difference between AIX shell scripting and Unix shell scripting. | haroonec | Shell Programming and Scripting | 2 | 04-12-2006 08:12 AM |
| new LAN, where are the config files? | softarch | UNIX for Dummies Questions & Answers | 3 | 03-27-2001 02:36 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
Hello Friends
I am new to this forum and this is my first post. I have to write a script in which i have to read data from a configuration ( .cfg) file. And also i have to execute/call some already written scripts from this script. Can you people plpease help me on this regards. Thanks in Advance. Manish |
|
||||
|
Hello Friend
Thanks for reply I am using Unix/Solaris plateform config file format is like this ######################## config.cfg servername = filepath = student name1 #student attributes age = class= student name2 age = class = #################### i have to use unix shell scripting. first i have to read that server and filepath.. after that i have to access these students and their corresponding attributes. so now can you please help me further. Thanks in advance. Manish |
|
||||
|
if you can get the config file like this..you may use below script.
config file format is like this ######################## config.cfg servername = filepath = #student attributes student name1 age = student name1 class= #student name2 student name2 age = student name2 class = ############################### while read line < configfile do `echo $line | awk -F"=" '{print $1}'`=`echo $line | awk -F"=" '{print $2}'` # This would assign servername = < The value you specified > & so for all.. done Now use those varibales in your script after the loop... |
|
|||||
|
Quote:
How you read the data depends on how the .cfg file is written. I use .cfg files written as shell scripts which I just source, e.g.: Code:
. ${0##*/}.cfg
Code:
while IFS= read -r line do : do whatever is necessary to interpret the line here done < "$configfilename" |
| Sponsored Links | ||
|
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|