bash 尽管在 PATH 中,但未找到命令

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/28274951/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 12:18:00  来源:igfitidea点击:

Command not found although in PATH

bashuss

提问by Klaus Schulz

In my shor tcshI can call netstatwithout problems. With Bash however, I get the message:

在我shtcsh我可以netstat毫无问题地打电话。但是,使用 Bash,我收到消息:

bash: netstat: command not found

The PATH variable is exactly the same for all shells:

所有 shell 的 PATH 变量完全相同:

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...

Netstat 位于 /bin 目录中,因此应包含在 PATH 中...

Any ideas?

有任何想法吗?

Thanks!

谢谢!

回答by Philip Couling

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/sbinyou ought to have /sbinin there as well for consistency.

您缺少标准目录/usr/bin。如果你有,/usr/sbin你也应该/sbin在那里保持一致性。

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

我无法想象为什么你会/etc在你的道路上。该目录中不应该有可执行文件。

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...

壳之间应该没有区别。您在这里发现 shell 中的错误的可能性很小,所以让我们假设您的路径在每个 shell 中并不完全相同,并尝试找出为什么它看起来如此......

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

所有的 shell 都应该告诉你,你的路径与这两个命令是一样的:

# 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.

请记住,有两种变量。内部变量和环境变量。PATH 应该是一个环境变量。

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 .profileor .bashrcthen it should be exported to ensure the PATH gets set as an environment variable.

如果这是从你采取.profile.bashrc那就应该出口以确保路径被设置为一个环境变量。

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:.:.