How to pass a multiline arg to exec('some.exe arg')?

alexelder at gmail.com alexelder at gmail.com
Mon May 5 06:47:51 EDT 2008


On May 5, 10:25 am, n00m <n... at narod.ru> wrote:
> os:windows
> ml = 'line1 \n line2 \n line3 \n'
> exec('some.exe "' + ml + '"')
>
> and some.exe get only 'line1'...

I think your problem lies with your "\n", escape chars. Assuming these
are not arguments and are indeed separating statements, I suggest
replacing "\n", with "&". That way, the command shell probably wont
complain.

An example:
ml = 'line1 & line2 & line3'

Alex.



More information about the Python-list mailing list