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

I have an rsync script that runs on one Linux server to synchronize files with another Linux server. Is there a way to launch a script on one of the Linux machines without actually opening an interactive ssh session to the server?

share|improve this question

4 Answers 4

up vote 4 down vote accepted

You should do it via a SSH command. You just need to setup plink.exe . You can download it at:
http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html

Then, from a batch file like this one, exectute it:

@ECHO off
:: run remote command
plink.exe username@myserver /cygwin/C/Users/username/do-backup.sh
ECHO Remote command finished...
PAUSE>nul
share|improve this answer

If you have a shell script, then consider Cywgin. It takes a while to install, but you get a full suite of common Linux tools running on Windows, so you won't have to change your script at all.

share|improve this answer
    
but I'm looking to make a batch file or something like that, that will login into my linux bux and run that script... so it is possible by using Cywgin? –  Kashif Apr 24 '12 at 20:30
    
Yes. Bash in Cygwin is nearly the same as bash under any *nix. –  Tim Apr 24 '12 at 20:31
    
Cygwin is quite complete, so you will also have all the other scripting languages available, Python, Ruby, Perl, etc. –  Tim Apr 24 '12 at 20:32

If you want to automate a task, you might consider plink. It actually uses ssh (or telnet or raw) to connect to another machine. But you can use it to connect and run a command in one line. Check putty documentation for more details:

http://www.chiark.greenend.org.uk/~sgtatham/putty/docs.html

share|improve this answer
    
actually I'm not looking to automate this command. I'm looking to make it manual but then it should automatically login to server and run script. Actually I need rsync on different times so i want to keep it under my control to get rsycn whenever i want without going to server. –  Kashif Apr 24 '12 at 20:39
    
Then you just need to put it the line in a batch script as djangofan wrote and run the script when needed. –  dmars Apr 24 '12 at 20:42

I understand that you have a pre-written script, but maybe you can get everything you need done with one of the many "rsync for cygwin repackages" like cwrsync and setting up a Windows scheduling job using cwrsync.

share|improve this answer

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.