LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Redirecting stderr to function/other stream

Hi

I hope someone can help me with this.
I'm using the perror() function to determine if an error has occurred in
getting access to a file. However the perror() function writes to the stderr
window and I would like to get the result so I can use this showing an appropiate
dialog popup

Is it possible to redirect to a function or whatever ?

Thanks in advance

Klaus
0 Kudos
Message 1 of 5
(3,336 Views)
Have you tried adding >file.out on your command line ?
I honestly don't think it'll work (maybe in CVI 5.5).

Why don't you simply read the value of the error variable and take action
accordingly ?
It's more simple and much better for the user.

> I hope someone can help me with this.
> I'm using the perror() function to determine if an error has occurred in
> getting access to a file. However the perror() function writes to the
stderr
> window and I would like to get the result so I can use this showing an
appropiate
> dialog popup
>
> Is it possible to redirect to a function or whatever ?
-----------
Guillaume Dargaud
CNR/IFA
http://sung3.ifsi.rm.cnr.it/~dargaud/
http://sung3.ifsi.rm.cnr.it/~domec/
http://www.appennini.it/roma8000/
http://sodarserver.ifa.rm.cnr.
it/
"A balanced diet is a cookie in each hand."
0 Kudos
Message 2 of 5
(3,336 Views)
Hi

The problem with the return error code is that I have to write code for all
the instances whereas the perror() function automatically returns a string
with the error that occurred.

Klaus

"Guillaume Dargaud" wrote:
>Have you tried adding >file.out on your command line ?>I honestly don't
think it'll work (maybe in CVI 5.5).>>Why don't you simply read the value
of the error variable and take action>accordingly ?>It's more simple and
much better for the user.>>> I hope someone can help me with this.>> I'm
using the perror() function to determine if an error has occurred in>> getting
access to a file. However the perror() function writes to the>stderr>> window
and I would like to get the result so I can use this showing an>appropiat
e>>
dialog popup>>>> Is it possible to redirect to a function or whatever ?>----------->Guillaume
Dargaud>CNR/IFA>http://sung3.ifsi.rm.cnr.it/~dargaud/>http://sung3.ifsi.rm.cnr.it/~domec/>http://www.appennini.it/roma8000/>http://sodarserver.ifa.rm.cnr.it/>"A
balanced diet is a cookie in each hand.">>
0 Kudos
Message 3 of 5
(3,336 Views)
Klaus,

You may find that you can obtain the information using the pipe out:

"action 2> filename"

This is a way to obtain the stderr output into a file using JAVA. Obviously
it depends if you are using a suitable compiler too. May be worth a try.

For more information on JAVA and C programming refer to Imperial College
Computing Dept web site, which contains a resource of knowledge!

www.doc.ic.ac.uk/lab/cplus/c.html

Good luck
0 Kudos
Message 4 of 5
(3,336 Views)
Try to close the handle of stderr ( close(2)) and then to open a new file.
The system will probably
give you the previous handle. After, you have to do the reverse.
this system is used with Unix,....
AB a écrit dans le message :
397415ca@newsgroups.ni.com...
>
> Klaus,
>
> You may find that you can obtain the information using the pipe out:
>
> "action 2> filename"
>
> This is a way to obtain the stderr output into a file using JAVA.
Obviously
> it depends if you are using a suitable compiler too. May be worth a try.
>
> For more information on JAVA and C programming refer to Imperial College
> Computing Dept web site, which contains a resource of knowledge!
>
> www.doc.ic.ac.uk/lab/cplus/c.html
>
> Good luck
0 Kudos
Message 5 of 5
(3,336 Views)