Sponsored Content
Full Discussion: Switching between shells
Top Forums Shell Programming and Scripting Switching between shells Post 302520921 by ygemici on Monday 9th of May 2011 03:40:16 PM
Old 05-09-2011
parent shell is waiting for execute of return value (file , command , variable , or any result..) that in backticks expression.firstly a new shell is executed and switching in.in new child shell , but commands are executed that is not efficiently work so does not produce any output.however parent shell is waiting still the result of it's and therefore probably commands can not see on stdoutput in this shell (probably non-access to terminal device via stdoutput because of ` ` backticks are still open so uncompleted and subshell has not it's own stdoutput fd!! )

firstly lets see wait issue effect these with backticks
for this i added the end of file an `echo`
Code:
# sed -n '$p' /etc/bashrc
echo UNIX.com

and then execute a new shell
Code:
# `bash`

i am in a new shell now
# echo "wheres is results my commands "
nothing displayed..but commands are running!
parent shell is try to execute result in backticks so it will try to execute "UNIX.com" when exit the subshell
Code:
# exit
exit
-bash: UNIX.com: command not found

in subshell
Code:
# echo "test"

nothing displayed again!.

try vim
Code:
# vim /usr/local/bin/test
Vim: Warning: Output is not to a terminal

so vim cant access to terminal , let see so why.

in parent shell
Code:
# lsof | grep pts/5 >list

check the shells
Code:
Every 1.0s: ps -eo "%p %P %y %x %c %a %t" | grep pts/5|grep -v grep               Mon May  9 22:05:50 2011
17607 12796 ?        00:00:00 sshd            sshd: root@pts/5               01:04:05
17609 17607 pts/5    00:00:00 bash            -bash                          01:04:05
26611 17609 pts/5    00:00:00 bash            bash                              26:52

Code:
# grep 26611 list
bash      26611      root    0u      CHR              136,5                   7 /dev/pts/5
bash      26611      root    2u      CHR              136,5                   7 /dev/pts/5
bash      26611      root  255u      CHR              136,5                   7 /dev/pts/5

Besides, as seen in above there is not a map with terminal and stdoutput in new shell with backticks..

last of all , in your script bash and ksh is seem success , csh is hanging (but in fact none of the successful)
as a result backticks are un-needed when they already will execute the commands by current shell.

Code:
#!/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" ; exec bash ;;
2) echo "You are now in KSH" ; exec ksh ;;
3) echo "You are now in TCSH" ; exec tcsh ;;
esac
clear

regards
ygemici

Last edited by ygemici; 05-09-2011 at 04:47 PM..
 

10 More Discussions You Might Find Interesting

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

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

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

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

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

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

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

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

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

10. 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
All times are GMT -4. The time now is 06:03 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy