Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
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
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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .