Python subprocess.call on sfxcl.exe not working fr

2019-08-12 09:08发布

问题:

I have written a script in Python to call SecureFX's commandline tool (sfxcl.exe)

result = subprocess.call([securefx, '/NoPrompt', '/Q', '/RetryCount', retries,
                 '/RetryDelay', '1', '/Log', sfxLogFile, '/List', '/S', session])

and then converted it into .exe using py2exe.

I can schedule it locally on my WinXP machine and everything works OK. When I run it manually on the Win2003 environment, it also works. BUT when I schedule it using Windows Task Scheduler in Win2003, it runs through the script and doesn't actually call sfxcl.exe (no logs whatsoever). I'm pretty stumped as to why this is...

The Win2003 server does not have Python installed, while my WinXP does (where I developed it).

I'm using Python 2.7.1.

EDIT: Or otherwise, if there is no answer to this - should I consider running the script once and set it to re-run using intervals and what not? Other options? It needs to run every 15-20minutes.

回答1:

So I've found the problem and it really is quite dumb. If it works manually, you should expect it to work in the Task Scheduler.

Now, I forgot to mention that it was using another account in the Scheduler, and that account didn't have SecureFX sessions/config set up and thus only that part didn't run.

It isn't a Python problem.