Topic "WinScp as a Windows service"

Author Message
rimma

Guest


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!
Advertisements
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24512
Location: Prague, Czechia
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:

Code:
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?
rimma

Guest


Sure, you are right , twice Smile.
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!
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24512
Location: Prague, Czechia
What happens when you run winscp.com directly, instead of through .bat file?
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
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24512
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
khom0609
[View user's profile]

Joined: 2014-04-08
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?
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24512
Location: Prague, Czechia
I looks rather like a local problem, not with SFTP.
_________________
Martin Prikryl
Advertisements

You can post new topics in this forum






Search Site

What is WinSCP?

It is award-winning SFTP client, SCP client, FTPS client and FTP client integrated into one software program for file transfer to FTP server or secure SFTP server. [More]

And it's free!

Donate

About donations

$9   $19   $49   $99

About donations

Recommend

WinSCP Privacy Policy

WinSCP License