Executing Exe or Bat File on Remote Windows Machine from *Nix

Executing exe or bat file on remote windows machine from *nix

I prefer to use cygwin and use SSH to then log in to the windows machine to execute commands. Be aware that, by default, cygwin doesn't have OpenSSH installed.

Once you have SSH working on the windows machine you can run a command on it from the Linux machine like this:

ssh user@windowsmachine 'mycommand.exe'

You can also set up ssh authentication keys so that you don't need to enter a password each time.

How to Run a batch file in a Remote machine Using ANT?

The standard way to do this is to use the sshexec task. Problem is this assumes you have SSH running on the server.

Your use of the word batch file suggests you're running Jboss/weblogic/tomcat on a windows machine? SSH is not a common service on that platform, you'll need to first install it.

Run batch scripts on a remote server (windows) from jenkins

If Jenkins on Windows, remote on *nix, use plink.exe (which is essentially command line PuTTy)

If Jenkins on Windows, remote on Window, use psexec.exe

If Jenkins on *nix, remote on *nix, use ssh

If Jenkins on *nix, remote on Windows, (update 2015-01) Ansible http://docs.ansible.com/intro_windows.html has support for calling Windows commands, eg powershell, from a unix/linux machine, https://github.com/ansible/ansible-examples/blob/master/windows/run-powershell.yml

Tell me what OSes are involved (both on Jenkins and remote), and I will flash this out further.

Edit:
The download page for psexec.exe lists all command line options. You will want something along the lines of:

psexec \\remotecomputername -u remoteusername -p remotepassword cmd /c <your commands here>
Replace <your commands here> with actual commands as you would execute them from command prompt.

Note that psexec first needs to install a service, and required elevated command prompt/admin remote credentials to do so.

Also, you need to run psexec -accepteula once to accept the EULA prompt.

Out of a git console: how do I execute a batch file and then return to git console?

After playing around a bit more, I found the solution myself:

cmd "/C clean.bat"

does the trick. But I got no clue, why...



Related Topics



Leave a reply



Submit