为什么在特定文件夹中找不到命令?

编程入门 行业动态 更新时间:2024-10-28 10:25:19
本文介绍了为什么在特定文件夹中找不到命令?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

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

更多推荐

为什么在特定文件夹中找不到命令?

本文发布于:2023-11-13 10:07:34,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1584092.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:找不到   命令   文件   夹中   在特定

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!