Results 1 to 2 of 2

Thread: How to input argument at the middle of running process using QProcess

  1. #1
    Join Date
    Aug 2007
    Location
    Gorakhpur, India
    Posts
    254
    Thanks
    8
    Thanked 14 Times in 14 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Question How to input argument at the middle of running process using QProcess

    I want to read local system's particular unread mail using mail command. Suppose
    I want to read mail no. 5 using mail command. The Syntax is

    mail
    Mail version 8.1 6/6/93. Type ? for help.
    "/var/spool/mail/root": 12 messages 12 unread
    >U 1 MAILER-DAEMON@localh Fri May 15 15:53 73/2415 "Returned mail: see tr"
    U 2 root@localhost.local Fri May 15 15:54 19/747 "psad-alert"
    U 3 root@localhost.local Fri May 15 16:00 21/721 "psad-alert"
    U 4 root@localhost.local Fri May 15 17:40 18/682 "psad-alert"
    U 5 MAILER-DAEMON@localh Mon May 18 09:16 68/2333 "Warning: could not se"
    U 6 MAILER-DAEMON@localh Mon May 18 09:16 70/2341 "Warning: could not se"
    U 7 MAILER-DAEMON@localh Mon May 18 09:16 69/2350 "Warning: could not se"
    U 8 MAILER-DAEMON@localh Mon May 18 09:16 69/2389 "Warning: could not se"
    U 9 MAILER-DAEMON@localh Mon May 18 09:16 68/2381 "Warning: could not se"
    U 10 MAILER-DAEMON@localh Mon May 18 09:16 67/2431 "Warning: could not se"
    U 11 MAILER-DAEMON@localh Mon May 18 09:16 66/2322 "Warning: could not se"
    U 12 MAILER-DAEMON@localh Mon May 18 09:16 68/2338 "Warning: could not se"
    &
    then enter 5 for reading 5th mail.

    My problem begins here to read this mail via QProcess. How to pass 5 no after issuing the mail command when mail list with no. displays...
    Qt Code:
    1. procMsg =new QProcess(this);
    2. QStringList arguments;
    3.  
    4. arguments << "\n" << msgKey << "\n";
    5.  
    6. procMsg->start("mail");
    7. QByteArray result=procMsg->readAllStandardOutput ();
    8.  
    9. QTextStream stream(&result);
    10. while (!stream.atEnd())
    11. {
    12. line += stream.readLine();
    13. }
    To copy to clipboard, switch view to plain text mode 
    U 12 MAILER-DAEMON@localh Mon May 18 09:16 68/2338 "Warning: could not se"
    & 5
    Message 5:
    From MAILER-DAEMON@localhost.localdomain Mon May 18 09:16:20 2009
    Date: Mon, 18 May 2009 09:16:20 +0530
    From: Mail Delivery Subsystem <MAILER-DAEMON@localhost.localdomain>
    To: root@localhost.localdomain
    MIME-Version: 1.0
    Content-Type: multipart/report; report-type=delivery-status;
    boundary="n4I3kFwx002482.1242618380/localhost.localdomain"
    Subject: Warning: could not send message for past 4 hours
    Auto-Submitted: auto-generated (warning-timeout)

    This is a MIME-encapsulated message

    --n4I3kFwx002482.1242618380/localhost.localdomain

    **********************************************
    ** THIS IS A WARNING MESSAGE ONLY **
    ** YOU DO NOT NEED TO RESEND YOUR MESSAGE **
    **********************************************

    The original message was received at Fri, 15 May 2009 15:43:18 +0530
    from root@localhost
    for showing the content of conventional mail system under LINUX.
    Anurag Shukla
    A man who never makes mistake is the man who never does anything! Theodre Rosvelt!

  2. #2
    Join Date
    Dec 2006
    Posts
    849
    Thanks
    6
    Thanked 163 Times in 151 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: How to input argument at the middle of running process using QProcess

    QProcess inherits from QIODevice which you can use to write data to your process' stdin.

    HTH

Similar Threads

  1. How to detect a QProcess is started
    By cooler123 in forum Qt Programming
    Replies: 9
    Last Post: 26th June 2008, 10:45
  2. Connecting with QProcess to an already running process
    By high_flyer in forum Qt Programming
    Replies: 7
    Last Post: 26th November 2007, 10:31
  3. QProcess / system call not working under linux. Why?
    By johnny_sparx in forum Qt Programming
    Replies: 12
    Last Post: 11th March 2006, 00:32

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.