Page 1 of 1

can anyone create this type of batch?

Posted: 07 Sep 2017 13:53
by raspberry109
can anyone create this type of batch?
I run this Simple-Script.bat:

Code: Select all

python my.py -w200
python my.py -w132
python my.py -w900
python my.py -w211


Each line runs well ---> python.exe process opens for each line(do his job) then closes automatically,but it seems that some lines cause problems,python.exe process opens but it never closes and i receive this error message:

Code: Select all

failure code 5
.Can someone make python.exe automatically when a line receives that error? then continue with the next (line) command?
thxx!

P.S.
or if someone knows the Python scripts can change directly from there

Re: can anyone create this type of batch?

Posted: 07 Sep 2017 14:10
by Squashman
raspberry109 wrote:Can someone make python.exe automatically when a line receives that error? then continue with the next (line) command?
thxx!

P.S.
or if someone knows the Python scripts can change directly from there

Remember what I said here.
viewtopic.php?f=3&t=8097#p53819

Re: can anyone create this type of batch?

Posted: 07 Sep 2017 14:20
by raspberry109
ok sorry then need help only for batch script, thank you

Re: can anyone create this type of batch?

Posted: 07 Sep 2017 15:35
by penpen
Does python expects you to type any text to proceed?
For example if the text were "TEXT", then you could try:

Code: Select all

echo TEXT| (python my.py -w200 & >nul findstr "^") 
echo TEXT| (python my.py -w132 & >nul findstr "^")
echo TEXT| (python my.py -w900 & >nul findstr "^")
echo TEXT| (python my.py -w211 & >nul findstr "^")

If python were expecting a simple return, then you could also try:

Code: Select all

<nul python my.py -w200
<nul python my.py -w132
<nul python my.py -w900
<nul python my.py -w211


penpen

Re: can anyone create this type of batch?

Posted: 08 Sep 2017 00:08
by raspberry109
doesn't work !!!

Re: can anyone create this type of batch?

Posted: 08 Sep 2017 04:02
by penpen
If the python script doesn't send the message directly to console, but uses stdout/stderr stream, then you might be able to do something like this (untested):

Code: Select all

cmd /c"(title uniqueName&python my.py -w200) | (set /p a=& (if defined taskkill /F /FI "WINDOWTITLE eq uniqueName"))"
Note: I'm not familiar with taskkill, so it might not work, or maybe impossible to solve in batch.
In the later case the python issue cannot be handled by batch.

Nevertheless:
As Squashman said, it is recommended to solve that issue from within python.


penpen

Re: can anyone create this type of batch?

Posted: 08 Sep 2017 07:23
by raspberry109
i tried but dones't work, same problem!

Re: can anyone create this type of batch?

Posted: 08 Sep 2017 08:49
by aGerman
If you have water in the fuel and the engine of your car stopped working - would you really try to develop an engine that works with water? I would go forward and blame the gas station that sold water instead of gasoline.
To be clear - you still try to solve that issue at the wrong end.

Steffen