简体   繁体   中英

Command not found although in PATH

In my sh or tcsh I can call netstat without problems. With Bash however, I get the message:

bash: netstat: command not found

The PATH variable is exactly the same for all shells:

PATH=/usr/lpp/Printsrv/bin:/usr/lpp/java/J6.0/bin:/EXEX/exec:/bin:/usr/sbin:/etc:/usr/lpp/perl/bin:.:/usr/lpp/ported/bin:.:.

Netstat is in the /bin directory and so should be included in the PATH...

Any ideas?

Thanks!

We don't quite have enough information yet to state what's gone wrong here, but I'm going to go out on a limb and suggest your path isn't what you think it is, not to mention the path you quote is very non-standard and most likely not what you want.

What you say your path is...

The path you quote looks like this when broken down:

/usr/lpp/Printsrv/bin
/usr/lpp/java/J6.0/bin
/EXEX/exec
/bin
/usr/sbin
/etc
/usr/lpp/perl/bin
.
/usr/lpp/ported/bin
.
.

The current working directory ( . ) three times over won't cause a problem, but it does look a little odd.

You're missing the standard directory /usr/bin . And if you have /usr/sbin you ought to have /sbin in there as well for consistency.

I can't imagine why you would ever put /etc in your path. There should never be executables in that directory.

What your path actually is...

There should be no difference between the shells. It's highly unlikely that you've found a bug in the shells here so lets assume your path isn't quite the same in each and try to figure out why it looks like it does...

All shells should tell you that your path is the same thing with BOTH of the two commands:

# The PATH variable
echo "$PATH"

# The PATH environment variable
env | /bin/grep PATH

Remember there are two kinds of variable. Internal Variables and Environment Variables. PATH should be an environment variable.

I'm not sure how you found the following line:

PATH=/usr/lpp/Printsrv/bin:/usr/lpp/java/J6.0/bin:/EXEX/exec:/bin:/usr/sbin:/etc:/usr/lpp/perl/bin:.:/usr/lpp/ported/bin:.:.

If this was taken from your .profile or .bashrc then it should be exported to ensure the PATH gets set as an environment variable.

export PATH=/usr/lpp/Printsrv/bin:/usr/lpp/java/J6.0/bin:/EXEX/exec:/bin:/usr/sbin:/etc:/usr/lpp/perl/bin:.:/usr/lpp/ported/bin:.:.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM