Note that there are some explanatory texts on larger screens.

plurals
  1. POConverting a bash script to python (small script)
    primarykey
    data
    text
    <p>I’ve a bash script I’ve been using for a Linux environment but now I have to use it on a Windows platform and want to convert the bash script to a python script which I can run.</p> <p>The bash script is rather simple (I think) and I’ve tried to convert it by google by way around but can’t convert it successfully.</p> <p>The bash script looks like this:</p> <pre><code>runs=5 queries=50 outfile=outputfile.txt date &gt;&gt; $outfile echo -e "\n---------------------------------" echo -e "\n----------- Normal --------------" echo -e "\n---------------------------------" echo -e "\n----------- Normal --------------" &gt;&gt; $outfile for ((r = 1; r &lt; ($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 &gt;&gt; $outfile done </code></pre> <p>The main command, the python read.py … etc. is another python file I’ve been given and have the arguments as you see.</p> <p>I know it is a lot to ask for, but it would really help me out if someone could convert this to a python script I can use or at least give me some hints and directions.</p> <p>Sincerely</p> <p>Mestika</p> <h1>Added per request:</h1> <p>This is what I've written but without success:</p> <pre><code>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 &lt; (%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() </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload