On Fri, 2006-05-19 at 09:01 +0200, Tino Wildenhain wrote:
garry saddington wrote:
This code on linux works without a problem
ispell = os.popen("echo " + word + | /opt/scholarpack/ancillary/ispell/bin/ispell -a") ispell.readline sentence = ispell.readline()
What if the word is like `rm -rf /` It is impossible for this to happen because of other controls in place.
for example? Doing something like that above is completely creazy :( There are actually 3 different popen() variants - 2 of them give you stdin too so you better use this to write the "word" to ispells stdin. Don't use echo or something like this! ...
however on windows it throws a string index out of range at the sentence[0] constructs.
the popen command on windows is: ispell=os.popen("echo" +word+ "\scholarpack\ancillary\ispell\bin\ispell -a")
Anyone know what the difference is on the two platforms?
As Andreas already said (and you can easily see by comparing the strings, can you? ;) Python has os.path.join() to construct paths for the actual platform. (And since this is a 3rd party tool anyway, you might want to make it configurable - of course not via ZMI) I am not bothered about the paths, that is not the question. Both commands work in their respective environments. It is the sequence[0] that throws the error so I am looking at differences in the way the results are returned from ispell.readline() regards Garry