Visit Our UNIX and Linux User Community


Script triggering Korn shell, how-to stop it?


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Script triggering Korn shell, how-to stop it?
# 1  
Old 08-21-2009
Script triggering Korn shell, how-to stop it?

Script_A.sh has
echo "In am in script A"
ksh ## K-shell is invoked.

Script B.sh ## which I am writing...
./script_A.sh
echo "I am in script B"
return 0

When I run:
$> Script_B.sh
$> I am in script A
$>

Basically, on calling Script_A.sh from within Script_B.sh I have the issue of the spawned K-shell. I can't change Script_A.sh as it's NOT owned by me. What's my alternative here, I need Script_B.sh to perform the next set of commands I execute AFTER I've run Script_A.sh...

A dirty solution would be to copy the contents from Script_A.sh and write it into Script_B.sh - but that's dirty.
# 2  
Old 08-21-2009
Please expland the question with example scripts showing input, processing and output (including any directory listings) such that you question is clear.
# 3  
Old 08-22-2009
One option is to temporarily close standard input, then the ksh has nothing to read from:

Code:
script_b.sh
=========
exec <&-
./script_A.sh
exec < /dev/tty
echo "I am in script B"
 
 
# ./Script_B.sh 
In am in script A
I am in script B

otherwise, something like:
Code:
script_b.sh
=========
echo | ./script_A.sh
echo "I am in script B"
 
 
# ./Script_B.sh 
In am in script A
I am in script B

While these work for the example you've shown, I'm guessing they might have a bad effect on script_a.sh (especially the first) - so not really a solution.

If you type "exit" when you get to this point:
Code:
$> Script_B.sh
$> I am in script A
$>

then script_b.sh will continue:
Code:
# ./Script_B.sh 
In am in script A
# exit
I am in script B

Also not ideal.

I would find whoever wrote script_a and ask him what he was thinking! Or better, why not copy script_a to script_c, remove the ksh and call that from script_b?

Last edited by Scott; 08-22-2009 at 09:30 AM..
 

Previous Thread | Next Thread
Test Your Knowledge in Computers #530
Difficulty: Medium
Unicode was supports encoding 1,112,064 possible characters.
True or False?

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Triggering remote UNIX shell script from Remote desktop

I m trying to run a batch script in remote desktop which executes unix commands on the unix server...the problem is i wnt the output in HTML format.so in my batch script i m giving the cmd like ssh hostname path ksh HC_Report.ksh>out.html ...but it generates the HTML file in remote desktop .i... (2 Replies)
Discussion started by: navsan
2 Replies

2. AIX

Shell script stop working

I have a strange problem. I have the following in a cron to find files older than a day. find /dir1/dir2/ ! -name . -prune -name "s*.txt" -type f -mtime +1 -exec echo {} \; | wc -w It was working fine for the last few days now it suddenly stopped working. I can clearly see files in the... (5 Replies)
Discussion started by: bbbngowc
5 Replies

3. Shell Programming and Scripting

Stop! (the countdown!) :-) shell script help

Hi guys, I've found two nifty little scripts on these forums one which detects if the F5 key has been pressed: #/bin/sh _key() { local kp ESC=$'\e' _KEY= read -d '' -sn1 _KEY case $_KEY in "$ESC") while read -d '' -sn1 -t1 kp do _KEY=$_KEY$kp ... (0 Replies)
Discussion started by: rich@ardz
0 Replies

4. Shell Programming and Scripting

Help with stop/start Shell Script.

Hi All, I would like to develop a shell script for stop & start an application server (1-4) on Solaris box. Here are the user requirements for this task. 1. User will input the option which server they wish to stop. 2. Will clear cache files from specific location. 3. ... (1 Reply)
Discussion started by: venga
1 Replies

5. Homework & Coursework Questions

Korn Shell Script

1. The problem statement, all variables and given/known data: Write a korn shell script with an alfanumeric string as argument. The script lists the file's names in the current directory that contain the given string as substring and that can be read and written. 2. Relevant commands, code,... (3 Replies)
Discussion started by: burm
3 Replies

6. UNIX for Dummies Questions & Answers

Stop a shell script

Hi, I am writing a bash shell script. How can I tell it to stop. For example, I would like to have something similar to the following: mike=1 if ; then STOP THE SCRIPT fi (3 Replies)
Discussion started by: msb65
3 Replies

7. Shell Programming and Scripting

stop Prstat using shell script

How to stop the Prstat using shell script ? because after i run the below script the thing seems to be always in loop and cannot get out till i ctrl + c, is there anything that i can add in the script to make it terminate ? <code> #!/bin/sh prstat -Tc -u testing > testing.txt </code> ... (19 Replies)
Discussion started by: filthymonk
19 Replies

8. AIX

Help with Korn Shell script

I have this Korn shell script that runs via a cron entry. It runs in a loop "watching" a specific file system for files with a certain name. The file system that it is watching is an upload file system for an FTP server. When files that are the correct name come in, it takes the extension of the... (1 Reply)
Discussion started by: heprox
1 Replies

9. UNIX for Dummies Questions & Answers

korn shell script

hello., i have 2 files.. 1 file is in this folder /home/test/ssk/DSA.WLG.20050713211544.20050710.20050713211544 (this part) other file is in this folder /home/kk/dev/DSA.WLG.20050711210100.20050710.20050711210100 ... (1 Reply)
Discussion started by: pavan_test
1 Replies

Featured Tech Videos