asdfg
asdfg

Reputation: 2641

Why doesn't this batch file work for me?

The following batch file is not woking.

@echo off
python -c "print('echo text')" > %TEMP%\test.bat
call %TEMP%\test.bat
Can anyone help me with this?.
edit:
I needed unix eval functionality in windows. I could not find a direct way though. So I redirected the eval string to a temporary batch file and executed it. The temporary batch file was successfully created but calling it did not work in the above case. I noticed that any command after the test.bat creation did not work.

Upvotes: 1

Views: 241

Answers (1)

techie007
techie007

Reputation: 1006

If the "python" you are calling is a batch file (python.bat in the path perhaps?) then the launching batch file will abort after calling it, unless you use the Call command like you are doing for temp.bat.

So perhaps

@echo off
call python -c "print('echo text')" > %TEMP%\test.bat
call %TEMP%\test.bat
will give you better mileage?

Upvotes: 3

Related Questions