LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   “basename $0” returns basename: -k: unknown option (https://www.linuxquestions.org/questions/linux-newbie-8/%93basename-%240%94-returns-basename-k-unknown-option-767306/)

jaideepca 11-06-2009 07:58 AM

“basename $0” returns basename: -k: unknown option
 
Hi,

I am setting oracle Environment in one of my server(RHEL5). Below is the error i am getting. I am using kshell.

Th=$" (basename $0) "--------returns
basename: -k: unknown option
basename: -s: unknown option
basename: -h: unknown option

Can any one help me to sort above problem.

Thank you
Jaidhe

catkin 11-06-2009 08:06 AM

Try
Code:

echo "DEBUG \$0: '$0'"
before the call to basename to see if $0 has the value you think it has.

There should be no space between $ and ( in $(<some command(s)>)

jaideepca 11-06-2009 08:12 AM

error
 
Same script and command working fine on RHEL4, but i am getting error in RHEL5.

Thank You!

timmeke 11-06-2009 08:23 AM

@jaideepca: please listen to senior members. If you're not here to take advice, then you're not in the right place.
I think catkin is on the right track: what is $0 set to? In other words, what is the name of your script?

jaideepca 11-09-2009 03:45 AM

echo $'DEBUG $0: \'-ksh\''
 
After setting up DEBUG, getting below error.

+ echo $'DEBUG $0: \'-ksh\''
DEBUG $0: '-ksh'
+ basename -ksh
-ksh: basename: -k: unknown option
-ksh: basename: -s: unknown option
-ksh: basename: -h: unknown option
Usage: basename [ options ] string [suffix]

Thanks!

catkin 11-09-2009 04:26 AM

OK, so $0 contains -ksh. Your script shows you expected it to be a file name. How does $0 get its value? What is the name of your script and how are you calling it?

jaideepca 11-09-2009 05:30 AM

basename $0
 
Thanks catkin,

Below is the format

. /u01/oracle/env -t test

I am using RHEL 5 and using SHELL as kshell.

echo $SHELL
/usr/bin/ksh


All times are GMT -5. The time now is 04:41 PM.