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?
4 Answers
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
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.
-
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?– KashifApr 24, 2012 at 20:30
-
-
Cygwin is quite complete, so you will also have all the other scripting languages available, Python, Ruby, Perl, etc.– TimApr 24, 2012 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:
-
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.– KashifApr 24, 2012 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.– dmarsApr 24, 2012 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.