- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- programming and scripting variable substitution qu...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-25-2004 03:32 AM
03-25-2004 03:32 AM
Attempting to setup a installation/configuration script to quicking blow down a complex setup of applications on RH9.
I have the "software download and installation" complete however, I still have several files that require editing, I would prefer to add these edits to my script using inline editing with perl or sed..
for example:
I have a "/etc/foo/foo.conf"
with in the foo.conf
I have several variables that are set usually manually with vi or emacs,
For example I have a variable with a path attached..
var FOOCONF_PATH ../fooconf
I want to change the FOO_PATH in the foo.conf to a full path
var FOOCONF_PATH /etc/foo/fooconf
I've tried the following:
export FOOPATHOLD "var FOOCONF_PATH ../fooconf"
echo "Enter the new path for FOO Configs"
read $FOOPATHNEW
export FOOPATHNEW
///then I attempt to inline edit using variable substitutions.
I am doing as follows:
cp -p foo.conf foo.conf.orig
perl -p -i -e s/$FOOPATHOLD/$FOOPATHNEW/g foo.conf
the substitution flakes out on me..
I've tried:
perl -p -i -e s/"$FOOPATHOLD"/"$FOOPATHNEW"/g foo.conf
Any thoughts appreciated..
Rex M - Omaha NE
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-25-2004 03:47 AM
03-25-2004 03:47 AM
Re: programming and scripting variable substitution question
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-25-2004 03:51 AM
03-25-2004 03:51 AM
Re: programming and scripting variable substitution question
dirname and basename will be usefull here...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-25-2004 03:55 AM
03-25-2004 03:55 AM
Re: programming and scripting variable substitution question
An down and dirty examples you can throw at me?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-25-2004 10:58 AM
03-25-2004 10:58 AM
SolutionHere's an example:
FOOPATH="var FOOCONF_PATH ../fooconf"
FOOPATHNEW="var FOOCONF_PATH /etc/foo/fooconf"
perl -pi -e "s/$FOOPATH/$FOOPATHNEW/g" foo.conf
Expand the -e, and you get:
"s/var FOOCONF_PATH ../fooconf/var FOOCONF_PATH /etc/foo/fooconf/g"
Way broken.
Using something like:
perl -pi -e "s#$FOOPATH#$FOOPATHNEW#g" foo.conf
works just fine however.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-26-2004 12:50 AM
03-26-2004 12:50 AM
Re: programming and scripting variable substitution question
using the "#" is new for me..
Need to get my regexp book out, I tried "!" yesterday, I think I got it now.. Thanks!!!
s#$FOOPATHOLD#$FOONEWPATH# worked.
Rex
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-26-2004 10:14 AM
03-26-2004 10:14 AM
Re: programming and scripting variable substitution question
It's just usual to use /'s as they are the default.