Switching between shells


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Switching between shells
# 1  
Old 05-05-2011
Lightbulb 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.Smilie

Quote:
#!/bin/bash

Clear
echo ".-----------------------------------------------------------------."
echo "| |"
echo "| Please specify which Shell you want to switch to: |"
echo "| 1. Bash |"
echo "| 2. Korn Shell |"
echo "| 3. T Shell |"
echo "| |"
echo "'-----------------------------------------------------------------'"
echo " "
echo "Enter the number of your choice: "; read shell

case $shell in
1) echo "You are now in Bash"; `bash` ;;
2) echo "You are now in Korn shell"; `ksh` ;;
3) echo "You are now in T Shell"; `tcsh` ;;
esac
clear
# 2  
Old 05-06-2011
what do you mean its not working? Post the error and the expected behavior.
# 3  
Old 05-06-2011
tcsh wasn't working, but now I think I got it working. for some reason I had to execute the file directly, just typing tcsh didn't work for me here is the new script.

Quote:
#!/bin/bash

Clear
echo ".-----------------------------------------------------------------."
echo "| |"
echo "| Please specify which Shell you want to switch to: |"
echo "| 1. Bash |"
echo "| 2. Korn Shell |"
echo "| 3. T Shell |"
echo "| |"
echo "'-----------------------------------------------------------------'"
echo " "
echo "Enter the number of your choice: "; read shell

case $shell in
1) echo "Starting Bash..."; sleep 2; clear; `bash`;;
2) echo "Starting shell..."; sleep 2; clear; `ksh`;;
3) echo "Starting T Shell..."; sleep 2; clear; exec /bin/tcsh -l;;
esac
# 4  
Old 05-06-2011
There's no point to putting bash or ksh in backticks. And exec always has the side-effect of annihilating the program that runs it. Which is fine if that's the last thing your program ever does anyway, but then, why not do it for all options?
This User Gave Thanks to Corona688 For This Post:
# 5  
Old 05-07-2011
It is because bash and kcsh open just fine when I put them the way they are, but tcsh just doesn't open the right way. But the program is working, so I am just going to leave it alone until it starts causing me problems. then I just make them all open with exec
# 6  
Old 05-09-2011
I mean that putting them in backticks may have negative side-effects. Do you truly want to capture their output and turn it into an argument? If not, there's no point using backticks and doing so may cause errors later when arguments pop up in places you didn't want them.
# 7  
Old 05-09-2011
Oh ok so basically for the most part backticks are not required. But for some reason, I remember when I was writing another program, I had to put the backticks in or it just wasn't working. Is there a scenario where backticks are required?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

Switching over to C++

Hi, We've been using a perl script to extract datas from several logs to generate a report. I've been asked to rewrite the code in C++. I want to know if it is wise to have a code in C++ and will it be more faster than Perl? (23 Replies)
Discussion started by: Ribosome
23 Replies

2. Solaris

The switching in the different AP's

HI, I am using the windows 2003 server R2 in there we are using the putty as to access the different AP's now from the primary AP i want to login to several different AP's using a script what the script will do is :- input a text file in which list of different ap's and the corresponding... (0 Replies)
Discussion started by: amiglani
0 Replies

3. OS X (Apple)

vt switching

greetings, i hope this hasn't been covered previously. has anyone heard of a .kext or daemon that would allow linux or (open)solaris-like vt switching? googling didn't help much.. i know os x allows a '>console' login from loginwindow.app, but i'm mainly interested in this because there are... (0 Replies)
Discussion started by: bamdad
0 Replies

4. Solaris

Switching between sessions

Unix sys admin in training here and I was performing a rollout of java code. While rolling out my connection to the server was broken. I logged back on to the box and performed a ps -ef | grep 'user' . I could see that session and pid number. My question is was there anyway to resume or... (1 Reply)
Discussion started by: vedder191
1 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. AIX

Switching users

Hi I want to write a script which can switch between super users.But it asks for the password at the prompt.How can I manage in the script so that it didnt ask me for the password at the prompt. (1 Reply)
Discussion started by: monika
1 Replies

7. Shell Programming and Scripting

switching users

Hi I want to write a script which can switch between super users.But it asks for the password at the prompt.How can I manage in the script so that it didnt ask me for the password at the prompt. (1 Reply)
Discussion started by: monika
1 Replies

8. Linux

Switching from one DNS to another

Hi all, we have running some linux servers with sles9 and we have some problems with our dns servers. Sometimes they don't like to work. However, is there a parameter to enable faster switching between two ore more dns servers? Thx for your help in front Regards frank (5 Replies)
Discussion started by: ortsvorsteher
5 Replies

9. Shell Programming and Scripting

Switching shells in UNIX Scripts

Solaris Newbie here to scripting in UNIX/SOLARIS. What I am looking to do is, once the script is executed, switch to /bin/bash shell and continue to execute the script. The problem I run into is once the script switches to the Bash shell, the script stops, and does not execute the... (2 Replies)
Discussion started by: Scoobiez
2 Replies

10. 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
Login or Register to Ask a Question