views:

386

answers:

2

Was wondering how you'd do the following in Windows:

From a c shell script (extension csh), I'm running a Python script within an 'eval' method so that the output from the script affects the shell environment. Looks like this:

eval `python -c "import sys; run_my_code_here(); "`

Was wondering how I would do something like the eval statement in Windows using Windows' built in CMD shell. I want to run a Python script within a Windows script and have the script run what the Python script prints out.

** update: specified interest in running from CMD shell.

+1  A: 

If it's in cmd.exe, using a temporary file is the only option [that I know of]:

python -c "print(\"Hi\")" > temp.cmd
call temp.cmd
del temp.cmd
grawity
+1  A: 
Jay Bazuzi