Results 1 to 2 of 2

Thread: using QProsses

  1. #1
    Join Date
    Jan 2006
    Posts
    9
    Thanks
    1
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default using QProsses

    Goodeven!

    BhowJas run command: df -h | sed '1d' | awk '{print $5"\t"$6"\t"$2}' ?


    Try
    Qt Code:
    1. pross->clearArguments();
    2. pross->addArgument("df");
    3. pross->addArgument("-h");
    4. pross->addArgument("|");
    5. pross->addArgument("sed");
    6. pross->addArgument("'1d'");
    7. pross->addArgument("|");
    8. pross->addArgument("awk");
    9. pross->addArgument("'{print $5\"\t\"$6\"\t\"$2}'");
    10. if(!pross->start()) std::cerr << "Error pross. start ;-(" << std::endl;
    To copy to clipboard, switch view to plain text mode 
    is failed.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: using QProsses

    Quote Originally Posted by Dmitry
    df -h | sed '1d' | awk '{print $5"\t"$6"\t"$2}'
    This command is only readable to a shell, while QProcess works like exec() function --- it starts some program with given arguments.

    Try:
    Qt Code:
    1. pross->clearArguments();
    2. pross->addArgument( "/bin/sh" );
    3. pross->addArgument( "-c" );
    4. pross->addArgument( "df -h | sed '1d' | awk '{print $5\"\\t\"$6\"\\t\"$2}'" );
    5. if( ! pross->start() ) {
    6. std::cerr << "Error pross. start ;-(" << std::endl;
    7. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by jacek; 31st May 2006 at 20:17.

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.