Communicating with xterm
This is my firs post in this forum and also I am new to Qt.
I am developing an application in which i need to run certain commands on a emulated terminal.
I am started to use "XTERM". I am able to open xterm but not able to send commands to it.
Can any one please help me in this regard.
@QString program = "xterm";
QProcess *proc = new QProcess;
i like to know weather is there any other terminal emulator to communicate efficiently.... ?
Thanks in advance
No, you can't communicate with xterm (send something to its standart input). But you can communicate that way with "/bin/sh", for example:
Q_FOREACH( QString cmd, QStringList() << "ls" << "date" << "echo test" )
proc.write((cmd + "\n").toLocal8Bit());
qDebug() << proc.readAllStandardOutput().split('\n');
or if you want you can run those program directly:
qDebug() << proc.readAllStandardOutput();
P.S.: examples from "stackoverflow":http://stackoverflow.com/questions/15050462/qprocess-call-write-function-failure, but i have tested it, it works. Hope this helps.
Hello Thanks for the post.
But my application need an emulated terminal to excute commands.
Thanks and regards,