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 02-14-2013, 01:41 AM   #1
charithsrng
LQ Newbie
 
Registered: Jan 2013
Posts: 19

Rep: Reputation: Disabled
basename: invalid option -- b


apps_down(){
. /ebiz1/QAL/apps/apps_st/appl/QALNEW_ct-eagorasvr1.env
su - applclone -c "whoami
echo $ADMIN_SCRIPTS_HOME
. $ADMIN_SCRIPTS_HOME/adstpall.sh apps/apps" > /home/applclone/error.txt
}

when executing above script am getting below output.anyway it will redirects the output in to the txt file. please advice.

basename: invalid option -- b
Try `basename --help' for more information.
 
Old 02-14-2013, 02:00 AM   #2
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.6, Centos 5.10
Posts: 16,324

Rep: Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041
Like it says, there's no --b option for basename cmd http://linux.die.net/man/1/basename.
Somewhere in those calls, you're calling basename. You need to read through those 'source' aka '. blah..' cmds and find it.
You may find it helpful to add
Code:
set -xv
at the top of the fn
 
Old 02-14-2013, 02:31 AM   #3
charithsrng
LQ Newbie
 
Registered: Jan 2013
Posts: 19

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by chrism01 View Post
Like it says, there's no --b option for basename cmd http://linux.die.net/man/1/basename.
Somewhere in those calls, you're calling basename. You need to read through those 'source' aka '. blah..' cmds and find it.
You may find it helpful to add
Code:
set -xv
at the top of the fn
Thanks for the rply.
below is the place which i found base name on my script. Is there a way that i can redirect output without prompting this messsage

program=`basename $0`
usage_msg="\t$program <appsusername/appspassword>\n \t$program <applications_username/applications_password> -secureapps\n \t$program -nodbchk"
 
Old 02-14-2013, 03:42 AM   #4
shivaa
Senior Member
 
Registered: Jul 2012
Location: Grenoble, Fr.
Distribution: Sun Solaris, RHEL, Ubuntu, Debian 6.0
Posts: 1,797
Blog Entries: 4

Rep: Reputation: 285Reputation: 285Reputation: 285
But there's no option i.e. -b associated with basename in your script.

Note that,
Code:
program=`basename $0`
is actually used to run the script again, if some condition fails and script needs to be run again.

So as chris said, once invoke your script with set -xv so debugging can be done.
Code:
#!/bin/bash
set -xv
(Rest script)
 
Old 02-14-2013, 12:37 PM   #5
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 2,325

Rep: Reputation: 593Reputation: 593Reputation: 593Reputation: 593Reputation: 593Reputation: 593
I'll make a small bet that the value of "$0" in the basename is "-bash"

I base this on the fact that the sequence of commands involves "su -" and then does a "-c" with commands following in a quoted string.

The command that is likely using "basename" is the line:
Code:
. $ADMIN_SCRIPTS_HOME/adstpall.sh apps/apps" > /home/applclone/error.txt
Which executes the script in the context of the running shell (which is started via the "-c" option of su), and that makes it an interactive shell (hence the -bash is the value of $0). So the "basename -bash" fails as "-b" is not a valid option...

It appears that the adstpall.sh script is designed to be executed by name, not included in the current context.

I suspect it would work by just dropping the ". " from the command line.
 
2 members found this post helpful.
Old 02-15-2013, 01:51 AM   #6
charithsrng
LQ Newbie
 
Registered: Jan 2013
Posts: 19

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by jpollard View Post
I'll make a small bet that the value of "$0" in the basename is "-bash"

I base this on the fact that the sequence of commands involves "su -" and then does a "-c" with commands following in a quoted string.

The command that is likely using "basename" is the line:
Code:
. $ADMIN_SCRIPTS_HOME/adstpall.sh apps/apps" > /home/applclone/error.txt
Which executes the script in the context of the running shell (which is started via the "-c" option of su), and that makes it an interactive shell (hence the -bash is the value of $0). So the "basename -bash" fails as "-b" is not a valid option...

It appears that the adstpall.sh script is designed to be executed by name, not included in the current context.

I suspect it would work by just dropping the ". " from the command line.
Yooooooooooo, This is working perfectly. You have clearly explained the reason and solution above.
You saved my day. Thanks alot.
 
  


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] rm: invalid option -- 'w'. Why this happened? e3399 Linux - Newbie 5 12-11-2010 12:39 PM
“basename $0” returns basename: -k: unknown option jaideepca Linux - Newbie 6 11-09-2009 06:30 AM
dkmraid -i invalid option sang_froid Linux - General 0 10-16-2006 09:50 AM
cp indicates invalid option Murdock1979 Linux - Software 1 01-24-2006 03:21 AM
in.telnetd: invalid option -- L implant23 Linux - Networking 1 12-01-2002 12:17 PM


All times are GMT -5. The time now is 07:00 PM.

Main Menu
Advertisement
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