Exit with error code from SPSS syntax -


i using batch file calls spss production job runs many syntax files.

in syntax files want able check variables, , if conditions not met want stop production job, exit spss , return error code batch file.

the batch file needs stop running next commands based on error code returned. know how in batch file already.

the basic solution if error code not 0 stop, , error text output separate text file within syntax. bonus different error code match in syntax code thrown.

what best way achieve in spss syntax , or production file?

one way execute statistics external mode python job. interrogate results, catch exceptions, , set exit codes , messages however, like. here example:

jobs.py:

python jobs

import sys
sys.path.append(r"""c:/spss23/python/lib/site-packages""")
import spss

try:
spss.submit("""insert file="c:/temp/syntax1.sps".""") except:
print "syntax1.spss failed" exit(code=1)

try:
spss.submit("""insert file="c:/temp/syntax2.sps".""")
except:
print "syntax1.spss failed"
exit(code=2)

then bat file do
python c:/myjobs/jobs.py
print %errorlevel%

or similar. job need save output in appropriate format using oms or shell redirection. (the blocks after try , except should indented.)


Comments

Popular posts from this blog

java - pagination of xlsx file to XSSFworkbook using apache POI -

Unlimited choices in BASH case statement -

apache - How do I stop my index.php being run twice for every user -