Update config file using shell script in Solaris 5.10


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Update config file using shell script in Solaris 5.10
# 1  
Old 03-04-2014
Update config file using shell script in Solaris 5.10

hi
I need to update the value in config.txt value using shell script
example:
lets say a value in config.txt file is as SEQUENCE=1
after some iteration as the loop ends , the SEQUENCE should get update in the config.txt file with a new value of SEQUENCE=2.

also , can anyone please help me in incrementing the date vlaue in the shell script
example/:
two variables
1)START DATE=dd/mm/yyyy
2)Period=10
the logic required is to add the period to the start date and increment the start date
e.g.
Code:
START DATE=04/03/2014
Period=10
END DATE= 14/3/2014


Last edited by Don Cragun; 03-04-2014 at 05:17 AM.. Reason: Add CODE and ICODE tags.
# 2  
Old 03-04-2014
Is this a homework assignment?
# 3  
Old 03-04-2014
NO Don,
its kind of a POC tht i was doing and got stuck into ....
# 4  
Old 03-04-2014
I could interpret:
Quote:
the logic required is to add the period to the start date and increment the start date
several ways. Is the setting to be used on the line containing START DATE related to today's date, or just the value currently found in the file? Please describe this in better detail and show us a complete starting config.txt and the exact resulting updated config.txt that you want to be produced (using CODE tags).

Do you have the GNU date utility installed on your system?

What shell are you using?
# 5  
Old 03-04-2014
thanks for you reply Don,

it would be the date which is mentioned in the file below is how my config.txt file is

config.txt
---------------
Code:
ORACLE_HOME=/opt2/oracle/productc/11.2.0/dbhome_1
ORACLE_BASE=/opt2/oracle/productc/11.2.0/dbhome_1
START_DATE=31-12-2013
END_DATE=31-01-2014
PERIOD=10
FLAG=A
MAX_SIZE=1
LAST_FEED=N
SEQUENCE=1

the above is how the config.txt file is , we would read the START_DATE value from config.txt via scripting and store the same in variable
(example
Code:
START_RUN_DATE=`cat $CONFIG_FILE | grep START_DATE=|cut -f2 -d'='`
PERIOD=`cat $CONFIG_FILE | grep PERIOD=|cut -f2 -d'=' | head -1`   )

after reading this above value we need sum up like

example if
START_DATE=04-03-2014
PERIOD=10

result should be as 14-03-2014

---------- Post updated at 04:14 AM ---------- Previous update was at 04:01 AM ----------

forgot to update on GNU and Shell which we are using on my last post

we don't have GNU utility installed and we cannot install the same in our live environment
and we are using SunOS 5.10 Generic_147440-07 sun4v sparc sun4v

thanks

Last edited by Scrutinizer; 03-04-2014 at 06:06 AM.. Reason: code tags
# 6  
Old 03-04-2014
You have now shown us a sample input file. I repeat:
Quote:
Please describe this in better detail and show us a complete starting config.txt and the exact resulting updated config.txt that you want to be produced (using CODE tags).

Do you have the GNU date utility installed on your system?

What shell are you using?
In particular; does the resulting date go on the line with START DATE (or START_DATE) or on the line with END DATE (or END_DATE)? Note that your 1st message said the strings containing the dates had spaces between the words, while your last post had underscores between the words??? Which is it?
# 7  
Old 03-04-2014
we don't have GNU utility installed and we cannot install the same in our live environment
and we are using KSH (SunOS 5.10 Generic_147440-07 sun4v sparc sun4v)

this is starting my config file
---------------------------------------------------
Code:
USER=MIS_EXTRACT
PASSWD=MIS_EXTRACT
DATABASE=WLR1
ORACLE_HOME=/opt2/oracle/productc/11.2.0/dbhome_1
ORACLE_BASE=/opt2/oracle/productc/11.2.0/dbhome_1
START_DATE=31-12-201300:00:00
END_DATE=31-03-201400:00:00
PERIOD=10
FLAG=A
MAX_SIZE=1
LAST_FEED=N
SEQUENCE=1

---------------------------------------------

after execution it shd be as below config.txt
--------------------------------------
Code:
USER=MIS_EXTRACT
PASSWD=MIS_EXTRACT
DATABASE=WLR1
ORACLE_HOME=/opt2/oracle/productc/11.2.0/dbhome_1
ORACLE_BASE=/opt2/oracle/productc/11.2.0/dbhome_1
START_DATE=10-01-2014
END_DATE=31-03-2014
PERIOD=10
FLAG=A
MAX_SIZE=1
LAST_FEED=N
SEQUENCE=1

--------------------------------------

the above is how are expecting

Last edited by Franklin52; 03-04-2014 at 07:44 AM.. Reason: Please use code tags for data and code samples
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell script to pass the config file lines as variable on the respective called function on a script

I want to make a config file which contain all the paths. i want to read the config file line by line and pass as an argument on my below function. Replace all the path with reading config path line by line and pass in respective functions. how can i achieve that? Kindly guide. ... (6 Replies)
Discussion started by: sadique.manzar
6 Replies

2. Shell Programming and Scripting

Script to detect dynamic ip change and update to config file

Hi All, I am newbie here and request your assistance. I have a service running on public ip, but since I have a dynamic IP it keeps on changing and every time I need to manually get the new ip and add to the config file and restart the service. This has become bit time consuming. Hence, I... (4 Replies)
Discussion started by: Shaan_Shaan
4 Replies

3. Shell Programming and Scripting

How to update an entry of another file in a Shell script?

Hi all, Say I have a shell script called update_password.sh - in this script I want to perform a task to update a specified entry of another file (e.g. users.passpords) update_password.sh #!/bin/bash -e PW_FILE_DIR="${A_DIR}/.../..." PW_FILE="users.passwords" I want to update the... (2 Replies)
Discussion started by: isaacniu
2 Replies

4. 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

5. Solaris

Autosys Config file update on a read-only filer

Hi To All Genius out there, We are running autosys application on solaris 10. In autosys we have a configuration file that contains an Autosys instance configuration data and is located on a NFS filer on which we have a read-only access. Our Autosys environment is on a dual server mode(Active... (0 Replies)
Discussion started by: whn_chips_r_dwn
0 Replies

6. UNIX and Linux Applications

Autosys Config file update on a read-only filer

Hi To All Genius out there, We are running autosys application on solaris 10. In autosys we have a configuration file that contains an Autosys instance configuration data and is located on a NFS filer on which we have a read-only access. Our Autosys environment is on a dual server... (0 Replies)
Discussion started by: whn_chips_r_dwn
0 Replies

7. Shell Programming and Scripting

how to access variables in a config file inside a shell script

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

8. UNIX for Dummies Questions & Answers

update records in a file using shell script...

Hi, I have a file with 6 columns. First 3 columns together make unique record. I have a variable ($v) which hold a value that is obtained by a caliculaion. I have to replace value in 5th columnn with the value of the variable ($v). The value $v is caliculated from col4 and col6 values. ... (2 Replies)
Discussion started by: new_learner
2 Replies

9. Shell Programming and Scripting

Edit a config file using shell script

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

10. Shell Programming and Scripting

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 : path=c://dataset/set1 v1= a.bin v2= b.bin path=c://dataset/set2 v1= xy.bin v2= abc.bin .................. and so on . and my testscript : (2 Replies)
Discussion started by: pradsh
2 Replies
Login or Register to Ask a Question

Featured Tech Videos