newbie - returned values from cscript.exe

R

Rich

I am writing my first python script and I'm guessing this is something
obvious but I can't find any examples of doing something like this. I
have a python script that is running a vbscript through cscript.exe.
The vbscript looks up a server name, username, password etc and returns
these values in a delimited list using wscript.echo. I can assign
these values to variables using a Windows batch files with the
following code

FOR /F "tokens=1-6" %%a in ('cscript /nologo GetServerAccessInfo.vbs"')
do (
SET DB_SERVER_NAME=%%a
SET DB_NAME=%%b
SET NMDBO_USERNAME=%%c
SET NMDBO_PASSWORD=%%d
SET SU_USERNAME=%%e
SET SU_PASSWORD=%%f

I can't figure out how to do the same thing using a python script to
call this instead of a batch file.

I am running the vbscript by using the following command
os.system('cscript /nologo GetServerAccessInfo.vbs')
 
J

Jerry

I would probably start with a look at popen. With it you can make your
call to cscript and capture the output. Then, you don't need to set
any environment variables.
 
D

Dennis Lee Bieber

I would probably start with a look at popen. With it you can make your
call to cscript and capture the output. Then, you don't need to set
any environment variables.

Heck, I'd probably start by looking at the VBS -- maybe everything
it does can be done directly IN Python.
--
Wulfraed Dennis Lee Bieber KD6MOG
(e-mail address removed) (e-mail address removed)
HTTP://wlfraed.home.netcom.com/
(Bestiaria Support Staff: (e-mail address removed))
HTTP://www.bestiaria.com/
 
I

ina

I did the same thing back before I knew about python and com.
I hope this example gets you on the right track.

It is just a simple script that does a dir and returns prints it out.

import os, sys
dCall = "dir"
resultFromCall = os.popen(dCall)
#get data back from the system call
mv = resultFromCall.read()
resultFromCall.close()
print mv
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,565
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top