Momergil
Momergil

Reputation: 2281

How to start and stop an external program in another device using Qt?

I'm developing a firmware updater that should download data from a web server and upload it to an Embedded Linux device.

I want a program (client) to start another program (server) before establishing a connection between them and start sending the data. To do that in the same environment is easy: just call QProcess and startDetached(), but I want to do that remotely: I want to start the client in the Desktop machine and, with the device connected via ETH/TCP in a known IP address, click a button which will ask the device to start the server. When the server finishes starting and start waiting for connections, the Desktop app will then open the socket connection and start sending the data. After all data have being send, another command should be send to ask the server to shut down, closing the connection and finishing the file transfer operation.

My question is: how can I do this operation of asking for an application to either start or stop when it is located in a different machine (in an Embedded Linux device while the caller is in a PC)? Notice that the solution must be such that doesn't depend on some extra software (such as a Tcp server) to constantly run on the device - that's precisely what I'm trying to avoid.

Upvotes: 0

Views: 1090

Answers (1)

Vitor
Vitor

Reputation: 2792

This is not related to Qt in any way, because it doesn't provides anything for that purpose. There are at least two paths from this point:

  • use SSH from your application to start any process in the remote machine: ssh user@remote-machine "any command here". This can be called using QProcess; or
  • write another software to listen to socket commands and start/stop any process you want, then get it running all the time in the remote machine. Then, it's just a matter of changing your client software to send the relevant commands

Beware of any security issue that may arise by allowing the machine to execute arbitrary commands from external sources.

Upvotes: 1

Related Questions