PDA

View Full Version : running linux command on remote machine using tcp/ip in Qt



sanjeet
6th April 2015, 14:26
Hi,

I have to build a gui based application in qt.
In which, I have to run/execute some linux-command(like "ls", "ps" etc) on remote machine(pc or other embedded device)
connected by ethernet or any communication media(gsm/gprs, wifi etc).
And after successful execution of these command i have to redirect output of these command to host pc so that i will
display it on my gui.
We have to use TCP/IP, and both host and remote system is linux-based.

I am able to send the command to remote system, but stucking there to run/execute that command.
for running command i am using "system" call. but not able to get it.

please anyone gudie me how to run command on remote system and redirect output to host system.

i am using QTcpSocket and QTcpServer classes, for communicating.
My first priority is on through ethernet.

anda_skoa
6th April 2015, 17:14
Assuming your remote program is using Qt (since you are posting into a Qt forum), use QProcess to run the command.

If you have program that require a controling terminal, then there's a library for that as an addon: http://inqlude.org/libraries/kpty.html

Cheers,
_

sanjeet
7th April 2015, 08:18
hi, anda_skoa

Thanks for your suggestion, i am able to do with QProcess.