PDA

View Full Version : QProcess + Bash



bunjee
25th August 2009, 00:57
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.

profoX
25th August 2009, 01:36
What do you mean with "noticed when a command is processed" ?

caduel
25th August 2009, 08:47
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()

bunjee
25th August 2009, 09:16
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 ?

drhex
25th August 2009, 11:56
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.