Mnetgen:bash文件和语法错误

编程入门 行业动态 更新时间:2024-10-27 05:24:35
Mnetgen:bash文件和语法错误 - 哪里出错?(Mnetgen: bash-files and syntax errors - where's the bug?)

我想在Mnetgen的帮助下创建Multicommodity Min Cost Flow实例,但我遇到了名为“batch”的文件问题,其第一行由

# Batch file for generating MMCF problems with the mnetgen random generator # # For each n in {64, 128, 256} generates 12 instances for each pair (n, k) # with k in {4, 8, 16 , ... , n}, using as input the parameters found # in pr{n}.{k}/{n}-{k}-{h}.inp for h in {1, ... , 12}. The instances # are left in the directory pr{n}.{k} # # At the end of the file, commented out, there are the instructions for # generating the groups with n = 512 and n = 768: in the latter case, # however, only 6 instances for each group are generated. # # In a Unix environment, simply type "source batch" or "csh < batch" foreach i ( 64 ) foreach j ( 4 8 16 32 64 ) foreach h ( 1 2 3 4 5 6 7 8 9 10 11 12 ) mnetgen pr$i.$j/$i-$j-$h.inp pr$i.$j/$i-$j-$h end end end ...

到目前为止我做了什么? 首先,我将#include <cstring>添加到mnetgen.c以避免错误。 然后我输入make来获取可执行文件mnetgen 。 最后一步是使用批处理文件生成实例。

使用上一个评论行中的提示,我得到了

bash: batch: Zeile 14: Syntaxfehler beim unerwarteten Wort »(« bash: batch: Zeile 14: 'foreach i ( 64 )'

要么

mnetgen: Command not found.

我该如何解决这个问题?

I want to create Multicommodity Min Cost Flow instances with the help of Mnetgen but I have problems with the file called "batch" whose first lines are given by

# Batch file for generating MMCF problems with the mnetgen random generator # # For each n in {64, 128, 256} generates 12 instances for each pair (n, k) # with k in {4, 8, 16 , ... , n}, using as input the parameters found # in pr{n}.{k}/{n}-{k}-{h}.inp for h in {1, ... , 12}. The instances # are left in the directory pr{n}.{k} # # At the end of the file, commented out, there are the instructions for # generating the groups with n = 512 and n = 768: in the latter case, # however, only 6 instances for each group are generated. # # In a Unix environment, simply type "source batch" or "csh < batch" foreach i ( 64 ) foreach j ( 4 8 16 32 64 ) foreach h ( 1 2 3 4 5 6 7 8 9 10 11 12 ) mnetgen pr$i.$j/$i-$j-$h.inp pr$i.$j/$i-$j-$h end end end ...

What did I so far? First I added #include <cstring> to mnetgen.c to avoid errors. Then I typed make to get an executable file mnetgen. The last step would be to generate the instances by using the batch-file.

Using the hint in last comment line I get either

bash: batch: Zeile 14: Syntaxfehler beim unerwarteten Wort »(« bash: batch: Zeile 14: 'foreach i ( 64 )'

or

mnetgen: Command not found.

How can I fix that?

最满意答案

您正在尝试在bash中运行csh shell。

要解决这个问题,请运行

csh myshell

或添加第一行:

#!/bin/csh

运行命令时,Unix / linux将检查第一行,它将被视为一种幻数,并以/bin/csh前缀。

(有更好的方法可以使用#!/bin/env csh )

对于未找到的mnetgen命令,我建议您在脚本中添加命令的完整路径或将其添加到系统PATH中。

You are trying to run a csh shell in bash.

To fix that, either run

csh myshell

or add on the first line:

#!/bin/csh

When running your command, Unix/linux will check the first line which will be seen as a kind of magic number and will prefix it by /bin/csh.

(there are better ways to do that maybe with #!/bin/env csh)

and for your mnetgen command which is not found, I suggest that you add the full path of your command in your script or add it to the system PATH.

更多推荐

本文发布于:2023-07-20 12:36:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1199623.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:语法错误   文件   Mnetgen   bash

发布评论

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

>www.elefans.com

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