Newbie - pass variable to cscript

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Tue Mar 3 10:50:09 EST 2009


En Tue, 03 Mar 2009 13:22:20 -0200, <plsullivan1 at gmail.com> escribió:

> On Mar 3, 10:07 am, "Gabriel Genellina" <gagsl-... at yahoo.com.ar>
> wrote:
>> En Tue, 03 Mar 2009 12:19:22 -0200, <plsulliv... at gmail.com> escribió:
>>
>> > import os
>> > os.system('cscript.exe /from:wrk-... at zzz.gov /to:plsulli... at zzz.gov'
>> > "C:\\Program Files\\nasa\\nmail.vbs")
>>
>> > nmail.vbs works. I need to make it work from a python script. Thanks.
>>
>> ...and the problem is...?
>>
>> --
>> Gabriel Genellina
>
> It's not firing off the vbs script. Have I got the syntax correct?
> Thanks.
>
> My latest attempt:
> vBS = "C:\\Program Files\\nasa\\nmail.vbs"
> os.system('cscript /from:wrk-gis at pittcountync.gov /
> to:plsullivan at pittcountync.gov /sub:TEST /msg:hello ' + vBS)

Usually arguments come after the script name:

vBS = "C:\\Program Files\\nasa\\nmail.vbs"
os.system('cscript "%s" /from:wrk-gis at pittcountync.gov  
/to:plsullivan at pittcountync.gov /sub:TEST /msg:hello' % vBS)

But I'd use the subprocess module instead of os.system:

import subprocess
ret = subprocess.call(['cscript', vBS, '/from:...', '/to:...'])

See http://docs.python.org/library/subprocess.html

-- 
Gabriel Genellina




More information about the Python-list mailing list