为什么在特定文件夹中找不到命令? [英] Why command not found in a specific folder?

查看:48
本文介绍了为什么在特定文件夹中找不到命令?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在bin文件夹中有一个.sh文件,但是当我尝试使用它时,服务器无法在该文件夹中找到它.

I have a .sh file in bin folder, but when I try to use it, the server cannot find it in the folder.

/home/monju/full/app/bin $ls
checkServer.sh  etf_disagg_config_loader.sh  getLogName.sh  mapr
common.sh       findLog.sh                   jgrouplog.sh   phase2b
commonStart.sh  findServer.sh                jmx            postInstallSetup.sh
errorLog.ksh    followLog.sh                 jrebel.sh      probe.sh
etf             genTestFile.ksh              killServer.sh  RMSDisable.sh
/home/monju/full/app/bin $stopServer.sh
bash: stopServer.sh: command not found

当我使用/home/monju/full/app/bin/stopServer.sh 时,可以使用它.

while when I use /home/monju/full/app/bin/stopServer.sh, it can be used.

推荐答案

仅仅因为它位于名为 bin 的目录中并不意味着Shell可以神奇地找到它.

Just because it's in a directory named bin doesn't mean the shell can magically find it.

您需要将完整路径放在您的 $ PATH 环境变量中,或将其符号链接到已经在 $ PATH 中的某个位置.

You need to put the full path in your $PATH environment variable, or symlink it to somewhere that's in the $PATH already.

当然,如果您只想从当前目录运行它,则最好使用

Of course, if you only want to run it from the current directory, it's best to use

$ ./stopServer.sh

与您给出的长绝对路径相同,仅使用相对路径语法,其中.表示当前目录.

Which is the same as the long absolute path you gave, only using relative path syntax where . means current directory.

.本身放入 $ PATH 中被认为是不良做法.

Putting . itself in $PATH is considered bad practice.

这篇关于为什么在特定文件夹中找不到命令?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