FTP script unable to connect when server locked?

Homerboy

Lifer
Mar 1, 2000
30,856
4,974
126
On a Win2008 server, I have some FTP scripts that automatically run via Windows Scheduler. They use WinSCP as the FTP client. The server locks the desktop after 15mins of inactivity. When the desktop is locked, and the scripts attempt to run, they can not connect to the remote FTP server:



. 2014-01-17 10:30:59.742 Looking up host "XXX.YYY"
. 2014-01-17 10:31:00.116 Connecting to XXX.XXX.XXX.XXX port 22
. 2014-01-17 10:31:21.317 Failed to connect to XXX.XXX.XXX.XXX: Network error: Connection timed out

It seems to resolve DNS, but just won't connect, and I can not figure out why. If I am logged into the desktop, and the script runs, it connects and does it's job flawlessly -- I just need it to do it when the desktop is locked out.

Anyone have any thoughts?

Thanks in advance!
 

seepy83

Platinum Member
Nov 12, 2003
2,132
3
71
Stange...I've got winscp scripts running through scheduled tasks on a 2k8R2 box, and haven't run into any problems like this. Since you're getting logs, the task must be running...so it's not related to the "run when this user is not logged in" setting. If you want to post a sanitized copy of the script you're using, I'll look it over. But as long as your scheduled task is running the correct copy of your script and is running under the appropriate credentials, it should definitely work.
 

Homerboy

Lifer
Mar 1, 2000
30,856
4,974
126
Code:
option batch on
option confirm off
open sftp://login:password@XXX.XXX.XXX.XXXX:22 -hostkey="ssh-rsa blaaaaaaaaaaaaaaaaaaah"
cd dropoff
lcd "\\XXXXXXX\temp\"
option transfer binary
put *.xml 
# Move the contents on remove folder
# mv *.xml ./backup/*
close
exit

simple as that.


Yes, the task IS running, it's just crapping out when trying to connect. Driving me nuts.
 

seepy83

Platinum Member
Nov 12, 2003
2,132
3
71
Going from memory now, I know that winscp has a few levels of logging. Have you turned your logging up to the highest level?

I would also consider pulling a packet capture while the job fails. Would be nice to know what, if anything, is happening on the wire.

A/V software getting in the way?

No idea if any of this is going to help or not. Those are just the next steps I would take.
 

jlee

Lifer
Sep 12, 2001
48,511
219
106
Anything in event viewer? Task set to run w/highest privileges?
 

Homerboy

Lifer
Mar 1, 2000
30,856
4,974
126
Anything in event viewer? Task set to run w/highest privileges?

Actually it wasn't.... I will give that a try before I go into more evasive troubleshooting.

What stinks is I have to wait until Friday -- stupid gov't FTP has no test folders/server.
 

seepy83

Platinum Member
Nov 12, 2003
2,132
3
71
"Highest Privileges" didn't appear to matter.
This is driving me nuts.

That is really strange. Maybe try something (kind of dumb) like delete the task and recreate it?

It just isn't adding up that it is giving you a network timeout error, but only when you aren't logged on. Is it possible that the server your trying to connect to is going down for maintenance every time your task is scheduled to run?

I just looked at one of our SCP scripts that connects to SFTP (vs. FTPS, FTP, etc), and it's basically line for line what you're doing. This scheduled task runs a bat file with 1 line in it to run:
Code:
"C:\program files (x86)\winscp\winscp.com" /script="PathToScript.cmd"

(not sure why it runs a bat instead of calling winscp.com directly...this one was set up by a colleague and it works so I don't touch it. The ones I have set up for FTPS I just call WinSCP.com directly, and use /ini, /log, and /script flags.)

Settings on the Scheduled Task are "Run whether user is logged on or not" and "Run with highest privileges".