can anyone create this type of batch?

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
raspberry109
Posts: 29
Joined: 07 Jun 2017 23:40

can anyone create this type of batch?

#1 Post by raspberry109 » 07 Sep 2017 13:53

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

Squashman
Expert
Posts: 4472
Joined: 23 Dec 2011 13:59

Re: can anyone create this type of batch?

#2 Post by Squashman » 07 Sep 2017 14:10

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

raspberry109
Posts: 29
Joined: 07 Jun 2017 23:40

Re: can anyone create this type of batch?

#3 Post by raspberry109 » 07 Sep 2017 14:20

ok sorry then need help only for batch script, thank you

penpen
Expert
Posts: 2005
Joined: 23 Jun 2013 06:15
Location: Germany

Re: can anyone create this type of batch?

#4 Post by penpen » 07 Sep 2017 15:35

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

raspberry109
Posts: 29
Joined: 07 Jun 2017 23:40

Re: can anyone create this type of batch?

#5 Post by raspberry109 » 08 Sep 2017 00:08

doesn't work !!!

penpen
Expert
Posts: 2005
Joined: 23 Jun 2013 06:15
Location: Germany

Re: can anyone create this type of batch?

#6 Post by penpen » 08 Sep 2017 04:02

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

raspberry109
Posts: 29
Joined: 07 Jun 2017 23:40

Re: can anyone create this type of batch?

#7 Post by raspberry109 » 08 Sep 2017 07:23

i tried but dones't work, same problem!

aGerman
Expert
Posts: 4654
Joined: 22 Jan 2010 18:01
Location: Germany

Re: can anyone create this type of batch?

#8 Post by aGerman » 08 Sep 2017 08:49

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

Post Reply