Sponsored Content
Top Forums Shell Programming and Scripting Switching shells in UNIX Scripts Post 88986 by vino on Thursday 10th of November 2005 11:27:53 AM
Old 11-10-2005
I doubt you can switch the shell in the middle of a script.

Why do you want to switch ?

the shells have similiar constructs save for a few ones.

Anyway, you can compile the second part of the script as a new script which runs in bash and invoke that.

Code:
#! /bin/ksh
# commands 
# which 
# runs 
# in 
# the 
# ksh 
# shell
#
. ./script-that-requires-bash

where

script-that-requires-bash is

Code:
#! /bin/bash
# commands 
# which 
# runs 
# in 
# the 
# bash
# shell

If you export any variables in the ksh script, there is a chance that the inner script might not be able to see it. It depends on the way you invoke the ksh script.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Good Unix Shells ?

Hey Guys i am new to Unix and i have downlaoded Cygwin for Windows and deleted it. I was just wondering is there any good shells like that for windows that just as good thanks for your time ][ce (1 Reply)
Discussion started by: IceCold
1 Replies

2. 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

3. UNIX for Dummies Questions & Answers

How to open multiple shells while the scripts keeps running.

Hello, I've tried for a while now to run a bash script that continues to the end, while opening new shells as needed. I've tried xterm -e "somecommand"; & xterm -e " somecommand"; I've also tried screen -S "somecommand"; & screen -S "somecommand"; All without any luck, they... (5 Replies)
Discussion started by: Closed_Socket
5 Replies

4. UNIX for Dummies Questions & Answers

Unix Kernel Switching?

How do I go about switching from one Kernel to another? I figure the process is somewhat like "compile -> remove old boot reference -> add new boot reference -> reboot/restart kernel"... but honestly I have no idea how to do this... I'm trying to test out a piece of software, but it only runs... (3 Replies)
Discussion started by: jjinno
3 Replies

5. Cybersecurity

Preventing switching shells

Hello, My firm has a requirement that everyone must use bash. Of course, there can be exceptions so I do not want to disable the other shells. But is there a way that I can prevent users from switching to another shell? Thank you. (5 Replies)
Discussion started by: danielf
5 Replies

6. 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

7. UNIX for Dummies Questions & Answers

shells and scripts

So in UNIX, I understand that there are several different shells you can be in: C, Bourne, Bourne Again, Korn, etc. I also know that you can write scripts for the shells, by assigning it by #!/bin/csh, or sh, etc. If I am working in the csh, do I have to write the script for the csh? Or can it... (1 Reply)
Discussion started by: bjstaff
1 Replies

8. Linux

Switching between Windows and UNIX

I have both UNIX and Windows on my system. While booting it asks for me to select an OS. Once I log in to an OS, then to log in to another OS, there is no direct method. I need to shutdown and again start to select another OS. May I know any method to directly switch between the two. (23 Replies)
Discussion started by: ravisingh
23 Replies

9. Programming

UNIX shells scripting

Can someone help by advising hw to built myself strong on logic building in UNIX shell scripting. I find it very difficult Sent from my iPhone using Tapatalk (4 Replies)
Discussion started by: Vijaykannan T
4 Replies

10. Shell Programming and Scripting

Switching from production to development envirornment in UNIX

I had a unix scripts in prod. I need to made changes in those scripts which I don't have the edit access. I need to move those scripts from prod to dev to edit. Please tell me how to switch from production to development, So that I can made changes in dev and again move those scripts to Prod. ... (3 Replies)
Discussion started by: Rajeswararao
3 Replies
RBASH(1)						      General Commands Manual							  RBASH(1)

NAME
rbash - restricted bash, see bash(1) RESTRICTED SHELL
If bash is started with the name rbash, or the -r option is supplied at invocation, the shell becomes restricted. A restricted shell is used to set up an environment more controlled than the standard shell. It behaves identically to bash with the exception that the follow- ing are disallowed or not performed: o changing directories with cd o setting or unsetting the values of SHELL, PATH, ENV, or BASH_ENV o specifying command names containing / o specifying a filename containing a / as an argument to the . builtin command o specifying a filename containing a slash as an argument to the -p option to the hash builtin command o importing function definitions from the shell environment at startup o parsing the value of SHELLOPTS from the shell environment at startup o redirecting output using the >, >|, <>, >&, &>, and >> redirection operators o using the exec builtin command to replace the shell with another command o adding or deleting builtin commands with the -f and -d options to the enable builtin command o using the enable builtin command to enable disabled shell builtins o specifying the -p option to the command builtin command o turning off restricted mode with set +r or set +o restricted. These restrictions are enforced after any startup files are read. When a command that is found to be a shell script is executed, rbash turns off any restrictions in the shell spawned to execute the script. SEE ALSO
bash(1) GNU Bash-4.0 2004 Apr 20 RBASH(1)
All times are GMT -4. The time now is 10:01 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy