The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Killing all active shells without rebooting Kesava81 UNIX for Dummies Questions & Answers 3 06-05-2008 05:39 AM
Passing environment variables to parent shells konndanley UNIX for Dummies Questions & Answers 3 08-04-2007 06:15 PM
forking and killing parent processes davewilliams20 UNIX for Dummies Questions & Answers 0 10-17-2005 06:40 AM
Version of Shells? Xplore Linux 2 08-06-2005 11:41 AM
Shells dino_leix UNIX for Advanced & Expert Users 3 06-08-2005 07:07 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 06-27-2007
rockysfr rockysfr is offline
Registered User
  
 

Join Date: Jun 2007
Posts: 24
Killing parent shells from subshells (KSH)

Hi all,

I have a shell script which calls other shell scripts, depending on the input.

Within a.sh, I have a command which calls b.sh (ie. ksh b.sh)

Normally, we use the exit function to terminate a shell. However, if I choose to call exit from b.sh, I will return to the parent shell who activated the shell (ie. a.sh), rather than to close the application completely.

Is there a command that I can use to close all parent shells from b.sh?

Thanks in advance.
  #2 (permalink)  
Old 06-27-2007
aigles's Avatar
aigles aigles is offline Forum Advisor  
Registered User
  
 

Join Date: Apr 2004
Location: Bordeaux, France
Posts: 1,429
Use 'exec b.sh' instead of 'ksh b.sh'
  #3 (permalink)  
Old 06-27-2007
rockysfr rockysfr is offline
Registered User
  
 

Join Date: Jun 2007
Posts: 24
Quote:
Originally Posted by aigles View Post
Use 'exec b.sh' instead of 'ksh b.sh'
Thanks a lot!
  #4 (permalink)  
Old 06-28-2007
rockysfr rockysfr is offline
Registered User
  
 

Join Date: Jun 2007
Posts: 24
Suppose that I want to allow the user to have a choice between:

1. Terminating the shell completely
2. Or closing the subshell and going back to the previous shell script that called it.

How can this be implemented? Is it through the use of using ksh b.sh instead of exec b.sh and then:

1. have a case statement which calls exit from the subshell to go back to previous page.

2. use some signal to kill the whole shell

Am I correct to say this? If so, what is the command to be used to implement the signals?

Thanks in advance.
  #5 (permalink)  
Old 06-28-2007
porter porter is offline Forum Advisor  
Registered User
  
 

Join Date: Jan 2007
Posts: 2,965
If the parent shell script used "exec" to call your script then the parent script has gone when you shell runs.

This is because exec replaces the current program with a new one. The old program is no longer running.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 12:00 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0