Sponsored Content
Top Forums Shell Programming and Scripting Help with dynamic configure cfg files Post 302423376 by suryanarayan on Friday 21st of May 2010 01:12:17 AM
Old 05-21-2010
Quote:
Originally Posted by rdcwayx
from the input file, what's the output you expect?

if the session grouped by "----------------------"
Hi rdcwayx;
Actually i am expecting filename first from input file and search in bin folder for that filename,if found,then expecting sectionname from input file and again search that section available in that filename,if found,then iam expecting all parameter's from input file(parameter's are reside in input file is like this,may be in between two sections || may be in between sectionname and filename || section name and eof),then i am appending/inserting those parameter's in that section(destination file's section) .
Again in destination file,many probality,means taht file consist only many || one sectionname(like [charge]) and parameter's.when we found sectionname from destination file,we have to check the position where we insert/append parameter's taking from input file.again we encounter multiple section and finally eof in destination file.

---------- Post updated at 12:12 AM ---------- Previous update was at 12:02 AM ----------

Quote:
Originally Posted by frans
Should this act as you want?
Code:
#!/bin/bash
read -p "Section name: " SECTION
read -p "File name: " FILE
until [ "$L" = "filename = $FILE" ]; do read L; done # seek file name
until [ "$L" = "sectionname = [$SECTION]" ]; do read L; done # seek section name
IFS='='
while read A B
do
    [ "$VAR" = filename ] || [ "$VAR" = sectionname ] && break # if next file or section encountered
    eval "$A=${B:1}" # ${B:1} to cut the first char (space)
done < configuration.cfg

---------- Post updated at 19:55 ---------- Previous update was at 19:42 ----------

If there were no spaces around the '=', you could simply do somethin like
Code:
read
eval "$REPLY"

Hi frans;
I am not expecting input from console,input is file(configure.cfg) and changes will happen in bin/filename,comes from configure.cfg.
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

How to Read config (.cfg) files using shell scripting

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... (5 Replies)
Discussion started by: smallwonder
5 Replies

2. HP-UX

dynamic names for .tar.gz files?

Hi All, I have a requirement to zip and compress files with dynamic names (which includes date and time component in their names) needs to be compressed with same name. for example I have a file T.30.SLS_ORD.SO.27.2_2_2.20080623.041415.dat which needs to archived as... (1 Reply)
Discussion started by: srinivas_paluku
1 Replies

3. UNIX for Dummies Questions & Answers

Problem with shared dynamic library files

I am having a major problem. Most of the commands that i am running on my centos 5 system is giving the error of type: <dynamic shared library file>:open failed: No such file or directory For example: libgcc_s.so.1: open failed: No such file or directory How can i solve this? (6 Replies)
Discussion started by: proactiveaditya
6 Replies

4. UNIX for Advanced & Expert Users

Dynamic Downloading and executing of ELF files

Dear Group, I want to prepare an ELF file which can be downloaded dynamically to any address in the moemory and executes as a new task/thread/process. 1) for this what are all the compileation, linker options while building the ELF file? 2) which parts of ELF file has to modified while... (1 Reply)
Discussion started by: ravinder.are
1 Replies

5. BSD

configure /usr/local/etc/be-agent.cfg

hi Howto configure Ralus at /usr/local/etc/be-agent.cfg on freeBSD 7.0 for Backup Exec 9.1? I've tried the following: # cat /usr/local/etc/be-agent.cfg name bsd.domain export / as root export /usr as usr export /var as var export /tmp as tmp force_address 10.10.1.50 tell... (0 Replies)
Discussion started by: ccc
0 Replies

6. Shell Programming and Scripting

Help - Using Find command on dynamic files on KSH

Hi Forum. When I run the following find command, I get the desired results: find . \( -name a.out -o -name '*.o' -o -name 'core' \) -type f -ls I want for my script to dynamically calculate and assign a variable var1 to contain all the files that I want to search instead of hard-coding. ... (2 Replies)
Discussion started by: pchang
2 Replies

7. Red Hat

Help in ANACONDA-ks.cfg

i have automated installation of my proprietory linux.. using PXE. it all goes well. but after complete installation, while using the admin interface.. i am facing display problems. is it due to package dependencies.? or i have to write post script in anaconda-ks.cfg file??? can some one tell... (10 Replies)
Discussion started by: jayesh_j
10 Replies

8. Solaris

Configure network in unix with dynamic ip on my DHCP server?

can anyone tell me how can i configure network in unix with dynamic ip on my DHCP server?? (7 Replies)
Discussion started by: Reham.Donia
7 Replies

9. Shell Programming and Scripting

Help Dynamic looping based on files

Hi I have to run the script (a part of the code) in a loop for the no of times the files present in the directory, by taking one file and process and next another file. For example, if we do ls and the result have: $ls abc.dat def.dat ghi.dat The script code should loop for 3... (4 Replies)
Discussion started by: karumudi7
4 Replies

10. Red Hat

Kickstart using anaconda-ks.cfg

Heyas I'm trying to build a live image using livecd-tools (livecd-creator), but this time i'd like to reuse the /root/anaconda-ks.cfg. System: Fedora 3.16.7-200.fc20.x86_64 The building starts, the download begins, but it fails with networking. MAIN.ks # Based on: fedora-live-base.ks... (0 Replies)
Discussion started by: sea
0 Replies
CLIENT-LOCAL.CFG(5)						File Formats Manual					       CLIENT-LOCAL.CFG(5)

