Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Take over STDOUT / STDERR for Perl embedded in C application

Reply
Thread Tools

Take over STDOUT / STDERR for Perl embedded in C application

 
 
William
Guest
Posts: n/a
 
      10-05-2005
Hello,

I am trying to embed Perl in a C++ application. I have a window that
takes input, when user hits return, the input is sent to Perl for
evaluation. I then want to display the input back to the user in the
window and display it differently for error versus normal output.

I've searched the web, but can't seem to find a clear example of how to
do this in C.

Presently, after calling result = perl_eval_pv() to eval the user
input, I do SvPV(result, PL_sa) and the result goes to my window. The
result is a code indicating success etc.

However, this leaves stdout and stderr still going to the shell where
my app was launched.

I would like a pointer to an example of this kind of thing being done
so I can emmulate it.

I've found many places where this question is asked but no clear
answer.

Thanks.

-William

 
Reply With Quote
 
 
 
 
Chris Johnson
Guest
Posts: n/a
 
      10-05-2005
William wrote:
> Hello,
>
> I am trying to embed Perl in a C++ application. I have a window that
> takes input, when user hits return, the input is sent to Perl for
> evaluation. I then want to display the input back to the user in the
> window and display it differently for error versus normal output.
>
> I've searched the web, but can't seem to find a clear example of how to
> do this in C.
>
> Presently, after calling result = perl_eval_pv() to eval the user
> input, I do SvPV(result, PL_sa) and the result goes to my window. The
> result is a code indicating success etc.
>
> However, this leaves stdout and stderr still going to the shell where
> my app was launched.
>
> I would like a pointer to an example of this kind of thing being done
> so I can emmulate it.
>
> I've found many places where this question is asked but no clear
> answer.
>
> Thanks.
>
> -William


This is more a question about C++ than Perl, so you're a bit offtopic.
Try a C++ or C newsgroup.

Now, if you wanted, I expect you could probably run the C program from
Perl, and for that, the IPC::Open3 module would be useful. (I haven't
been able to find a C/C++ equivalent. I suspect it may involve multiple
threads.)

If you've still got your heart set on running the perl from the C, I
suppose you could open a couple FIFOs.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
VOIP over VPN over TCP over WAP over 3G Theo Markettos UK VOIP 2 02-14-2008 03:27 PM
Reading stdout and stderr separately ladygrinningsoul Perl 3 04-25-2005 04:25 PM
redirecting stderr and stdout Jon Landenburer Perl 1 05-13-2004 07:38 AM
How to redirect stdout&stderr into files in Tomcat 4.1.29 on RedHat 9 ? Java 3 01-11-2004 10:30 PM
redirect stdout & stderr tomcat 4.1 VisionSet Java 6 09-20-2003 01:37 AM



Advertisments