Results 1 to 5 of 5

Thread: QProcess + Bash

  1. #1
    Join Date
    Jan 2007
    Location
    Paris
    Posts
    459
    Thanks
    98
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4 Qt5

    Default QProcess + Bash

    Hey there,

    I'm running bash shell in a QProcess.

    Is it possible to be noticed when a command is processed ?

    Like "cd myRep/" for example.

    Thanks.

  2. #2
    Join Date
    Mar 2008
    Posts
    27
    Thanks
    1
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QProcess + Bash

    What do you mean with "noticed when a command is processed" ?

  3. The following user says thank you to profoX for this useful post:

    bunjee (25th August 2009)

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

    Default Re: QProcess + Bash

    Note that stuff like a "cd" in a bash does not affect your program (the one calling bash in a QProcess) but only the process it was executed in. To change the current directory for your app, use QDir::cd(), QDir::setCurrent() etc

    You can not be notified about when "cd" has finished, but only when the process (here: bash) has finished, see QProcess::finished()

  5. The following user says thank you to caduel for this useful post:

    bunjee (25th August 2009)

  6. #4
    Join Date
    Jan 2007
    Location
    Paris
    Posts
    459
    Thanks
    98
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4 Qt5

    Default Re: QProcess + Bash

    Thanks both,

    So if you had to do a command queue like :

    - Run "cd myDir".
    - Wait for the command (or whatever it is) to be processed.
    - Run "cat myFile"
    - Wait for the command to be processed.
    - ...

    How would you implement that using bash ?

    How can I know the bash's current directory at any time ?

  7. #5
    Join Date
    Jan 2006
    Location
    Knivsta, Sweden
    Posts
    153
    Thanks
    30
    Thanked 13 Times in 12 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: QProcess + Bash

    You could have bash execute a script file containing several commands.

    Via QProcess, it is possible to read and write to the stdin & stdout of the process. If you have your bash run "pwd" it will prints its current directory to stdout.

Similar Threads

  1. QProcess Bash in Event Filter (Multiple Processes)
    By Arsenic in forum Qt Programming
    Replies: 1
    Last Post: 8th November 2008, 08:42
  2. Detect First QProcess finished in a group and kill other
    By Davidaino in forum Qt Programming
    Replies: 3
    Last Post: 11th July 2008, 12:53
  3. QProcess exitStatus()
    By user_mail07 in forum Qt Programming
    Replies: 2
    Last Post: 12th June 2008, 20:51
  4. QProcess and Pipes
    By KaptainKarl in forum Qt Programming
    Replies: 1
    Last Post: 9th April 2007, 23:11
  5. problem with qprocess
    By deekayt in forum Qt Programming
    Replies: 2
    Last Post: 13th June 2006, 13:30

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.