Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

We have a handful of machines that we administer: some Windows 2003/8 and some various flavors of Unix. I need to write some sort of script/task/etc (I'm a programmer, so any language/tool is fine) that will connect to these various machines and fetch some log file data that we've had our software create on the machine and ideally delete the old data on the machine.

In Unix, this is pretty easy to do as I can merely connect via telnet/ssh or even ftp and grab what I need. For our Windows machines, however, the only guaranteed connection method we have is remote desktop. Normally, I would connect via remote desktop with a local drive that is visible remotely and copy the file then delete it. I need to automate this process.

I Googled around a bit and didn't find as much as I would hope, including a similar and unanswered question on SO http://stackoverflow.com/questions/4406573/how-to-open-remote-desktop-copy-file-programmatically.

Anybody know of any libraries or tools (preferably free) that can do this? Thanks.

Phantom bonus points if you can help me deal with sites that I need to establish a VPN connection with before connecting.

share|improve this question
    
So, RDP is the only service available? All other ports may be filtered? Can a drive be mounted via a 'Net.exe use' command? –  RobW Nov 8 '11 at 21:37
    
That only works when I'm on the same network right? These are arbitrary machines somewhere out there on the internet. –  Morinar Nov 8 '11 at 21:42
    
The only way you can be semi-sure that you'll get this log data is to have the application phone home (be sure to tell your customers you are adding this feature) and have it upload the logs either automatically or on demand. –  mrdenny Nov 8 '11 at 22:00
    
Phoning home was definitely my initial inclination, however, we have some semi-unique connection methods that make that not ideal. Additionally, I think it would be really hard to get customers to be happy about a phone home feature, especially due to how sensitive the data usually is. –  Morinar Nov 8 '11 at 22:04
    
If connections are difficult and if customers are sensitive about apps phoning home, won't they be touchy about letting someone in from the outside? At least for phoning home, they're already paying you, presumably they trust your software... –  Ward Nov 9 '11 at 6:44

4 Answers 4

Can you utilize push, rather than pull?

Should be easy to write a script to gather local event logs, then ftp (or curl or whatever else sounds good) the file to wherever you need it to be.

You would then need to make a scheduled task or service out of this script.

share|improve this answer
    
If the machines are not on your network, you might consider using this idea, with blat.exe or some other sendmail type utility. –  RobW Nov 9 '11 at 16:13

Have you considered something like DropBox? If there are different flavors of OS, and they have internet access you could have scripts copy the log files to the single DrobBox account folder, which will synch with the cloud.

share|improve this answer

How about you create a script using AutoIt or AutoHotkey and use MSTSC?. I suggest that if you approach it from this direction, you configure your RDP session to be 800x600, so that everything is predictably in the same place?

share|improve this answer
    
Seems like that could work, but I'd essentially need a machine that I would have to dedicate to nothing but gathering the data since I wouldn't be able to do anything else on it while the GUI scripts were running. It also makes a lot of assumptions about all of these servers being configured/setup in the exact same way. –  Morinar Nov 8 '11 at 22:22
2  
@Morinar: If you need to use a dedicated machine to implement RobW's suggestion you could run a VM in something like VMware Player (free) or VirtualBox (also free) which would essentially run as an application on your workstation. Neither one would require a lot of resources from the host by the sound of what they need to do. –  joeqwerty Nov 9 '11 at 2:48
    
That's a great idea using virtualization to do it. Not sure I would have thought of that. –  Morinar Nov 9 '11 at 16:14

one consideration might be programatically dialing a VPN into these networks if it's a possibility and the client will allow it.

and provided the default admin shares are enabled for logical drives on these machines you would be able to just use a UNC path to connect

\\server.domain.com\C$\folderwithstuff\folderwithmorestuff\

then just copy out what you need

Run.("XCOPY "\server.domain.com\C$\folder*.*", "\yourserver.domain.com\c$\folder")

share|improve this answer
    
it also just occurred, if you're not looking to reinvent the wheel for each client server, you could create a VPN and a file repository on your end wherever the files need to end up, then just create schedule tasks on the client machines to dial your VPN, copy the files, then disconnect –  Matt Hamende Apr 29 '12 at 17:57

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.