help Regarding progress bar

Hello,

I want to create a progress bar, which shows the progress of a copy
command.

So, how can I take the output of a copy command ?
Can anybody help in this regard ?

Thanks in Advance

Prabha

If “cp” thinks its stdout is connected to a tty, then “cp -V” produces
output about once per second, which your program can capture and parse. You
can run a program like cp in such an environment using forkpty(). Note that
this is a somewhat advanced topic; the Stevens books or equivalent sources
on the web regarding pseudo-ttys may be helpful.

dB

Prabha <prabha@myrealbox.com> wrote in message
news:b4uump$cac$1@tiger.openqnx.com

Hello,

I want to create a progress bar, which shows the progress of a copy
command.

So, how can I take the output of a copy command ?
Can anybody help in this regard ?

Thanks in Advance

Prabha



\

I would just re-implement the copy command in C. If you are not doing
anything tricky (like recursive directory copies or creating destination
directoies if they don’t exist) then it’s only about 5 lines of code.

Or grab the source for ‘cp’ and modify it to your requirements.

Personally I would find either of the above simpler than messing around with
forkpty().

Rob Rutherford

“David Bacon” <dbacon@qnx.com> wrote in message
news:b4vc11$ikp$1@nntp.qnx.com

If “cp” thinks its stdout is connected to a tty, then “cp -V” produces
output about once per second, which your program can capture and parse.
You
can run a program like cp in such an environment using forkpty(). Note
that
this is a somewhat advanced topic; the Stevens books or equivalent sources
on the web regarding pseudo-ttys may be helpful.

dB

Prabha <> prabha@myrealbox.com> > wrote in message
news:b4uump$cac$> 1@tiger.openqnx.com> …
Hello,

I want to create a progress bar, which shows the progress of a copy
command.

So, how can I take the output of a copy command ?
Can anybody help in this regard ?

Thanks in Advance

Prabha





\

Hello,
Thanks for the suggestions.
As I am doing Recursive copying, I think I have to go for forkpty().
I tried to divert the output of the cp -V to a text file, so that i can
use it in my app for capturing the status of copy. But when i do that, The
percentage of copy wont be displyed in the text file.
Could you pls give an idea of how can i implement forkpty() in my app.

Thanks you

Prabha

Robert Rutherford wrote:

I would just re-implement the copy command in C. If you are not doing
anything tricky (like recursive directory copies or creating destination
directoies if they don’t exist) then it’s only about 5 lines of code.

Or grab the source for ‘cp’ and modify it to your requirements.

Personally I would find either of the above simpler than messing around with
forkpty().

Rob Rutherford

“David Bacon” <> dbacon@qnx.com> > wrote in message
news:b4vc11$ikp$> 1@nntp.qnx.com> …
If “cp” thinks its stdout is connected to a tty, then “cp -V” produces
output about once per second, which your program can capture and parse.
You
can run a program like cp in such an environment using forkpty(). Note
that
this is a somewhat advanced topic; the Stevens books or equivalent sources
on the web regarding pseudo-ttys may be helpful.

dB

Prabha <> prabha@myrealbox.com> > wrote in message
news:b4uump$cac$> 1@tiger.openqnx.com> …
Hello,

I want to create a progress bar, which shows the progress of a copy
command.

So, how can I take the output of a copy command ?
Can anybody help in this regard ?

Thanks in Advance

Prabha





\