Executing an exe or bat file on a remote Windows computer from * nix

I am trying to execute a bat file on a remote Windows machine on the cloud from my Linux. Bat files run the selenium server, and then my selenium tests are run. I can not run selenium RC server on this machine. I tried using telnet, but the problem is with closing the telnet session. The RC server port is also closed. As the code for my code, I need to start the server, so I tried to execute the ANT telnet task, and also run the telnet script shell in both cases when the port was closed.

I read about Open SSH, psexec for linux and cygwin. But I don’t understand how to use them, and they will solve my problem.

I tried to start a service that starts the server, but in this method I do not get browser visibility, all tests are performed in the background, since my script takes the browser browser visibility of the screen.

Now my question is what to use and which will be preferable for my work. and what ever i choose should be executed by code, it can be a shell, ANT or php.

Thanks in advance.

+7
source share
3 answers

I prefer to use cygwin and use SSH to log in to Windows to execute commands. Keep in mind that by default cygwin does not have OpenSSH installed.

Once you have SSH on the Windows machine, you can run the command on it from the Linux machine as follows:

ssh user@windowsmachine 'mycommand.exe' 

You can also configure ssh authentication so that you do not need to enter a password each time.

+7
source

Skip the various options you mentioned:

  • psexec . This is basically a PC. In addition, you must ensure that new Windows computers can go through the UAC, which are configured by default. UAC is what you constantly see in Vista and Windows 7 when you try to do something that requires administrator rights. You can try something called winexe , which is a Linux program that can execute the psexec protocol, but I had problems working with it.
  • OpenSSH There are two main aspects of SSH, and Open SSH is the one that is used by the vast majority of sites. SSH has several advantages over other methods:
    • SSH is secure: your network traffic is encrypted.
    • SSH can be password independent: you can configure SSH to use private / public keys. Thus, you do not even need to know the password on the remote server. This makes it more secure since you do not have passwords stored on different systems. And, in many Windows sites, passwords must change every month or so, or the account is locked.
    • SSH can do more than just execute remote commands. SSH has two sub-protocols called SCP and SFTP. They allow you to transfer files between two machines. Since they work on SSH, you get all the benefits of SSH, including encrypted packets and public / private key protection.
    • SSH is well implemented in Unix World: you will find SSH clients built into Ant , Maven, and other build tools. Programs such as CVS, Subversion, and Git can also work with SSH connections. Unfortunately, Windows World runs in a different space. Using SSH on a Windows system requires third-party software such as Cygwin.
  • Cygwin : Cygwin is a kind of weird beast. This is a layer on top of Windows that allows many Unix / GNU libraries to work on Windows. It was originally designed to allow Unix developers to run their software on Windows DOS systems . However, Cygwin now contains a complete Unix system, including tools such as Perl and Python, the BASH shell, and many utilities such as the SSH server. Since Cygwin is open source, you can download it for free and run the SSH server. Unfortunately, I had problems with the Cygwin SSH server. Another problem: if you use programs remotely, you probably want to run them in a Windows environment, not in a Cygwin environment.

I recommend you take a look at WinSSHD from Bitvise. This is an implementation of the OpenSSH SSSS server, but not open source. This is about $ 100 per license, and you need a license on each server. However, it is a reliable implementation and has all the features that SSH can offer.

You can see CoSSH , which is a package of Cygwin utilities and an OpenSSH server. It's free and all open source, but if you need an easy way to set it up, you have to pay for the Advanced Administrator Console . You do not need the Advanced Administrator console, since you can use Cygwin to configure everything, and it includes the base console.

+15
source

Not a very safe way, but if you have a working web server, you can use PHP or ASP to run the system command. Just hide the thgat script at www.myserver.com/02124309c9867a7616972f52a55db1b4.php or something like that. And make sure that the command is fixed in the code, and not open through the parameter ...

-3
source

All Articles