control sub-shells


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting control sub-shells
# 1  
Old 07-09-2008
control sub-shells

Hi all,

New to shell scripting, I would like to know if it is possible to pass commands to a shell, which has been launched by a parent shell.
Example:

PHP Code:
#!/bin/ksh
#
# Launch and command shells
#
mySecondShell.ksh #this launches a sub-shell

#now is something like this possible?
mySecondShell.ksh -> ls 
Problem is that I cannot edit " mySecondShell.ksh". Goal is to automate software compilation (a command in a shell) and delivery (tarring, zipping etc etc).

Thanks a lot!!

Last edited by MarkZWEERS; 07-09-2008 at 06:41 AM..
# 2  
Old 07-09-2008
I don't understand what exactly you're trying to do but some shells like ksh93 and zsh support coprocesses,
consider the following:

Code:
$ head process*
==> process1 <==
#! /usr/dt/bin/dtksh

while :; do
  sleep 3
  read && print Received your message: $REPLY
done

==> process2 <==
#! /usr/dt/bin/dtksh

./process1 |&

while :;do
  print -p message $((++i))
  read -p
  print process1 says: $REPLY
  sleep 3
done
$ ./process2
process1 says: Received your message: message 1
process1 says: Received your message: message 2
process1 says: Received your message: message 3
^C

# 3  
Old 07-09-2008
Thanks for the answer, but it is not exactly what I am trying to do.

One can put commands in a shell script, like 'ls' or 'touch', or one can launch a program. Now I'll launch a shell in the following line:
PHP Code:
mySecondShell.ksh 
Everything which is written below this line will be executed only AFTER having terminated the shell "mySecondShell.ksh". But how can I say what should be done in that shell "mySecondShell.ksh"?
# 4  
Old 07-09-2008
Quote:
Everything which is written below this line will be executed only AFTER having terminated the shell "mySecondShell.ksh". But how can I say what should be done in that shell "mySecondShell.ksh"?
I still don't understand,
could you describe the actions that should be done in the parent script?
Could you also post the content of mySecondShell.ksh?
# 5  
Old 07-09-2008
:-) But that's the problem, I don't have the contents of that shell. At least I cannot modify it.

To compile my source code for a platform, I normally launch a shell from the command line, which will set several parameters etc. This shell results in some new command-line terminal, in which I simply type 'make' to compile the plug-ins for the platform.

Now I want to launch the (let's say) platform-shell from my home-brewn shell, with the line I gave you, but then of course I cannot write the commands for the platform-shell in my home-brewn shell.

PHP Code:
#!/bin/ksh
#
# Launch and command shells
#
PlatformShell.ksh #this launches the platform-shell

#now this should be executed in the "PlatformShell.ksh", but how..?
make 

Last edited by MarkZWEERS; 07-09-2008 at 09:15 AM.. Reason: typo
# 6  
Old 07-09-2008
It depends.
I understand that you cannot modify PlatformShell.ksh, but if you post the code it would be easier.

I think you need something like this (from what you're saying, it seems that the script invokes a new shell):

Code:
. PlatformShell.ksh<<!
make
!

Consider that . script is different than script and ./script.

Last edited by radoulov; 07-09-2008 at 09:52 AM..
# 7  
Old 07-10-2008
Ok, then I think my mind needs a little refresh on the '.' (see also https://www.unix.com/shell-programmin...teresis-2.html ).

I've always learned to run scripts with a '.' (so that it runs in the current shell), and to run binairies (executables) without, or with ./ if the path is not set in the .bashrc or .kshrc

ps: to run a script, one should make it executable by "chmod 777"

pps: '750' also works

Last edited by MarkZWEERS; 07-10-2008 at 03:56 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Please what are shells?

I mean like this: http://shells.red-pill.eu/ Can anyone explain how this works? I hope my post is not spam. I think its related to linux. Thank you (1 Reply)
Discussion started by: postcd
1 Replies

2. UNIX for Dummies Questions & Answers

Shells

Lets say my default shell is bash and then i load up csh and then ksh. How would i exit csh without exiting ksh? so basically i gone from bash > csh > ksh and i wish to close csh (2 Replies)
Discussion started by: Bill Thompson
2 Replies

3. Shell Programming and Scripting

Switching between shells

I don't know why, but it just isn't working how I want it to work. You might want to run it to see what I mean. Or you might be a genius (or just really good at unix) and know just by looking at it what the problem is. Have fun trying to figure this one out.:wall: (11 Replies)
Discussion started by: nowruzr
11 Replies

4. Shell Programming and Scripting

Differences between shells

What is the practical difference among the different shell like csh , ksh , bash etc.:confused::confused: Please use descriptive subjects instead of single words (2 Replies)
Discussion started by: hiten.r.chauhan
2 Replies

5. UNIX for Advanced & Expert Users

why we have different shells?

Can you pls. tell me, why we have different shells in UNIX OS ( Eg. SunOs) and also I would like to know what is the specific difference b/w SVR and BSD ? Thanks. (2 Replies)
Discussion started by: shahnazurs
2 Replies

6. Shell Programming and Scripting

different kinds of shells

Can anyone tell me about the classification and significance of variuos unix shells and why is only sh used for most shell scripting? (3 Replies)
Discussion started by: gurujoe
3 Replies

7. Shell Programming and Scripting

Different type of shells?

Hello there, i just want to know what are the different type of shells and the main difference betwee them. The problem is that if you try to search over the net you will find a lot of information and hence you will have no enough time to read all of them.....Anyone can help with this?? (1 Reply)
Discussion started by: charbel
1 Replies

8. UNIX for Advanced & Expert Users

Shells

I have came across the definitions of these shells korn bourne c etc .. but honestly till now i din't get the exact difference between these threes , the advantages ..... can anyone pinpoint me where it actually lies ..... don;t include me answers like aliasing in c is posible and not in bourne ..... (3 Replies)
Discussion started by: dino_leix
3 Replies

9. UNIX for Dummies Questions & Answers

switching shells??

Hi How can i switch shells on linux and freebsd? i tried changing the passwd file and restarted the computer but i still get the same old shell. anybody has the answer? thanks (6 Replies)
Discussion started by: xNYx
6 Replies

10. Shell Programming and Scripting

Different type of Shells

Hello every body iam new to UNIX and shell scripting and i would like to know the different type of shells. And also i would like to know the reason for Shell scripts And tell me which will be the best site for UNIX beginners. Regards Sivam. :rolleyes: (5 Replies)
Discussion started by: sivhard
5 Replies
Login or Register to Ask a Question