我有一个在Linux环境下使用的bash脚本,但现在我需要在Windows平台上使用它,并想将其转换为可以运行的Python脚本。
这个bash脚本相当简单(我认为),我已经尝试通过谷歌来转换它,但无法成功。
这个bash脚本看起来像这样:
runs=5
queries=50
outfile=outputfile.txt
date >> $outfile
echo -e "\n---------------------------------"
echo -e "\n----------- Normal --------------"
echo -e "\n---------------------------------"
echo -e "\n----------- Normal --------------" >> $outfile
for ((r = 1; r < ($runs + 1); r++))
do
echo -e "Run $r of $runs\n"
db2 FLUSH PACKAGE CACHE DYNAMIC
python reads.py -r1 -pquery1.sql -q$queries -shotelspec -k6 -a5 >> $outfile
done
主要命令是python read.py...等等,它是另一个我得到的Python文件,并且具有如您所见的参数。
我知道这是很大的请求,但如果有人能够将其转换为我可以使用的Python脚本,或者至少给我一些提示和指导,那对我来说真的会很有帮助。
此致
Mestika
根据请求添加:
这是我写的,但没有成功:
runs=5
queries=50
outfile=ReadsAgain.txt
file = open("results.txt", "ab")
print "\n---------------------------------"
print "\n----------- Normal --------------"
print "\n---------------------------------"
file.write("\n----------- Normal --------------\n")
print "\n------------- Query without Index --------------"
file.write("\n------------- Query without Index --------------\n")
for r = 1; r < (%s + 1); r++ % runs
print "Run %s of %s \n" % r % runs
db2 FLUSH PACKAGE CACHE DYNAMIC
output = python reads.py -r1 -pquery1.sql -q$queries -shotelspec -k6 -a5
file.write(output)
file.close()
echo
变成print
)。 - Marcelo Cantos