Problem With Task Sceduler

Advertisement

Bubbo77
Joined:
Posts:
3

Problem With Task Sceduler

Good Morning,

I'm new to Winscp Scripting, and i've got a problem with the automation of mi scripting.
My environment is simple i install an SSH server with Freesshd, and now i start to use winscp for transfer file on 22 Port in this server. If i use a script that i run with a .bat file manually with a double click than all work perfectly.
But if i use the Windows task scheduler, nonthing happens, i think it's simple because i start a program : mytransfer.bat and i click "esecute", but nothing...also if i wait the time for the schedule...

My script is run with a simple batch (mytransfer.bat)

@echo off
cd "C:\Program Files (x86)\WinSCP"
winscp.com /script=Upload.txt
exit

that lunch this simple file "Upload.txt":

# Automatically abort script on errors
option batch abort
# Disable overwrite confirmations that conflict with the previous
option confirm off
# Connect
open sftp://user@xx.xx.xx.xxx/ -hostkey="ssh-rsa 2048 ##:##:##:ecc..."
# Force binary mode transfer
option transfer binary
# Upload the file to current working directory
put c:\Uploadfile\*.*
# Disconnect
close
# Exit WinSCP
exit

Thank a lot for the support

Reply with quote

Advertisement

Bubbo77
Joined:
Posts:
3

Re: Problem With Task Sceduler

Hi,

i tried to export the configuration winSCP.ini from Tools>export of the GUI.And the i tried to put winSCP.ini to the folder where is the executable Winscp.exe and i run the task scheduler from my Server Windows 2008 R2, but doesn't work, the same if i put the winSCP.ini to user profile Roaming folder. More over i add the folliwing command /ini to permit the batch to read where is the winSCP.ini file.
But nothing...
this is the Log that i receive:

! 2014-10-09 18:02:25.947 Using username "user".
. 2014-10-09 18:02:25.948 Prompt (7, SSH password, , &Password: )
. 2014-10-09 18:02:34.270 Sent password
. 2014-10-09 18:02:34.271 Password authentication failed
! 2014-10-09 18:02:34.271 Access denied
. 2014-10-09 18:02:34.271 Prompt (7, SSH password, , &Password: )
. 2014-10-09 18:02:35.948 Sent password
. 2014-10-09 18:02:35.949 Password authentication failed
! 2014-10-09 18:02:35.949 Access denied
. 2014-10-09 18:02:35.949 Prompt (7, SSH password, , &Password: )
. 2014-10-09 18:02:44.273 Disconnected: Unable to authenticate
. 2014-10-09 18:02:45.950 Disconnected: Unable to authenticate

i repeat that if i double click to the batch then works like a charm. :-(

and i receive this LOG

. 2014-10-09 18:05:39.096 Trying Pageant key #0
! 2014-10-09 18:05:39.096 Authenticating with public key "rsa-key-20141009" from agent
. 2014-10-09 18:05:39.173 Sending Pageant's response
. 2014-10-09 18:05:39.175 Access granted
. 2014-10-09 18:05:39.175 Opening session as main channel

I hope your going to help me!

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
29,053
Location:
Prague, Czechia

Re: Problem With Task Sceduler

You are authenticating with Pageant which is running in a different session than the scheduler. So WinSCP cannot communicate with Pageant.
You need to specify a private key explicitly in the script.

Reply with quote

Bubbo77
Joined:
Posts:
3

Re: Problem With Task Sceduler

martin wrote:

You are authenticating with Pageant which is running in a different session than the scheduler. So WinSCP cannot communicate with Pageant.
You need to specify a private key explicitly in the script.

Hi there!

it's correct if i change my script in this way ?

# Automatically abort script on errors
option batch abort
# Disable overwrite confirmations that conflict with the previous
option confirm off
# Connect
open sftp://user@xx.xx.xx.xxx/ -privatekey=mykey.ppk"
# Force binary mode transfer
option transfer binary
# Upload the file to current working directory
put c:\Uploadfile\*.*
# Disconnect
close
# Exit WinSCP
exit


Could you explain it to me in more detail?
I'm sorry but I'm not very handy with these concepts.

Thanks a lot!

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
29,053
Location:
Prague, Czechia

Re: Problem With Task Sceduler

Yes, that is correct, except for the unmatched double-quote.

Reply with quote

Advertisement

You can post new topics in this forum