- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: Manage parameter-file
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
Discussions
Discussions
Forums
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
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
тАО01-16-2006 02:24 AM
тАО01-16-2006 02:24 AM
Re: Manage parameter-file
is there also a chance to do this:
# perl -i.old -ple 's/par2\s*=.+\b/par2=newvalue/' parmsfile
in ksh or awk? nice solution with perl, but i wouldn't mix a lot of programming languages, if possible only ksh and awk.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-16-2006 02:34 AM
тАО01-16-2006 02:34 AM
Re: Manage parameter-file
Perl's regular expression handling is one of the best available. Since perl allows updating in-place, whereas 'awk' or 'sed' force you to redirect modified output into a second file and then rotate that second file over the first, I also choose perl for this task.
As far as mixing various languages, then, one sees this all the time in shell scripts. Consider the number of shell lines with 'sed' and 'awk' snippets. If a shell uses 'cut' or 'grep' in reality that too is mixing languages since the later are C-code.
Could your requirement be met wholly in shell? Well, yes. For instance, you could parse your parameter file by using the shell's IFS (inter-field-separator) much along the lines of what I did with 'split' in the 'awk' code.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-16-2006 02:45 AM
тАО01-16-2006 02:45 AM
Re: Manage parameter-file
how do you handle this at your own?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-16-2006 03:14 AM
тАО01-16-2006 03:14 AM
Re: Manage parameter-file
You asked, "...what is more professional? to mix a lot of languages or only use of one or two (if possible)? how do you handle this at your own?"
I prefer to drive screws with screwdrivers and nails with hammers. By this I mean, I perfer to do things easily and gracefully with the tools that offer both ease of use and good performance.
Just because you can do something in language X doesn't mean that you should. I want readable, maintainable (flexible) code that performs well using a minimum of server resources in that order. Sometimes mixing two languages (e.g. shell + awk or shell + sed or shell + perl) is an easy solution. The whole Unix philosophy is built around the idea of plumbing and to me this is one case of it.
Certainly as one becomes more familar and proficient with a language, like any tool, one tends to grab it at the start of a project. Many of the tasks we do in shell scripts could be re-written in perl. In cases where a working piece of code already exists I find no harm in leveraging another language for a small subtask.
"Mixing" languages is really nothing more than calling modules or libraries and that generally means making things easier in my opinion.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-16-2006 03:53 AM
тАО01-16-2006 03:53 AM
Re: Manage parameter-file
Regards Oviwan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-16-2006 09:28 PM
тАО01-16-2006 09:28 PM
Re: Manage parameter-file
why doesn't work my adjustment? the parameter file doesn't change:
echo $par_name $par_value | perl -i.old -F: -ple 's/^$F[0]\s*=.*\b/$F[0]=$F[1]/o' ${prg_path}${prg_par_file}
output of set -x:
+ echo db_name PROD
+ perl -i.old -F: -ple s/^$F[0]\s*=.*\b/$F[0]=$F[1]/o /home/oracle/scripts/file.par
are my perl parameters wrong? or is there another chance to include the shell variable $par_name in the perl?
Thanks a lot
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-17-2006 12:00 AM
тАО01-17-2006 12:00 AM
SolutionI you last post, there are several things amiss. It looks like you are attempting to autosplit on the ":" character but you don't specify '-a' nor do you explicity 'split' $_.
What you want to do is let the shell expand your variables and then present them to the perl snippet:
# arg=par2;val=newvalue;perl -i.old -ple "s/$arg\s*=.+\b/$arg=$val/" parmsfile
Note that this is a variation on my last post. By using double-quotes I let the shell evaluate the $arg and $val variables before perl runs.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-17-2006 12:23 AM
тАО01-17-2006 12:23 AM
Re: Manage parameter-file
I have every time troubles with this quotes ("'`) :(
Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-19-2006 07:39 PM
тАО01-19-2006 07:39 PM
Re: Manage parameter-file
is it possible to include a file in a shell-script file?
one file is the main programm the other one is the function file.
i search something like exists in php:
include ("functionfile");
Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-19-2006 10:26 PM
тАО01-19-2006 10:26 PM
Re: Manage parameter-file
You asked if it is possible to include a file in a shell script. Yes, the process is called "sourcing" a file. You cause this by writing a "dot" followed by a "blank" followed by the file name:
#/usr/bin/sh
echo "the next line says include the file"
. $HOME/includeme
echo "done"
This technique is often used to include environmental variables from a common file into a script instead of declaring them in a login profile.
Regards!
...JRF...