CODESYS - the IEC 61131-3 automation software

Welcome to the official CODESYS Forum by 3S-Smart Software Solutions GmbH | A member of the CODESYS Group
Deutsche Version English version russian version 
It is currently Thu Jun 20, 2019 4:04 pm

All times are UTC+01:00




Post new topic  Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Thu Aug 02, 2012 11:50 am 
Offline

Joined: Tue Oct 04, 2011 10:13 am
Posts: 80
Does CoDeSys return an errorlevel, when using --runscript?

I use (in a batch file):
Code:
"%CoDeSysPath%\CoDeSys.exe" --profile="CoDeSys V3.5 Patch 4" --noUI --runscript="script1.py"
echo %errorlevel%
The errorlevel is 0 always. Even when using sys.exit (4) in the script.

How can I get the return code from the script running in CoDeSys, into my batch file?


Top
   
PostPosted: Fri Aug 17, 2012 12:04 pm 
Offline
Frequent User
Frequent User
User avatar

Joined: Fri Mar 18, 2011 4:12 pm
Posts: 266
Hi, Edwin,

Edwin wrote:
Does CoDeSys return an errorlevel, when using --runscript?

I use (in a batch file):
Code:
"%CoDeSysPath%\CoDeSys.exe" --profile="CoDeSys V3.5 Patch 4" --noUI --runscript="script1.py"
echo %errorlevel%
The errorlevel is 0 always. Even when using sys.exit (4) in the script.

How can I get the return code from the script running in CoDeSys, into my batch file?


If you use system.exit(4), it should work.

The reason is that sys.exit() was redirected to just exit the script execution instead of the whole CoDeSys instance. By hindsight, the process is still terminated in --noUI mode, so there the exit code should be retained. I filed issue CDS-30366 in our tracker, so this will be fixed eventually.

_________________
Check out the CODESYS store: http://store.codesys.com/

CODESYS® a trademark of 3S-Smart Software Solutions GmbH
Inspiring Automation Solutions


Top
   
PostPosted: Mon Aug 20, 2012 9:12 am 
Offline

Joined: Tue Oct 04, 2011 10:13 am
Posts: 80
I replaced
Code:
sys.exit(4)

with
Code:
system.exit(4)

And it is working successful. The batch command retrieves the correct errorlevel.

Thank you for your help.


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 3 posts ] 

All times are UTC+01:00


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Limited