WinScp as a Windows service

Advertisement

rimma
Guest

WinScp as a Windows service

Hello,
I have a small script:

option batch abort
option confirm off
open sftp://user@esm
get -delete /opt/cccc/*.txt c:\bbb\*.txt
exit

And a batch file:
WinScp.com /ini=c:/ddd/winscp.ini /log=c:/ddd/winscp.log
WinScp.com /script=fff/txt

When I run it from console or double click on the batch, it works well. But I need to run it as a service (each 10 secs), so I can't use Scheduler (minimum is 1 min)

I wrote a small program on Python that runs this batch, just run it. Anything works there, except for this batch!
Also, when I check the output of running this batch, it returns 3221225794 error status code, that actually means "access denied". But I put ini file, instead of using registry.

Can anyone help me?
Thank you in advace!

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
28,542
Location:
Prague, Czechia

Re: WinScp as a Windows service

rimma wrote:

WinScp.com /ini=c:/ddd/winscp.ini /log=c:/ddd/winscp.log
WinScp.com /script=fff/txt
This does not make sense.

The first line would hang the batch, waiting for input.
You should do:

winscp.com /script=fff/txt /ini=c:/ddd/winscp.ini /log=c:/ddd/winscp.log
(btw, shouldn't it be fff.txt?)

Anyway, please post an output of the batch (when ran from Python).

Or what about running a batch from Scheduler every minute that loops 6 times?

Reply with quote

rimma
Guest

Sure, you are right , twice :).
1) It should be fff.txt.
2) Now it makes sense, but there is the same error.
3) In the Scheduler - I should wait for 10 seconds, for example... interesting idea, thanks!
4) Anyway, in Python, when I can run subprocess.call([...bat]) it just does nothing.
When I run retVal = subprocess.check_output([...bat]) I get the error I put to you.
I write on one computer, but run in on another (with connection to linux vm)


Here is the output in Event Viewer, after I start the service in Services:

The instance's SvcRun() method failed
Traceback (most recent call last):
File "C:\Python33\lib\site-packages\win32\lib\win32serviceutil.py", line 835, in SvcRun
self.SvcDoRun()
File "C:\Rimma\AS\AS4Bpm.py", line 58, in SvcDoRun
retval = subprocess.check_output(['C:/Rimma/AS/winscp_srv.bat'])
File "C:\Python33\lib\subprocess.py", line 589, in check_output
raise CalledProcessError(retcode, process.args, output=output)
subprocess.CalledProcessError: Command '['C:/Rimma/AS/winscp_srv.bat']' returned non-zero exit status 3221225794
%2: %3


Thank you in advance!

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
28,542
Location:
Prague, Czechia

What happens when you run winscp.com directly, instead of through .bat file?

Reply with quote

rimma
Guest

Thank you reply. Here is the description of the error in Event Logger:

The instance's SvcRun() method failed
Traceback (most recent call last):
File "C:\Python33\lib\site-packages\win32\lib\win32serviceutil.py", line 835, in SvcRun
self.SvcDoRun()
File "C:\Rimma\ArcSight\ArcSight4Bpm.py", line 59, in SvcDoRun
retval = subprocess.check_output(['"C:\Program Files (x86)\WinSCPWinSCP.com" /script="C:\Rimma\ArcSight\winscp_script.txt"'])
File "C:\Python33\lib\subprocess.py", line 576, in check_output
with Popen(*popenargs, stdout=PIPE, **kwargs) as process:
File "C:\Python33\lib\subprocess.py", line 824, in __init__
restore_signals, start_new_session)
File "C:\Python33\lib\subprocess.py", line 1118, in _execute_child
raise WindowsError(*e.args)
PermissionError: [WinError 5] Access is denied
%2: %3

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
28,542
Location:
Prague, Czechia

OK, I'm not sure how to help you and it definitely does not seem to be related to WinSCP itself.
_________________
Martin Prikryl

Reply with quote

khom0609
Joined:
Posts:
1

Can it be something with sftp? Because it's sftp in the script file.
I thought maybe when it runs as a service in another user with ini file, maybe there is any problem with getting to some files through sftp...
What do you think?

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
28,542
Location:
Prague, Czechia

I looks rather like a local problem, not with SFTP.
_________________
Martin Prikryl

Reply with quote

Advertisement

You can post new topics in this forum