LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 10-24-2010, 01:32 AM   #1
SharonGe
LQ Newbie
 
Registered: Oct 2010
Distribution: Ubuntu
Posts: 10

Rep: Reputation: 0
Run script in kSh


Hi,
I want to run some ksh script in my virtual machine which is in ubuntu. Although I have install ksh, the shell is always remain in bash. What was wrong? Please help.
 
Old 10-24-2010, 01:41 AM   #2
mesiol
Member
 
Registered: Nov 2008
Location: Lower Saxony, Germany
Distribution: CentOS, RHEL, Solaris 10, AIX, HP-UX
Posts: 731

Rep: Reputation: 137Reputation: 137
Hi,

your login shell will be bash per default. To run a script in a ksh environment add a hash bang like this to the first line of your script
Code:
#!/bin/ksh
. This will create a ksh shell, inside this shell only the script will run. There is no need to change your login shell.

If you like to test/develop your script in ksh, easily run
Code:
ksh
.
 
1 members found this post helpful.
Old 10-24-2010, 01:44 AM   #3
jdkaye
Senior Member
 
Registered: Dec 2008
Location: Westgate-on-Sea, Kent, UK
Distribution: Debian Testing Amd64
Posts: 4,703

Rep: Reputation: Disabled
Assuming you have installed the ksh package, have you tried running
Code:
ksh93
from the commandline to see what happens?
ciao,
jdk
 
1 members found this post helpful.
Old 10-24-2010, 02:22 AM   #4
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian sid + kde 3.5 & 4.4
Posts: 6,823

Rep: Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947
If you're talking about setting a different default shell for the user, there's a tool for that: chsh.

It's also possible to do it by manually modifying the user's entry in the /etc/passwd file.
 
1 members found this post helpful.
Old 10-24-2010, 12:28 PM   #5
SharonGe
LQ Newbie
 
Registered: Oct 2010
Distribution: Ubuntu
Posts: 10

Original Poster
Rep: Reputation: 0
I think I didn't explain my question well, sorry
I tried to figure what shells I have and did the following:
user@user-desktop:~/Desktop$ cat /etc/shells
# /etc/shells: valid login shells
/bin/csh
/bin/sh
/usr/bin/es
/usr/bin/ksh
/bin/ksh
/usr/bin/rc
/usr/bin/tcsh
/bin/tcsh
/usr/bin/esh
/bin/dash
/usr/bin/screen
/bin/bash
/bin/rbash
/bin/ksh93
Then I think I probably type "ksh" and will change shell, but
user@user-desktop:~/Desktop$ ksh
$ echo $SHELL
/bin/bash

see, it is showing the current shell is still bash.

What I really want to do is to test a simple ksh script; I plan to change my shell temporary and see if the script is working. I know it is a really stupid question, but I am too new in linux.

Last edited by SharonGe; 10-24-2010 at 12:30 PM.
 
Old 10-24-2010, 12:51 PM   #6
jdkaye
Senior Member
 
Registered: Dec 2008
Location: Westgate-on-Sea, Kent, UK
Distribution: Debian Testing Amd64
Posts: 4,703

Rep: Reputation: Disabled
That seems to be just a list of all possible shells. Running the same command on my system also shows ksh but it is not installed on my system.
Code:
# /etc/shells: valid login shells
/bin/csh
/bin/sh
/usr/bin/es
/usr/bin/ksh
/bin/ksh
/usr/bin/tcsh
/bin/tcsh
/usr/bin/esh
/bin/dash
/bin/bash
/bin/rbash
jdk
 
1 members found this post helpful.
Old 10-24-2010, 01:08 PM   #7
SharonGe
LQ Newbie
 
Registered: Oct 2010
Distribution: Ubuntu
Posts: 10

Original Poster
Rep: Reputation: 0
Smile

Wow! I thought I did install from "synaptic package manage", because I install my emacs from there and it is working. If that is the case, Can I find a manual or guide to finish the installation?
Quote:
Originally Posted by jdkaye View Post
That seems to be just a list of all possible shells. Running the same command on my system also shows ksh but it is not installed on my system.
Code:
# /etc/shells: valid login shells
/bin/csh
/bin/sh
/usr/bin/es
/usr/bin/ksh
/bin/ksh
/usr/bin/tcsh
/bin/tcsh
/usr/bin/esh
/bin/dash
/bin/bash
/bin/rbash
jdk
 
Old 10-24-2010, 11:20 PM   #8
mesiol
Member
 
Registered: Nov 2008
Location: Lower Saxony, Germany
Distribution: CentOS, RHEL, Solaris 10, AIX, HP-UX
Posts: 731

Rep: Reputation: 137Reputation: 137
Hi,

From the bash man page
Code:
SHELL  
The full pathname to the shell is kept in this environment variable. 
If it is not set when the shell starts, bash assigns to it the full pathname
of the current user’s login shell.
and in you example, ksh is not your login shell.

Last edited by mesiol; 10-24-2010 at 11:21 PM.
 
1 members found this post helpful.
Old 10-24-2010, 11:38 PM   #9
jdkaye
Senior Member
 
Registered: Dec 2008
Location: Westgate-on-Sea, Kent, UK
Distribution: Debian Testing Amd64
Posts: 4,703

Rep: Reputation: Disabled
Quote:
Originally Posted by SharonGe View Post
Wow! I thought I did install from "synaptic package manage", because I install my emacs from there and it is working. If that is the case, Can I find a manual or guide to finish the installation?
Code:
aptitude search ksh
This will tell you if ksh is installed or not.
ciao,
jdk
 
1 members found this post helpful.
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] KSH script cheltz Linux - Newbie 12 05-21-2010 03:57 PM
Ksh Script Help sharathkv25 Programming 10 02-02-2007 10:28 AM
help w/ksh script ShaqDiesel Programming 2 01-12-2007 02:04 PM
Can somebody help me with a ksh script? twentymil AIX 7 01-21-2004 09:55 AM
KSH script AquamaN Programming 2 12-08-2003 11:34 AM


All times are GMT -5. The time now is 03:13 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration