- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Shell question
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
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-05-2002 02:49 PM
03-05-2002 02:49 PM
There is a script which executes different shell scripts within it, let's say I have a script which executes 3 different scripts, my question is how many shell does it spawn, if three, how can I make it not to spawn new shells and run the script in the same shell ..
Any help would be greatly appreciated.
Thanks,
Shabu
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-05-2002 02:56 PM
03-05-2002 02:56 PM
Re: Shell question
If sh or ksh, then `. script` or `. /path/to/script`.
If csh, then `source script` or `source /path/to/script`.
But if you want each of these to run concurrently, then they must run in there own shells.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-05-2002 02:57 PM
03-05-2002 02:57 PM
Re: Shell question
In your case, each script is a new process but only the parent and one child is run at a time therefore you have at most two shells running at any one time.
You have a couple of options:
. myshell2.sh
This will run .myshell.sh as simply a part of the parent shell BUT you must make certain that myshell2.sh does not use an exit statement or myshell2.sh AND the parent (since they are one and the same) will terminate.
You could also use exec BUT this is not a good answer because exec replaces the current shell with another.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-05-2002 02:58 PM
03-05-2002 02:58 PM
Re: Shell question
Further to this, if you are using pipes in your shell script, each pipe will spawn off a different process.
eg. ps -fae|grep blah
There will be two processes spawned.
Hope this helps. Regards.
Steven Sim Kok Leong
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-05-2002 03:01 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-05-2002 04:04 PM
03-05-2002 04:04 PM
Re: Shell question
Thanks for all your answers !
So, in my case can I say that my script spawns three shells and if I want my script to not to do that then
. scriptname will only run in the current shell (one shell) provided I don't have an exit statement ?
Will my script perform better if I don't break up my script into different scripts and do everything in one single script ?
Thanks for your assistance Guys !
-Shabu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-05-2002 04:44 PM
03-05-2002 04:44 PM
Re: Shell question
If you create variables in the scripts you call and want to use them in the calling script, then you should source the called scripts.
If the called scripts can "stand on their own" and would be useful to be stand-alone scripts, then that's what I'd do.
If you can run the called scripts concurrently, you could start them in the background from the calling script. You can use the "wait" command if you need all of them to finish before continuing in the calling script.
Darrell
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-05-2002 04:58 PM
03-05-2002 04:58 PM
Re: Shell question
That's what I thought too, shouldn't be much of a overhead.
Different question: How do I make changes to the "Assign Points" section ? Do you know ?
-Shabu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-05-2002 11:25 PM
03-05-2002 11:25 PM
Re: Shell question
I think it is not possible to make changes after assigning points.
Please remember, if you start a script like described by the others here:
. scriptname
you have to be sure, that your script is using the same syntax! This way, you can't use scripts which use diffenrent shells, like kornshell- scripts and in that script c-shell- scripts. This would cause errors. You can simply find out which shell interprets the script in most cases looking for a line like this:
# !/usr/bin/ksh -->> kornshell
# !/usr/bin/csh -->> c- shell
Allways stay on the bright side of life!
Peter