• 1 reply
  • Latest Post - ‏2005-11-03T21:56:50Z by SystemAdmin
232 Posts

Pinned topic Curly Brackets in Windows

‏2004-09-29T03:23:57Z |
I am new in programming and recently I have to change my colleague's codes. He wrote his script in python for Linux. I am using the same script but need to modify for windows.
Somehow, it doesnt work, and giving an error message at the beginning of the curly bracktes.

here is code.
os.system('python %s %s %s %s |awk '{if (%0 ~ /<output>/) (s= gensub(/\t*<\/*output>/, "", "g"); printf("%%s ", s);}if (%0 ~ /<score>/) ( s= gensub(/\t*<\/*score>/, "", "g"); print s; }} ' | head -1 | tee %s | awk '{for (i=1 ; i < NF ; i++) print "_"$i " "$NF;}' > %s' % (asr_host, asr_port, asrclassname, tmpfname, tresfname, tresfname2));

I tried to change it but doesnt work.
just want to let u know its only one statement.
Can I break this into many or different statements? if yes, then how?
Updated on 2005-11-03T21:56:50Z at 2005-11-03T21:56:50Z by SystemAdmin
  • SystemAdmin
    232 Posts

    Re: Curly Brackets in Windows

    You have two problems here.

    One is quoting.
    In your os.system() call the command to execute is quoted.
    I'm not familiar with python specifically, but something like this would be executed: os.system('copy c:\wtf\* d:\wtf') to copy some files. The single quote begins the string of the command to execute. In your code, right after the first "awk" you have a single quote. This completes the string to execute, and python doesn't know why you've got a { next. You will have quite a bit of clean up to get the quotes right.

    The second problem you'll have, even if you get the quotes cleaned up, it that as your sample was written for linux, it assumes a lot of things that are standard on linux and unix systems. Your windows installation almost certainly does not have the following commands that your script uses:
    awk, head, tee. You'll have to find those for windows, and hope they work the same way. You can get these from But that's just the beginning.

    I'd start by replacing the first single quote (') with a double quote (") and the last single quote (') with a double quote (").... but then the double quotes in the middle ("","g" etc) will be off....