Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Simple substitution not working 1

Status
Not open for further replies.

netman4u

Technical User
Mar 16, 2005
176
US
I don't understand this. I have a text file I am trying to do a substitution for that is not working:

Code:
#!/usr/bin/perl 
my $out_file = "/etc/default/ovpa";
open (OUT, "$out_file") or die ("Error opening ovpa file $1");
while(<OUT>) {
	chomp;
  s/MWA_PROTOCOL/IT WORKED/g;
}


Here is the file after running the program. No changes are made! Below is the file I am trying to modify

Code:
# @(#)ovpa.default    C.04.70.00  02/15/07 AIX 5.1+                   =*=
###############################################################################
#
# This file contains various environment variables which control the behavior
# of HP Performance Agent upon start. It is sourced by the following scripts:
#
#     o /usr/lpp/perf/bin/ovpa         HP Performance Agent control script
#     o /etc/rc.ovpa                   HP Performance Agent auto-start script
#
# The following are the environment and shell variables that can be modified
# by user to change the default behavior of Performance Agent.
#
###############################################################################
# NOTICE:
#
# This file is not overwritten during the HP Performance Agent product update. 
# A new copy of this file is left in the /usr/lpp/perf/newconfig directory.
###############################################################################
#
# MWA_START
#    This file originally has MWA_START set to 1 because it is assumed
#    that the user will edit the /var/opt/perf/parm file to suit their
#    environment prior to system boot.
#
#    Values:    0        Do not start Performance agent at the system boot
#               1        Start Performance agent at the system boot
#
#    Purpose:   This variable controls the auto-start of the Performance agent
#               at the system reboot.
#
#    Exported:  No
#
# MWA_PROTOCOL
#    Values:    ncs      Run HP Performance Agent as NCS service
#               dce      Run HP Performance Agent as DCE service
#
#    Purpose:   Determines whether HP Performance Agent servers register their
#               interfaces as NCS or DCE interfaces.
#
#    Exported:  No
#
# MWA_START_COMMAND
#    Values:    command string
#
#    Purpose:   Contains a command to be used to start Performance agent at
#               the system boot. Normally set to "mwa start".
#
#    Exported:  No
#
# MWA_LLBD_COMMAND
#    Values:    command string
#
#    Purpose:   Contains the command string to be used to start the NCS local
#               location broker deamon. The dced daemon is capable of emulating
#               NCS's local location broker, therefore this is a preferred
#               choice upon the product installation. However, users that still
#               wish to run genuine NCS location broker daemon may choose to
#               set this variable. By default it is set to:
#                   MWA_LLBD_COMMAND="/usr/lpp/perf/bin/llbd"
#               Note that this variable only applies when MWA operates
#               in NCS mode and neither dced nor llbd are already running.
#
#    Exported:  No
#
# MWA_RPC_INETADDR
#    Values:    IP address in dotted format
#
#    Purpose:   When HP Performance Agent is run in NCS mode on multi-homed
#               systems, this environment variable defines the network
#               interface to be used for communication with client products,
#               such as PerfView. NCS does not support registration to
#               multiple interfaces therefore this environment variable must
#               explicitly be set, if the default network interface is not
#               reachable by the client products.
#
#    Exported:  Yes
#
###############################################################################

MWA_START=1
MWA_PROTOCOL=dce
MWA_START_COMMAND="mwa start"
MWA_LLBD_COMMAND="/usr/lpp/perf/bin/llbd"

#
#   Replace the 127. address with the IP address of desired network interface
#   to direct MWA NCS mode communication through this particular network, and
#   uncomment the following two lines.
# MWA_RPC_INETADDR=127.0.0.1
# export MWA_RPC_INETADDR
#
###############################################################################

If at first you don't succeed, don't try skydiving.
 
Hi

I may miss the point, but where are you writing out the modified strings ?

And what about a one-liner ?
Code:
perl -i -p -e 's/MWA_PROTOCOL/IT WORKED/g' /etc/default/ovpa

Feherke.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top