Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

The problem: I have a backup program (BackupAssist) that can run scripts automatically after a backup. I want to automatically shut down the computer that stores my offsite backups after the backup completes. I have the shutdown part working (with keys instead of passwords so it would work in a script), but I don't know how to send the Linux box a command without using an interactive shell like Cygwin.

I need to be able to send the command with no user interaction at all. A way to simply execute commands from Cygwin in scripts would be ideal, but any solution will do.

share|improve this question

3 Answers 3

up vote 2 down vote accepted

plink is an ssh client for Windows.

You can also use the ssh client from OpenSSH from Cygwin.

You will need to have sshd running and available on your Linux machine. If you want to run automated, you probably want to use passwordless ssh keys for this.

share|improve this answer

If you want to run SSH in Cygwin from a batch file you could try:

@echo off
C:\cygwin\bin\bash ssh user@host 'shutdown -h now'

Fair warning, I don't have a Windows box to test this on.

share|improve this answer

If you have access to ssh from Cygwin, then ssh user@host <command> will execute <command> in place of the login shell. Alternatively, you can use plink.exe from PuTTY in place of the Cygwin's ssh. (Thanks grawity)

You can also execute multiple commands, e.g.

ssh user@host "first_command ; second_command ; ..."

share|improve this answer
2  
PuTTY has an equivalent, plink. –  grawity Jun 13 '12 at 21:12
    
@grawity Ah! All I had been able to find was PuTTY's -m argument, which seemed kind of clumsy for this. –  Darth Android Jun 13 '12 at 21:17

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.