csh 脚本找不到可执行文件

发布于 2024-12-14 20:30:06 字数 728 浏览 0 评论 0原文

对于当前的项目,我需要运行GENESIS遗传算法程序,教授提供了一个csh脚本,可以让我们轻松传入适应度函数以及外部初始化和模板文件。

该脚本调用 makefile 来构建可执行文件,将适应度函数添加到混合中并生成可执行文件 ga.FIT,其中 FIT 是精细度函数源文件的名称。

在学校运行 Ubuntu 10.04 的机器上,运行这个脚本没有任何问题。但是,当我尝试在我的计算机上运行它时,我得到以下输出:

./go cancer2 ex0
Note: Genesis files modified for use on USM Linux cluster
Note2: ga.cancer2 is your executable (e.g., if you need to use the debugger)
making executables ...
make: `ga.cancer2' is up to date.
make: `report' is up to date.
running ga.cancer2 ex0 ...
ga.cancer2: Command not found.

但是可执行文件就在那里!我可以通过 ga.cancer2 ex0 手动单独调用它,它在 csh 和 bash 提示符下运行。我已验证这不是权限问题,因为已将 chmod 755 的等效项设置为可执行文件。

这是 csh 特有的东西吗?我应该考虑修改 bash 的脚本,还是坚持远程处理学校系统?

For the current project, I need to run the GENESIS genetic algorithm program, and the professor has provided a csh script that allows us to easily pass in the fitness function as well as external initilization and template files.

The script calls the makefile to build the executable, adding the fitness function to the mix and produces an executable ga.FIT, where FIT is the name of the finess function source file.

On the machines at school runnung Ubuntu 10.04, there is no problem whatsoever running this script. However, when I try to run it on my machine, I get the following output:

./go cancer2 ex0
Note: Genesis files modified for use on USM Linux cluster
Note2: ga.cancer2 is your executable (e.g., if you need to use the debugger)
making executables ...
make: `ga.cancer2' is up to date.
make: `report' is up to date.
running ga.cancer2 ex0 ...
ga.cancer2: Command not found.

But the executable IS there! I can manually call it separately via ga.cancer2 ex0 and it runs at both the csh and bash prompts. I've verified its not a permissions issue as the equivalent of chmod 755 has been set to the executable.

Is this something specific to csh, and should I look into modifying the script for bash, or stick to remoting in to the school system?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

江湖正好 2024-12-21 20:30:06

看起来 ga.cancer2 位于您的当前目录中。 Basile 的答案应该有效,但修改脚本可能是更好的主意,以便它调用 ./ga.cancer2 而不是 ga.cancer2

一般来说,在您的 $PATH 中包含 . 是一个潜在的安全风险(无论您使用哪种 shell)。想象一下,cd进入一个目录,其中有人植入了一个ls命令来进行邪恶的操作。如果您确保 . 不在您的 $PATH 中(并养成输入 ./command 的习惯,以在您的 $PATH 中执行命令)当前目录),您就可以避免这种风险。

. 放在 $PATHend 风险较小,但由于测试程序最常见的名称是 test< /code> ,而 test 会调用 /bin/test./command 习惯还是一个好习惯。

Basile 有一个很好的观点,即 csh 并不是编写脚本的最佳 shell ——但是从输出的外观来看,您正在运行的脚本可能足够简单,因此不会产生太多影响不同之处。尽管如此,良好的习惯等等。

It looks like ga.cancer2 is in your current directory. Basile's answer should work, but it's probably a better idea to modify the script so it invokes ./ga.cancer2 rather than ga.cancer2.

In general, having . in your $PATH is a potential security risk (regardless of which shell you're using). Imagine cding into a directory in which someone has planted an ls command that does something evil. If you make sure . isn't in your $PATH (and get into the habit of typing ./command to execute a command in your current directory), you avoid this risk.

Having . at the end of $PATH is less risky -- but since the most common name for a test program is test, and test will invoke /bin/test, the ./command habit is still a good one.

And Basile has a good point that csh is not the best shell for writing scripts -- but from the looks of the output, the script you're running is probably simple enough that it doesn't make much difference. Still, good habits and all that.

萌能量女王 2024-12-21 20:30:06

也许您需要将 . 添加到您的 $PATH 中。

一旦你参加了考试,告诉你的教授著名的 C -shell 认为有害论文,并建议他阅读维基百科“考虑”有害” 页面。

Perhaps you need to add . to your $PATH.

And once you've got your exam, tell your professor about the famous C-shell considered harmful paper, and suggest him to read the Wikipedia "Considered Harmful" page.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文