07-08-2007
How to parse config variables from external file to shell script
How do i use a config.txt to recursively pass a set of variables to a shell script
eg my config.txt looks like this :
[set_1]
path=c://dataset/set1
v1= a.bin
v2= b.bin
[set_2]
path=c://dataset/set2
v1= xy.bin
v2= abc.bin
[set_3]
..................
and so on .
and my testscript :
#!/bin/bash
.$1
echo $path $v1 $v2
Right now I am able to parse first set of variables . How do i move on to the subsequent set_2 , set_3 ...........
Thanks in advance
pradsh
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
I need to edit a config file using shell script. i.e., Search with the 'key' string and edit the 'value'.
For eg: below is what I have in the config file "configfile.cfg".
Key1=OldValue1
Key2=OldValue2
I want to search for "Key1" and change "OldValue1" to "NewValue1"
Thanks for your... (7 Replies)
Discussion started by: rajeshomallur
7 Replies
2. Shell Programming and Scripting
I'm writing a shell script. I want to put the variables in a separate config files and use those inside my script.
e.g. the config file (temp.conf)will have the values like
mapping=123
file_name=xyz.txt
I want to access these variables in temp.conf(i.e. mapping and file_name) from inside the... (7 Replies)
Discussion started by: badrimohanty
7 Replies
3. Shell Programming and Scripting
Hi there, am trying to parse an Apache 'server' config file. A snippet of the config file is shown below:
.....
ProxyPassReverse /foo http://foo.example.com/bar
.....
.....
RewriteRule ^/(.*) http://www.example.com/$1
RewriteRule /redirect https://www.example1.com/$1
........ (7 Replies)
Discussion started by: jy2k7ca
7 Replies
4. Shell Programming and Scripting
Hi,
I have a config file that has blank, commented lines. I need to escape commented lines, blank lines, parse the remaining lines and store them in variables or array.
the config file contains the following lines.
# config file
# Define Oracle User
ORA_USER=abcde
ORA_PASS=xyzabc... (8 Replies)
Discussion started by: Lakshmi Chowdam
8 Replies
5. Shell Programming and Scripting
I have a script with few pre defined variables.
Also have a config file. Something like this.
# config file
# Define Oracle User
MOD1_TAG=abcde
MOD2_TAG=xyzabc
MOD3_TAG=def
I need to parse the config file and have each of the value copied to different variables.
Please suggest what... (1 Reply)
Discussion started by: souryadipta
1 Replies
6. Shell Programming and Scripting
Hi I am new to shell scripting. There is a requirement to write a shell script to meet follwing needs.Prompt reply shall be highly appreciated.
script that will compare two config files and produce 2 outputs - actual config file and a report indicating changes made.
OS :Susi linux ver 10.3.
... (4 Replies)
Discussion started by: muraliinfy04
4 Replies
7. Shell Programming and Scripting
Hi, I have a script that interacts with a config file in the format:
file1.txt
file2.txt
file3.txt
file4.txt
file5.txt
file6.txt
I would like to return the Category, when given the file name. (11 Replies)
Discussion started by: MoreCowbell
11 Replies
8. Shell Programming and Scripting
Hi All,
#include <iostream> int main() {
std::int foo = 34;
system("mkdir /home/linuxUser/fooDir");
system("vi fooFile")
system("write foo in fooFile")
foo = 43;
foo = read foo from fooFile;
std::cout << "foo = " << foo ; }
result should be
foo = 34
can... (3 Replies)
Discussion started by: linuxUser_
3 Replies
9. UNIX for Dummies Questions & Answers
Dear Unix gurus,
We have a config shell script file which has 30 variables which needs to be passed to master unix shell script that invokes oracle database sessions. So those 30 variables need to go through the database sessions (They are inputs) via a shell script. one of the variable name... (1 Reply)
Discussion started by: dba1981
1 Replies
10. Shell Programming and Scripting
Dear Unix gurus,
We have a config shell script file which has 30 variables which needs to be passed to master unix shell script that invokes oracle database sessions. So those 30 variables need to go through the database sessions (They are inputs) via a shell script. one of the variable name... (1 Reply)
Discussion started by: dba1981
1 Replies
LEARN ABOUT OPENSOLARIS
endusershell
getusershell(3C) Standard C Library Functions getusershell(3C)
NAME
getusershell, setusershell, endusershell - get legal user shells
SYNOPSIS
#include <unistd.h>
char *getusershell(void);
void setusershell(void);
void endusershell(void);
DESCRIPTION
The getusershell() function returns a pointer to a legal user shell as defined by the system manager in the file /etc/shells. If
/etc/shells does not exist, the following locations of the standard system shells are used in its place:
/bin/bash /bin/csh
/bin/jsh /bin/ksh
/bin/ksh93 /bin/pfcsh
/bin/pfksh /bin/pfsh
/bin/sh /bin/tcsh
/bin/zsh /sbin/jsh
/sbin/pfsh /sbin/sh
/usr/bin/bash /usr/bin/csh
/usr/bin/jsh /usr/bin/ksh
/usr/bin/ksh93 /usr/bin/pfcsh
/usr/bin/pfksh /usr/bin/pfsh
/usr/bin/sh /usr/bin/tcsh
/usr/bin/zsh /usr/sfw/bin/zsh
/usr/xpg4/bin/sh
The getusershell() function opens the file /etc/shells, if it exists, and returns the next entry in the list of shells.
The setusershell() function rewinds the file or the list.
The endusershell() function closes the file, frees any memory used by getusershell() and setusershell(), and rewinds the file /etc/shells.
RETURN VALUES
The getusershell() function returns a null pointer on EOF.
BUGS
All information is contained in memory that may be freed with a call to endusershell(), so it must be copied if it is to be saved.
NOTES
Restricted shells should not be listed in /etc/shells.
SunOS 5.11 1 Nov 2007 getusershell(3C)