I have a SystemCaller that simply deletes a file. I would assume if the deletion is successful, it would give code 0, otherwise 1. However, it always gives 0 whether the deletion is successful or not (for example, I keep the file open before hand to cause the deletion to fail). Any workaround? I could use PythonCaller to do the deletion and generate an exit code, but would be nice just do this simple operation in the SystemCaller.
Which command are you using in the SystemCaller? If you're using "del", that command always return 0, which is what the SystemCaller will return as well.
See the documentation: https://ss64.com/nt/del.html
Errorlevels: DEL will return an Errorlevel of 0, irrespective if the delete succeeds or fails for any reason.Try PythonCaller using the follwing script:
import fme
import fmeobjects
import os
def killFile(feature):
try:
os.remove("e:\\data\\temp\\test.txt")
stat = 0
except WindowsError:
stat = 1
feature.setAttribute ('stat', stat)
pass
When called, after execution the feature would contain an attribute stat having value of 0 (succeed) or 1 (failed) depending if the delete operation deleted the file.
Which command are you using in the SystemCaller? If you're using "del", that command always return 0, which is what the SystemCaller will return as well.
See the documentation: https://ss64.com/nt/del.html
Errorlevels: DEL will return an Errorlevel of 0, irrespective if the delete succeeds or fails for any reason.
Try PythonCaller using the follwing script:
import fme
import fmeobjects
import os
def killFile(feature):
try:
os.remove("e:\\data\\temp\\test.txt")
stat = 0
except WindowsError:
stat = 1
feature.setAttribute ('stat', stat)
pass
When called, after execution the feature would contain an attribute stat having value of 0 (succeed) or 1 (failed) depending if the delete operation deleted the file.
Which command are you using in the SystemCaller? If you're using "del", that command always return 0, which is what the SystemCaller will return as well.
See the documentation: https://ss64.com/nt/del.html
Errorlevels: DEL will return an Errorlevel of 0, irrespective if the delete succeeds or fails for any reason.