View Full Version : How to run "more" command using Qprocess ???
jesse_mark
3rd October 2012, 22:53
Hello guys,
I am trying to run the "more" command in Linux using the Qprocess
what i have been trying is :
......
.......
myProcess->setWorkingDirectory(ui->LE_workingdir->text().trimmed());
myProcess->start("/bin/sh");
myProcess->write("more filename\n\r");
// I have the slots to get all the reads from the process
}
but i am not getting any info, please any idea what is wrong i am doing here
Thank you so much for taking time to read this :)
I also tried
myProcess->start("/bin/sh", QStringList()<< "-c" << "more filename"));
and
myProcess->start("/bin/sh", QStringList()<< "-c" << "more" << "filename"));
but it didnot work too
wysota
3rd October 2012, 23:06
What exactly would you expect to receive as a result of such command?
jesse_mark
3rd October 2012, 23:46
its a log file i expect to receive numbers and when i run the commend in the terminal it works fine and i got the result it want
$ more filename
result i got list of numbers such as :
871
881
891
901
911
921
941
951
....
wysota
3rd October 2012, 23:51
its a log file i expect to receive numbers and when i run the commend in the terminal it works fine and i got the result it want
$ more filename
result i got list of numbers such as :
871
881
891
901
911
921
941
951
....
But with QProcess you don't have a terminal.
If you want to have the content of a file, why don't you just read it with QFile?
jesse_mark
3rd October 2012, 23:58
with this way is faster, to use the more command.
but with this way i can run the ifconfig command and get its out, so why can not i use the more command ??
so it is not possible to use the more command using qprocess ??
wysota
4th October 2012, 08:30
with this way is faster, to use the more command.
I don't understand what you mean.
but with this way i can run the ifconfig command and get its out, so why can not i use the more command ??
ifconfig doesn't require a terminal, more does.
so it is not possible to use the more command using qprocess ??
Certainly not the way you are trying to do it. Either launch a terminal and execute more there or if your app is launched from a terminal, find a way to attach to this terminal and launch more there.
jesse_mark
4th October 2012, 15:15
Thanks but could you please tell me how can i launch a terminal using qprocess and execute "more" in it ??
wysota
4th October 2012, 16:51
Thanks but could you please tell me how can i launch a terminal using qprocess and execute "more" in it ??
Most probably by making QProcess run "xterm -e more filename" or something similar.
jesse_mark
4th October 2012, 19:06
this command did open a terminal and run the command, but the Qprocess didn't read any output.
what i really want is to make the qprocess receive the out put of the command so i can display it where i want.
Thank you
wysota
4th October 2012, 19:52
this command did open a terminal and run the command, but the Qprocess didn't read any output.
Why would it read any output?
what i really want is to make the qprocess receive the out put of the command so i can display it where i want.
Then use QFile like I already told you.
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.