- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Wrapper Script
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
тАО12-22-2008 08:38 AM
тАО12-22-2008 08:38 AM
Thanks in advance. Any help will be appreciated
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-22-2008 09:26 AM
тАО12-22-2008 09:26 AM
Re: Wrapper Script
some kind of config file that stores the various items needed and is read at exection
prompt for the individual parameters, store them variables and apply the needed variables to the calls to the individual scripts...may work acceptably for an interactive process
place all of the required input on the command line and parse that as needed using case or getops or???
if the existing 4 scripts use command line arguments that will not change, then it is as simple as coding the call w/ the correct arguements in the correct order.
If the existing 4 scripts prompt for input, and that input not change, then a "HERE-DOC" may be suitable.
It all depends on what you want to do (currently not well defined) and how the original 4 scripts get their input (totally undefined).
Methods can be "mixed and matched" as needed, are other methods are probably available, I simply listed the first few that occurred to me.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-22-2008 09:37 AM
тАО12-22-2008 09:37 AM
Re: Wrapper Script
The main task is I have 4 individual scripts which run fine but I have to integrate it together as one script thats why I thought about wrapper script. If there is another efficient way for to solve this problem also I am ready to use that way because I believer there are more than one way to do things correctly
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-22-2008 10:26 AM
тАО12-22-2008 10:26 AM
SolutionYeah...right...thats a simple restatement of the original, and not much more informative, so lets try this:
The 4 original scripts take positional parameters...DO THOSE EVER VARY when your wrapper runs? Or, when the wrapper runs them, are the inputs to the 4 original scripts always the same?
if they never vary then the wrapper can be something like:
===============
#!/bin/sh
script1 a b c
script2 d e f
script3 a d e
script4 g f e
===============
where a-g are the "positional parameters" you need to pass to scripts1-4, and they are "hardcoded"
if they vary, then you can either write a wrapper for each version, or something like:
========================
#!/bin/sh
script1 $1 $2 $3
script2 $4 $5 $6
script3 $1 $4 $5
script4 $7 $6 $5
and running it as "wrapper a b c d e f g" would produce the input to the scripts as illustrated in the previous example.
also note the following in my previous response:
"place all of the required input on the command line and parse that as needed using case or getops or???
if the existing 4 scripts use command line arguments that will not change, then it is as simple as coding the call w/ the correct arguements in the correct order"
note that getops / case statements allow you to do things like accept the various arguments "out of order" and assemble them in the correct fashion, something like
wrapper -s server -d directory -or-
wrapper -d directory -s server
would be equally as acceptable input
if the above doesn't answer your questions, you're going to have to explain what about this has got you confused. Posting a sample of what you've attempted to make work would be helpful.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-23-2008 12:16 AM
тАО12-23-2008 12:16 AM
Re: Wrapper Script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-23-2008 07:17 AM
тАО12-23-2008 07:17 AM
Re: Wrapper Script
Like for example
wrapper
script1 param1 param2 param3 param4
script2 param1 param2 param3
script3 param1 param2 param3 param4
script4 param1 param2
all the scripts need parameter and it might be different or some of them may be the same. In this condition how can I pass parameter from wrapper.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-23-2008 07:38 AM
тАО12-23-2008 07:38 AM
Re: Wrapper Script
> all the scripts need parameter and it might be different or some of them may be the same. In this condition how can I pass parameter from wrapper.
OldSchool has provided you a nicely detailed set of choices!
You need to pass everything you need to your "wrapper". Perhaps the first argument ($1) [or switch and argument] should identify which of the four scripts is to be run. Then, the remaining arguments are applied as needed.
Providing more details would be helpful. I suggest you look at the manpages for 'sh-posix' and for 'getopts'. There is actually a good example of how to use 'getopts' in those manpages.
You could also benefit by looking at this site:
http://www.shelldorado.com/
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-23-2008 07:44 AM
тАО12-23-2008 07:44 AM
Re: Wrapper Script
"Its a korn shell script and the script I am writting is not supposed to be interactive its supposted to be automated........Parameters should be passed to them in a command line (Positional Parameter)."
"My problem is parameters inside the script are not supposed to hard coded"
==================================================================================
Congratulations...you've stated yet a different requirement, maybe, possibly.
DID YOU EVEN LOOK at the second example I posted? Did you comprehend it?
"if they vary, then you can either write a wrapper for each version, OR SOMETHING LIKE:
THE WRAPPER IS:
========================
#!/bin/sh
script1 $1 $2 $3
script2 $4 $5 $6
script3 $1 $4 $5
script4 $7 $6 $5
========================
and running it as "wrapper a b c d e f g" would produce the input to the scripts as illustrated....." Note that $1 - $7 were the 7 parameters listed on the command line of "wrapper", and will be substituted in the appropriate places as follows(see next)
========================
script1 a b c
script2 d e f
script3 a d e
script4 g f e
========================
Then again, the statement "Its supposed to give by user while running the wrapper and that means it can change user to user" means that the existing scripts prompt then all you need is:
script1
script2
script3
script4
I don't understand the problem, as you are not clearly defining it. you've been provided examples which apply (or don't) to the questions as stated / when stated. Whatever it isyou are trying to accomplish, it appears to be very basic, but communication of the real / actual requirements seems to be breaking down.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-23-2008 08:28 AM
тАО12-23-2008 08:28 AM
Re: Wrapper Script
given wrapper script:
script1 $1 $2 $3
script2 $4 $5 $6
script3 $1 $4 $5
script4 $7 $6 $5
========================
and running it as "wrapper a b c d e f g"....
the command line parameters of wrapper get mapped as follows:
parm1 (a) of "wrapper" to script1/parm1 and script3/parm1,
parm2 (b) of "wrapper" to script1/parm2,
parm3 (c) of "wrapper" to script1/parm3,
parm4 (d) of "wrapper" to script2/parm1 and script3/parm2,
parm5 (e) of 'wrapper" to script2/parm2, script3/parm3 and script4/parm3,
parm6 (f) of "wrapper" to script4/parm2, and lastly
parm7 (g) of "wrapper" to script4/parm1
note that the $2 used in "wrapper" means the second positional parameter on the command line of "wrapper" and doesn't relate to any of the $2's found in scripts1-4. In script1-4, those $2's refer to the 2nd parameter on the shell script line where the given script is invoked.
as a note on style...I wouldn't expect a user to get the parameters correct order, especially if there are more than just a couple of them. I'd suggest you either gather all of the information required, either by prompting for the required stuff and storing it in a variable to be supplied when needed, or by implementing a strategy where the information contains some kind of options flag (see -d -s in previous examples). This adds complexity to the code, but enhances usability. However, given the problems to date, this may not be feasible....
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-23-2008 04:25 PM
тАО12-23-2008 04:25 PM
Re: Wrapper Script
cat script1 script2 script3 script4 > newscript