使用“批处理”运行批处理文件命令

发布于 2025-01-15 10:48:18 字数 242 浏览 0 评论 0原文

我目前正在开发一个项目,其中的可交付成果是 .sh 文件。当我使用 ./file.sh 运行该文件时,它工作得很好。但根据教授的说法。我们必须使用此语句运行该文件。 批处理文件.sh。这不起作用,返回的错误是batchaccepts noparameter。阅读手册页后这是有道理的。

使用批处理命令的正确方法是什么?是否有可能按照教授想要的方式运行?

I am currently working on a project in which the deliverable is a .sh file. When I run the file using ./file.sh it works just fine. But according to the prof. we have to run the file using this statement. Batch file.sh. This does not work, and the errors returned are batch accepts no parameters. Which makes sense after reading the man page.

What is the proper way to use the batch command? Is it even possible to run it the way that the professor wants?

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

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

发布评论

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

评论(1

葬シ愛 2025-01-22 10:48:18

根据您的描述,您尝试执行的文件不应该使用Batch执行,而是Bash/Shell执行。

批处理文件之后,Batch 不应使用 sh< /em> 扩展名(sh 代表 shell)。

您可以通过以下方式验证您尝试使用的程序应使用哪种解释器运行:

  1. 检查 shebang
  2. 使用file 命令(即file ./your_program.sh

找到正确的解释器后,您可以通过调用它来运行程序(即sh ./your_program.sh

According to your description, the file you are trying to execute shouldn't be executed with Batch but Bash/Shell.

Following Batch file, Batch is not supposed to run programs with the sh extension (sh stands for shell).

You can validate what interpreter the program you are trying to use should be run with with the following ways:

  1. Checking the shebang
  2. Using the file command (i.e. file ./your_program.sh)

After finding the correct interpreter, you can run the program with calling it (i.e. sh ./your_program.sh)

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