Sponsored Content
Full Discussion: Automate config changes
Top Forums Shell Programming and Scripting Automate config changes Post 302106098 by sb008 on Tuesday 6th of February 2007 02:31:32 PM
Old 02-06-2007
This might get you started.

I assume the config file and the changes file have the same format.
I also assume the changes file is a subset of the config file.

You could convert both of them to a different format.

e.g.

nawk '/\[.*\]/ { SECT=$1; next } { print SECT$0 }' configfile > tmpfile1
nawk '/\[.*\]/ { SECT=$1; next } { print SECT$0 }' changesfile > tmpfile2

Use info from tmpfile2 to make changes in tmpfile1.

When done convert tmpfile1 back to original format and use this file to replace the original config file.

running the command above on the example config file you provided would result in the following output:

tmpfile1:
[Section1]parm=value
[Section1]parm2=value
[Section1]parm3=value
[Section2]parm=value
[Section2]parm2=value
[Section2]parm3=value

Suppose your changes file looks like:

[Section1]
parm2=newvalue1

[Section2]
parm=newvalue2

Again using the command above the output would be:

tmpfile2:
[Section1]parm2=newvalue1
[Section2]parm=newvalue

Thsi puts the config and changes file in a similar format which makes it easy to make the necessary edits.

As mentioned, when the edits are done convert the format back.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to automate responses

I would have searched for this but I couldn't really think of what to use for the search text... I've got a situation where I need to automate responses to an executable when running it from a script so that it can be made into a job the operators don't have to interact with. When I run it... (2 Replies)
Discussion started by: djp
2 Replies

2. SuSE

automate ispell

Hello!! Is posible to automate ispell?? I have a lot of misspelled text and I want to launch a script that runs ispell choosing for example the first option, all that automatically. Is possible?? Thanks :) (4 Replies)
Discussion started by: elblo
4 Replies

3. Shell Programming and Scripting

parsing config file to create new config files

Hi, I want to use a config file as the base file and parse over the values of country and city parameters in the config file and generate separate config files as explained below. I will be using the config file as mentioned below: (config.txt) country:a,b city:1,2 type:b1... (1 Reply)
Discussion started by: clazzic
1 Replies

4. UNIX for Dummies Questions & Answers

Can you automate CVS?

Currently we have a load of files which we manually edit and then commit back into CVS ready for whoever else to edit. I have now made a script which auto-populates these files, however the powers that be still want them accessible via CVS. Is there a way I can automatically commit these files... (7 Replies)
Discussion started by: JayC89
7 Replies

5. Shell Programming and Scripting

Shell script that will compare two config files and produce 2 outputs 1)actual config file 2)report

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

6. Shell Programming and Scripting

Need a help to automate a task

I need to automate a manual task using shell scripting. The scenario is like :- #!/usr/bin/sh echo "please enter the name of the lab server to test ..." read s ssh $s This is peace of the script which will allow me to login to another server using "ssh". I have a conf file which is having... (4 Replies)
Discussion started by: Renjesh
4 Replies

7. UNIX for Dummies Questions & Answers

To automate a process

CAN ANYONE HELP TO SOLVE i wann write a script to automate a process .i.e, to search files in the FTP server and and if files are there and we hav to bring that files to our system. After copying the files in our system we have to upload the data in the tables. I have scripts to load the... (2 Replies)
Discussion started by: nani1984
2 Replies

8. Red Hat

Apache virtual host config vs global config problem

Hi folks, I am trying to configure Apache webserver and also a virtual host inside this webserver. For Global server config: /var/www/html/index.html For virtual host config: /var/www/virtual/index.html Both client10 & www10 are pointing to 192.168.122.10 IP address. BUT, MY... (1 Reply)
Discussion started by: freebird8z
1 Replies

9. Shell Programming and Scripting

Sftp automate

hi, I am trying to automate a file download process using sftp. There is some logic to download files. 1) I need to login to destination server and then go to folder. 2) find list of files and count 3) using list of files I need to eliminate three selective files and download remaining... (1 Reply)
Discussion started by: getmilo
1 Replies

10. Windows & DOS: Issues & Discussions

(VS 2008) New build config looking files from other folder build config

Hi Team, My new build configuration always looking for the files from the build where i copied from. please help me to resolve this. I am using Visual studio 2008.It has Qt 4.8. plugins,qml,C++ development I created new debug_new build configuration with additional preprocessor from the... (1 Reply)
Discussion started by: SA_Palani
1 Replies
XmTransferSetParameters(library call)									     XmTransferSetParameters(library call)

NAME
XmTransferSetParameters -- A toolkit function that establishes parameters to be passed by the next call to XmTransferValue SYNOPSIS
#include <Xm/Transfer.h> void XmTransferSetParameters( XtPointer transfer_id, XtPointer parm, int parm_fmt, unsigned long parm_length, Atom parm_type); DESCRIPTION
XmTransferSetParameters establishes a parameter definition. Your application calls XmTransferSetParameters just before calling XmTransfer- Value, and only if XmTransferValue needs to transfer a value containing a parameter. transfer_id Specifies a unique indentifier for the data transfer operation. The value must be the same as the value of the transfer_id mem- ber of the XmDestinationCallbackStruct passed to the XmNdestinationCallback procedure. parm Specifies parameters to be passed to the conversion routine (and the XmNconvertCallback procedures, if any) of the widget that owns the selection. The type and length of parameters are target-specific. If the target takes no parameters, the value is NULL. parm_fmt Specifies whether the data in parm should be viewed as a list of 8-bit, 16-bit, or 32-bit quantities. Possible values are 0 (when parm is NULL), 8, 16, and 32. parm_length Specifies the number of elements of data in parm, where each element has the number of bits specified by parm_fmt. When parm is NULL, the value is 0. parm_type Specifies the type of parm. RELATED
XmTransferSendRequest(3), XmTransferStartRequest(3), and XmTransferValue(3). XmTransferSetParameters(library call)
All times are GMT -4. The time now is 12:45 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy