Run an .EXE file on Windows from a PHP application on an external server

1

I have an SMS Gateway (Gammu) properly installed and running on my local machine at home.

I need my PHP script hosted on a server to run this application on my local SMS server. How should I proceed?

Do I need to apply some kind of permission on Windows for this? How do I pass the path for PHP to have access to this file .exe ?

    
asked by anonymous 14.05.2015 / 17:42

2 answers

1

PHP alone does not do this. The most you can do is run through the javascript:

<script>
function abrirArquivo() {
document.location.href = "C:/Program Files/caminho/arquivo.exe";
}
</script>

This will also open a dialog box asking if you want to run the file. For security reasons it is not possible to open automatically. At least I've never seen it before.

    
14.05.2015 / 17:57
1

I imagine you have a server in your house, where Gammu should be running.

Because Gammu is in your house, and your home probably uses a home internet link, you have a dynamic IP address in your home.

So, in the first place, you need to register a dynamic DNS pointing to your home. Use a service such as No-Ip or DynDNS. You will have to install a program on your home computer, preferably on the same computer as Gammu (since you probably will not turn it off).

Once this is done, you need to configure your router to perform port forwarding to your Gammu computer. See the documentation of the software that communicates with Gammu which are the network ports used. Note that this application acts as a server, receiving commands and passing them to Gammu to run. If you do not have it, you will need one. I do not know any, so I will not recommend it, but Google quotes a few. Otherwise, build yours.

There are classes that communicate PHP with Gammu, but PHP needs to run on the same computer as Gammu is. Therefore, one solution would be to also install a webserver on the Gammu computer. On your host server, you would send commands to the Gammu server, which in turn would send commands to Gammu.

Regardless of whether you use a communication code in PHP with Gammu or not, you will need an application on your home server to interface the Gammu and your remote webserver, as well as the dynamic router and IP settings.

    
14.05.2015 / 18:01