There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
 
Tag Cloud
acer black screen blue screen boot bsod computer connection crash css dell display driver drivers email error excel explorer firefox firefox 3 game hard drive internet internet explorer itunes laptop lcd linux malware network networking nvidia outlook outlook 2003 outlook express partition printer problem ram router slow sound sprtcmd.exe trojan usb video virus vista windows windows xp wireless
UNIX/Linux
Search
Search in:
 
Advanced Search
Tech Support Guy Forums > Operating Systems > UNIX/Linux >
Unix Shell Scripting (AIX 5.2)


HELLO AND WELCOME! Before you can post your question, you'll have to register -- it's completely free! Click here to join today! We highly recommend that you print a copy of our Guide for New Members. Enjoy!

Closed Thread
 
Thread Tools
LorenRad's Avatar
Junior Member with 2 posts.
 
Join Date: Jul 2007
Experience: Intermediate
06-Jul-2007, 05:22 PM #1
Unix Shell Scripting (AIX 5.2)
My input file contains the following:

#Root directory for the webserver
client-connect-timeout = 120
# Selectively disable SSL version support for browser connections
disable-ssl-v2 = no
disable-ssl-v3 = no
disable-tls-v1 = no
# Session timeout for SSL v2 connections (range: 1-100 secs)
# ssl-v2-timeout = 100
# Session timeout for SSL v3 connections (range: 1-86400 secs)
ssl-v3-timeout = 7200
# Selectively disable SSL version support for junction connections
disable-ssl-v2 = no
disable-ssl-v3 = no
disable-tls-v1 = no
# CRL Cache configuration.
# When gsk-crl-cache-size and gsk-crl-cache-entry-lifetime are
# both set to zero (which they are by default), CRL Caching will
# be disabled.

I'm trying to write a script that will edit the file and make changes such as follows:

This ==> server-root = /www-abcsamc
To Be => server-root = /www-defsamd

This ==> disable-ssl-v2 = no
To Be => disable-ssl-v2 = yes (only the browser connection, leave the junction connection at "no")

This ==> # ssl-v2-timeout = 100
To Be => ssl-v2-timeout = 100

I've tried "sed" which works for the most part but if what I'm changing appears more than once in the file then sed will change all occurrences. I figure I can do this with a "cat while read" command script but I'm having trouble putting it together. Can anyone help?
lotuseclat79's Avatar
Distinguished Member with 10,521 posts.
 
Join Date: Sep 2003
Location: -71.45091, 42.27841
06-Jul-2007, 06:08 PM #2
Hi LorenRad,

I would choose different names for the browser vs junction connections to discriminate them better for their functionality, such as:

Use a prefix like browconn and juncconn on each separate instance of the variables - then your sed script won't confuse the difference between them - i.e. when they have the same names.

The 'g' flag at the end of a sed statement - instructs sed to make changes globally on all occcurrences in pattern space. Normally, only the first occurrence is replaced, i.e. when the 'g' flag is not used.

example:
s/""//
vs
s/""//g

-- Tom
__________________
The independence created by philosophical insight is - in my opinion - the mark of distinction between a mere artisan or specialist and a real seeker after truth. - Einstein wrote in 1944.

Some say knowledge is power, I say knowledge without action is powerless. - lotuseclat79

Don't confuse action with movement. - Hemingway to Gardner

Imagination is more important than knowledge. - Einstein
LorenRad's Avatar
Junior Member with 2 posts.
 
Join Date: Jul 2007
Experience: Intermediate
07-Jul-2007, 01:52 PM #3
I don't believe I can use variables for what needs to be changed. Could you provide an example? When you create a instance within Tivoli a config file is created. What I'm trying to do is make the necessary changes within the config file with a script instead of using vi or something to manually go in and make the changes. There are numerous changes to be made and what I've listed are just a few.

When using sed the "g" flag only relates to one line. So if the word "tom" appears more than once on one line the g flag if used will change all occurances of the word "tom" on a line, example: s/tom/tim/g, if no "g" flag then it changes just the first occurance of "tom" on a line.

I'm looking for a script that will "cat" the file and pipe it to a "while read" statement and go through the file line by line and make changes if necessary using "if" statements or something similiar. I'm not even sure if that's the easiest way and this is why I'm here asking for help.

cap ..
lotuseclat79's Avatar
Distinguished Member with 10,521 posts.
 
Join Date: Sep 2003
Location: -71.45091, 42.27841
07-Jul-2007, 05:22 PM #4
Hi LorenRad,

Sed is implicitly global - i.e. it applies all sed commands in a script to each line in the file (the target of sed) being edited.

-- Tom
Closed Thread

THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
WELCOME TO TECH SUPPORT GUY! Are you looking for the solution to your computer problem? Join our site today to ask your question -- for free! Our site is run completely by volunteers who help people like you solve computer problems. See our Welcome Guide to get started.



Thread Tools


You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 08:57 PM.
Copyright © 1996 - 2008 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Powered by Cermak Technologies, Inc.