NAME
client-local.cfg - Local configuration settings for Xymon clients SYNOPSIS
~xymon/server/etc/client-local.cfg DESCRIPTION
The client-local.cfg file contains settings that are used by each Xymon client when it runs on a monitored host. It provides a convenient way of configuring clients from a central location without having to setup special configuration maintenance tools on all clients. The client-local.cfg file is currently used to configure what logfiles the client should fetch data from, to be used as the basis for the "msgs" status column; and to configure which files and directories are being monitored in the "files" status column. Note that there is a dependency between the client-local.cfg file and the hobbit-clients.cfg(5) file. When monitoring e.g. a logfile, you must first enter it into the client-local.cfg file, to trigger the Xymon client into reporting any data about the logfile. Next, you must configure hobbit-clients.cfg so the Xymon server knows what to look for in the file data sent by the client. So: client-local.cfg defines what raw data is collected by the client, and hobbit-clients.cfg defines how to analyze them. PROPAGATION TO CLIENTS
The client-local.cfg file resides on the Xymon server. When clients connect to the Xymon server to send in their client data, they will receive part of this file back from the Xymon server. The configuration received by the client is then used the next time the client runs. This method of propagating the configuration means that there is a delay of up to two poll cycles (i.e. 5-10 minutes) from a configuration change is entered into the client-local.cfg file, and until you see the result in the status messages reported by the client. FILE FORMAT
The file is divided into sections, delimited by "[name]" lines. A section name can be either an operating system identifier - linux, solaris, hp-ux, aix, freebsd, openbsd, netbsd, darwin - or a hostname. When deciding which section to send to a client, Xymon will first look for a section named after the hostname of the client; if such a section does not exist, it will look for a section named by the oper- ating system of the client. So you can configure special configurations for individual hosts, and have a default configuration for all other hosts of a certain type. Apart from the section delimiter, the file format is free-form, or rather it is defined by the tools that make use of the configuration. LOGFILE CONFIGURATION ENTRIES
A logfile configuration entry looks like this: log:/var/log/messages:10240 ignore MARK trigger Oops The log:FILENAME:SIZE line defines the filename of the log, and the maximum amount of data (in bytes) to send to the Xymon server. FILENAME is usually an explicit full-path filename on the client. If it is enclosed in backticks, it is a command which the Xymon client runs and each line of output from this command is then used as a filename. This allows scripting which files to monitor, e.g. if you have logfiles that are named with some sort of timestamp. The ignore PATTERN line (optional) defines lines in the logfile which are ignored entirely, i.e. they are stripped from the logfile data before sending it to the Xymon server. It is used to remove completely unwanted "noise" entries from the logdata processed by Xymon. "PAT- TERN" is a regular expression. The trigger PATTERN line (optional) is used only when there is more data in the log than the maximum size set in the "log:FILENAME:SIZE" line. The "trigger" pattern is then used to find particularly interesting lines in the logfile - these will always be sent to the Xymon server. After picking out the "trigger" lines, any remaining space up to the maximum size is filled in with the most recent entries from the logfile. "PATTERN" is a regular expression. COUNTING LOGENTRIES
A special type of log-handling is possible, where the number of lines matching a regular expressions are merely counted. This is linecount:FILENAME, followed by a number of lines of the form ID:PATTERN. E.g. linecount:/var/log/messages diskerrors:I/O error.*device.*hd badlogins:Failed login FILE CONFIGURATION ENTRIES
A file monitoring entry is used to watch the meta-data of a file: Owner, group, size, permissions, checksum etc. It looks like this: file:/var/log/messages[:HASH] The file:FILENAME line defines the filename of the file to monitor. As with the "log:" entries, a filename enclosed in backticks means a command which will generate the filenames dynamically. The optional [:HASH] setting defines what type of hash to compute for the file: md5, sha1 or rmd160. By default, no hash is calculated. NOTE: If you want to check multiple files using a wildcard, you must use a command to generate the filenames. Putting wildcards directly into the file: entry will not work. DIRECTORY CONFIGURATION ENTRIES
A directory monitoring entry is used to watch the size of a directory and any sub-directories. It looks like this: dir:DIRECTORYNAME The dir:DIRECTORYNAME line defines the filename of the file to monitor. As with the "log:" entries, a filename enclosed in backticks means a command which will generate the filenames dynamically. The Xymon client will run the du(1) command with the directoryname as parameter, and send the output back to the Xymon server. NOTE: If you want to check multiple directories using a wildcard, you must use a command to generate the directory names. Putting wildcards directly into the dir: entry will not work. E.g. use something like dir:`find /var/log -maxdepth 1 -type d` The "du" command used can be configured through the DU environment variable. On some systems, by default du reports data in disk blocks instead of KB (e.g. Solaris). So you may want to configure the Xymon client to use a du command which reports data in KB, e.g. by setting DU="du -k" in the hobbitclient.cfg file. NOTES
The ability of the Xymon client to calculate file hashes and monitor those can be used for file integrity validation on a small scale. How- ever, there is a significant processing overhead in calculating these every time the Xymon client runs, so this should not be considered a replacement for host-based intrusion detection systems such as Tripwire or AIDE. Use of the directory monitoring on directory structures with a large number of files and/or sub-directories can be quite ressource-inten- sive. SEE ALSO
hobbit-clients.cfg(5), hobbitd_client(8), hobbitd(8), xymon(7) Xymon Version 4.2.3: 4 Feb 2009 CLIENT-LOCAL.CFG(5)
All times are GMT -4. The time now is 09:56 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy