Results 1 to 10 of 10

Thread: How to run "more" command using Qprocess ???

  1. #1
    Join Date
    Jun 2012
    Posts
    173
    Thanks
    48
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default How to run "more" command using Qprocess ???

    Hello guys,

    I am trying to run the "more" command in Linux using the Qprocess

    what i have been trying is :


    Qt Code:
    1. ......
    2. .......
    3. myProcess->setWorkingDirectory(ui->LE_workingdir->text().trimmed());
    4. myProcess->start("/bin/sh");
    5. myProcess->write("more filename\n\r");
    6.  
    7. // I have the slots to get all the reads from the process
    8. }
    To copy to clipboard, switch view to plain text mode 

    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
    Last edited by jesse_mark; 3rd October 2012 at 23:23.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to run "more" command using Qprocess ???

    What exactly would you expect to receive as a result of such command?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Jun 2012
    Posts
    173
    Thanks
    48
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to run "more" command using Qprocess ???

    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
    ....

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to run "more" command using Qprocess ???

    Quote Originally Posted by jesse_mark View Post
    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?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Jun 2012
    Posts
    173
    Thanks
    48
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to run "more" command using Qprocess ???

    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 ??

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to run "more" command using Qprocess ???

    Quote Originally Posted by jesse_mark View Post
    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.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  7. #7
    Join Date
    Jun 2012
    Posts
    173
    Thanks
    48
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to run "more" command using Qprocess ???

    Thanks but could you please tell me how can i launch a terminal using qprocess and execute "more" in it ??

  8. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to run "more" command using Qprocess ???

    Quote Originally Posted by jesse_mark View Post
    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.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  9. The following user says thank you to wysota for this useful post:

    jesse_mark (4th October 2012)

  10. #9
    Join Date
    Jun 2012
    Posts
    173
    Thanks
    48
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to run "more" command using Qprocess ???

    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

  11. #10
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to run "more" command using Qprocess ???

    Quote Originally Posted by jesse_mark View Post
    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.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  12. The following user says thank you to wysota for this useful post:

    jesse_mark (5th October 2012)

Similar Threads

  1. Replies: 7
    Last Post: 20th October 2012, 13:44
  2. Replies: 4
    Last Post: 15th July 2012, 02:41
  3. Replies: 2
    Last Post: 27th July 2011, 04:24
  4. Replies: 11
    Last Post: 26th July 2010, 05:01
  5. Translation QFileDialog standart buttons ("Open"/"Save"/"Cancel")
    By victor.yacovlev in forum Qt Programming
    Replies: 4
    Last Post: 24th January 2008, 19:05

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.