【发布时间】:2011-02-19 20:30:39
【问题描述】:
我有一个用于 Linux 环境的 bash 脚本,但现在我必须在 Windows 平台上使用它,并且想将 bash 脚本转换为我可以运行的 python 脚本。
bash 脚本相当简单(我认为),我尝试通过 google 对其进行转换,但无法成功转换。
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 脚本,或者至少给我一些提示和方向,那真的会帮助我。
真诚的
梅斯蒂卡
按请求添加:
这是我写的,但没有成功:
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()
【问题讨论】:
-
您之前的努力是什么样的?这是一个问答网站,而不是免费的代码商店,所以如果您自己努力解决问题,您更有可能获得帮助。至少上面的一些东西可以简单地转换为 Python(
echo=>print等)。 -
嗨,Marcelo,我明白你在说什么,当然我会发布我自己的努力,因为我试图在 python 脚本中重新创建 bash 文件。我将发布我的 python 代码
-
您的 Python 代码无法编译这一事实可能至少会给您一个线索。采取最少的步骤来学习您想要使用的语言可能会有所帮助:docs.python.org/tutorial