bug-sh-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

my bug report1: BASH command which says my shell script is not found eve


From: Satya Nemana
Subject: my bug report1: BASH command which says my shell script is not found evenif it exists under $PATH, unless I add #!/bin/sh in the 1st line
Date: Fri, 29 Jun 2001 09:38:29 -0700 (PDT)

Hi,

1st of all, I am very much delighted to use the GNU
tools that I downloaded from www.cygnus.com.

Here is a bug report on BASH command 'which' and
probably related 'chmod' and/or 'ls -ls' as well.

A. summary of my bug report1:
----------------------------

BASH command which says my shell script is not found
evenif it exists under $PATH, unless I add #!/bin/sh
in the 1st line

B. Details:
-----------

If I write my own shell scripts and store under my own
directories and add that directory name into my $PATH
and chmod it to executable to mode, it gets executed
alright, but it is not recognized by 'which' command,
and also it is not indicated as an executable with x
flag in rwx in ls -ls output.

The work around is to make sure that, we always add
the #!/bin/sh as the 1st line in that user script.

C. How to reproduce the problem?
--------------------------------

1. Run the following commands

$ mkdir $HOME/bin
$ export PATH="$PATH:$HOME/bin"

2. Create my following script vii under your $HOME/bin
What it does is...

- it accepts a command line argument as input string,
which is supposed to be some executable file -- some
shell script

- it runs 'which' on that string and if it is found
under $PATH, then it opens a vi-session to edit that
script.

This way, user need not remeber where are all those
shell scripts, he wrote and stored under what
directories.

$ cd $HOME/bin
$ cat vii
cmd=$1
fullpath=$(which $cmd 2>/dev/null)
pathknt=$(echo $fullpath | wc -w)
if [ $pathknt -eq 1 ]
then
        echo OK, $cmd is found in $fullpath. Enter
return to view.
        read x
        vi $fullpath
else
        echo Sorry, $cmd is not found in your $PATH
fi

$ chmod a+x vii

3. Try a direct whcih command on it and it fails:
$ which vii
no vii in
/usr/local/bin:/usr/bin:/bin:/cygdrive/c/WINNT/system32:/cygdrive/c/WINNT:/cygdrive/c/WINNT/System32/Wbem:/home/Administrator/bin

4. Even the ls -ls does not say that that x bit is set
for allowing execution mode.
$ ls -ls
total 2
   1 -rw-r--r--    1 Administ None          250 Jun 29
12:18 vii
$

4. Now execute my shell script vii
$ vii vii
Sorry, vii is not found in your
/usr/local/bin:/usr/bin:/bin:/cygdrive/c/WINNT/system32:/cygdrive/c/WINNT:/cygdrive/c/WINNT/System32/Wbem:/home/Administrator/bin

D. Workaround:

5. Now add #!/bin/sh as the 1st line in the above
script and everything wotrks as  expected.

$ which vii
/home/Administrator/bin/vii
address@hidden /cygdrive/z/Public/tools/bin
$ cd $HOME/bin
$ ls -ls
total 2
   1 -rwxr-xr-x    1 Administ None          248 Jun 29
12:13 vii
$

If you have a solution, or planning to fix it in next
release, please let me know.
I can volunteer to fix it as well and proide a fix.
Please let me know how to signup.

Thanks,
Satya Nemana

Home Phone: 732-264-5756
EMail: address@hidden


__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/



reply via email to

[Prev in Thread] Current Thread [Next in Thread]