Linux - NewbieThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I'm trying to switch to a k shell for my base, and Ive set the line:
export ENV=$HOME/.kshrc
in my .profile and the /etc/passwd has /bin/ksh as its entry.
When I login, it appears to try and process my .kshrc but for the newlines it returns a "command not found" and that makes me think it's not working properly, as my function(s) I put in there aren't working.
Any thoughts on how to test the reason for the error and to fix it so that my .kshrc gets executed?
Once after login, invoke following cmd to check your shell:-
Code:
~$ echo $SHELL
If it results in ksh, then you can set any new environment variable in your .kshrc as:
Code:
export ENV=$HOME/.kshrc
Or simply,
ENV=$HOME/.kshrc
And then recharge the file to take it into effect as:-
Code:
~$ source .kshrc
If it still gives same error, then comment out this line from your .kshrc and recharge the file again to check whether error is because of this line or any other entry:
# .kshrc -- Commands executed by the Korn shell at startup
#
# Set environmental variables
# Set command line prompt
PS1='${HOSTNAME}:${PWD} >'
#
# Some useful aliases here:
#
alias cd..="cd .."
alias copy="cp"
alias del="rm"
alias hist="history"
alias help="man"
alias ren="mv"
alias type="cat"
#
# change arrow commandline habits
#
alias __A=`echo "\020"`
alias __B=`echo "\016"`
alias __C=`echo "\006"`
alias __D=`echo "\002"`
alias __H=`echo "\001"`
alias __Y=`echo "\005"`
Here's what i get from 'source .profile; which export'
linux2441:/wic/home/mmdewell >which export
/usr/bin/which: no export in (/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin:/opt/informix/bin:/usr/pub:/wic/client/bin:/usr/local/bin/optical:.::/usr/pub:/wic/client/bin:/usr/local/bin/optical:.)
Thanks for your help, yet I'm still getting errors. We can figure this out.
you need (must) not start your .profile with #!/bin/ksh. instead, you can add set -x to check what's happening. There were some additional questions: how did you create that file? what is the exact result of source .profile? also please try echo $0, and show the answer
Well, the removal of '#!/bin/ksh' appears to have done it, though I'm not sure what you mean with the 'set -x' command. Where in do I need to put 'set -x'? Do I need to put it in .profile or .kshrc? And where in that (what line or place with the order of things) do I need to write it?
so a script is executed always by an interpreter. In general you can use shebang (#! at the beginning of the file) to define the interpreter to be used to execute the current script. So you can enter #!perl, #!bash or whatever you need. The source <file> command means the file will be executed by the current shell, therefore the shebang is not evaluated and also can be misleading. for example ~/.profile is used by bash, ksh and zsh too.
see for example here: http://stackoverflow.com/questions/1...of-a-file-mean
Spoke to soon! I forgot that I still had passwd with /bin/bash for my login. So, I fixed that and I'm still getting this error on login:
: not foundome/mmdewell/.kshrc[4]:
: not foundome/mmdewell/.kshrc[7]:
alias not found
: not foundome/mmdewell/.kshrc[18]:
: not foundome/mmdewell/.kshrc[28]:
: not foundome/mmdewell/.kshrc[51]:
ksh: /???/home/mmdewell/.kshrc[55]: syntax error: `(' unexpected
I used '???' to protect some other information that might reveal too much information about where this problem is at.
Here's what i get from 'source .profile; which export'
linux2441:/wic/home/mmdewell >which export
/usr/bin/which: no export in (/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin:/opt/informix/bin:/usr/pub:/wic/client/bin:/usr/local/bin/optical:.::/usr/pub:/wic/client/bin:/usr/local/bin/optical:.)
As you can see, export command is not available in ksh. So the error of "command not found" can be because of this entry in .kshrc:-
Code:
export ENV=$HOME/.kshrc
So either remove export keyword:-
Code:
ENV=$HOME/.kshrc
Or simply comment out this line:-
Code:
# export ENV=$HOME/.kshrc
After this, once source .kshrc to take changes into effect.
Last edited by shivaa; 01-25-2013 at 08:21 AM.
Reason: Formatting
I tried to 'source' at the commandline and it's not finding it. I did a 'whereis source' and it only gave me a 'man' page entry. So, I 'man'ed source and it said things about 'bash' and nothin about 'ksh' in the man-page. Any thoughts? Is it just not in my PATH?
Command source is used to recharge i.e. re-read specified file. Well, I don't understand, you've used source .profile , but now why there's no source?
Anyway, if source isn't there, then exit from your current terminal and open a new one. It will re-read your shell initialization file(s) and will take modified ones into effect. Also check if you still get "command not found" error or not.
linux2441:/???/home/mmdewell >ksh .kshrc
: not found
: not found
alias not found
: not found
: not found
: not found
.kshrc[55]: syntax error: `(' unexpected
I tested the .kshrc that you provided and found that this error is because of "function" keyword before function names in it, so simply remove "fuction" keyword, and source .kshrc again (by exiting and opening a new terminal).
Or copy the new .kshrc from here:
Code:
# .kshrc -- Commands executed by the Korn shell at startup
#
# Set environmental variables
# Set command line prompt
PS1='${HOSTNAME}:${PWD} >'
#
# Some useful aliases here:
#
alias cd..="cd .."
alias copy="cp"
alias del="rm"
alias hist="history"
alias help="man"
alias ren="mv"
alias type="cat"
#
# change arrow commandline habits
#
alias __A=`echo "\020"`
alias __B=`echo "\016"`
alias __C=`echo "\006"`
alias __D=`echo "\002"`
alias __H=`echo "\001"`
alias __Y=`echo "\005"`
#
# entries added from Chad D. Young's .profile
#
export HISTFILE=${HOME}/.sshistory
export EXINIT="set showmode"
export HZ=100
# export MAIL=/usr/mail/${LOGNAME:?}
# export PATH=$PATH:/usr/local/bin:/usr/pub:/wic/client/bin:/usr/local/bin/optical:.
export PATH=$PATH:/usr/pub:/wic/client/bin:/usr/local/bin/optical:.
# export PGPPATH=/wic/home/wi/.pgp
# export PGPPASS=west
export SHELL=/bin/ksh
# export TERM=vt100
export VISUAL=/usr/bin/vi
export HOST=`hostname`
# export CVS_RSH=remsh
# export CVS_SERVER=/usr/local/bin/cvs
# export CVSROOT=:ext:$LOGNAME@ibm32:/wic/cvs
# export CVS_SERVER=/wic/local/bin/cvs
# export CVSROOT=/wic/cvs
# export CVS_RSH=rsh
# export CVSUMASK=000
#
# funtion to use as 'dir' command
#
adir(){
ls -la $1 | grep "^d" && ls -la $1 | grep "^-" && ls -la $1 | grep "^l" | more;
}
dir(){
ls -l $1 | grep "^d" && ls -l $1 | grep "^-" && ls -l $1 | grep "^l";
}
Second thing, once confirm your default shell:
Code:
grep 'mmdewell' /etc/passwd
It's last field will give you your default shell.
Last edited by shivaa; 01-25-2013 at 07:32 PM.
Reason: Addition
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.