【发布时间】:2019-11-16 16:22:40
【问题描述】:
我编写了这段代码,用于在我的 Linux 远程机器上执行一些不同输入的重复实验。
#!/bin/bash
#timeout 10m
trap "exit 1" INT
repeat() {
executiontime=$( /usr/bin/time /home/me/optimathsat-1.5.1-macos-64-bit/bin/optimathsat < file.smt2 2>&1 >/dev/null)
echo "$executiontime">>results.csv
}
export -f repeat
for length in 30 ; do
step=0.05
short=0 #0
long=1
for i in {1..10}; do
ratio=0
for j in {1..10}; do
declare -a listofresults
echo "$length $short $long $ratio">>results.csv
python3 main.py "$length" "$short" "$long" "$ratio">file.smt2
chmod 775 file.smt2
declare total=0
declare m=0
parallel -n0 repeat ::: {1..10}
ratio=$(echo "scale=10; ($ratio) + ($step)" | bc)
done
short=$(echo "scale=10; ($short) + ($step)" | bc)
long=$(echo "scale=10; ($long) - ($step)" | bc)
done
done
trap - INT
我已经在我自己的 mac 机器上执行了这段代码并且它可以工作(使用 gtime 而不是 /usr/bin/time )但是现在我收到了这个错误,我不知道它是什么意思/
0inputs+0outputs (0major+66minor)pagefaults 0swaps
/home/me/optimathsat-1.5.1-macos-64-bit/bin/optimathsat: 1: /home/project/optimathsat-1.5.1-macos-64-bit/bin/optimathsat:
Syntax error: word unexpected (expecting ")")
当我尝试手动执行指令时,我得到了这个:
src$ python3 main.py 10 0.5 0.5 0.5>file.smt2
我检查了file.smt2,它应该是,然后发生这种情况
src$ /home/project/optimathsat-1.5.1-macos-64-bit/bin/optimathsat < file.smt2
-bash: /home/project/optimathsat-1.5.1-macos-64-bit/bin/optimathsat: cannot execute binary file: Exec format error
【问题讨论】:
-
为什么用python标记?
-
错字:
!/bin/bash应该是#!/bin/bash -
能否请您运行带有跟踪的脚本?那是
$ bash -x myscript.sh。它将显示导致错误的行。见tldp.org/LDP/Bash-Beginners-Guide/html/sect_02_03.html -
@waffles123,请确保向我们显示准确的minimal reproducible example。我们不能指望猜测哪些错误是相关的,哪些不相关。复制和粘贴是最好的。
-
我认为问题出在
optimathsat程序中,而不是这个脚本中。
标签: linux bash macos shell optimathsat