Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > How to retrieve the Perl script returned value in C program? Many thanks

Reply
Thread Tools

How to retrieve the Perl script returned value in C program? Many thanks

 
 
mike
Guest
Posts: n/a
 
      04-24-2007
Hi Guys:

I have an Email application that was made of C(no source code). Only I
know is that it can call a program with a parameter(email file name)
and check the return value. If returns 0, go ahead and work with the
next one; return 1, drop it, and work with next one.

I intend to use Perl script to check the email's FROM field. Once it
comes from a specific domain, then return 1; otherwise, return 0.

Here comes the question: How can I return 0 or 1 from Perl script to
the C program? I made a C test program, and called the Perl script
this way:

int ret_val = system("perl_script email_file_name");

When I call exit(0) in the Perl script, the ret_val in the C test
program is 0; but when I call exit(1) in the Perl script, the ret_val
in the C test program is 256,

How come it happens this way? Any suggestion would be appreciated.

Mike

 
Reply With Quote
 
 
 
 
Mumia W.
Guest
Posts: n/a
 
      04-25-2007
On 04/24/2007 02:39 PM, mike wrote:
> [...]
> When I call exit(0) in the Perl script, the ret_val in the C test
> program is 0; but when I call exit(1) in the Perl script, the ret_val
> in the C test program is 256,
>
> How come it happens this way? Any suggestion would be appreciated.
>
> Mike
>


Shift the return value right by eight bits.

 
Reply With Quote
 
 
 
 
Tad McClellan
Guest
Posts: n/a
 
      04-25-2007
mike <(E-Mail Removed)> wrote:

> Subject: How to retrieve the Perl script returned value in C program? Many thank



The same way you would retrieve an exit value (not a return value)
from a program written in any other programming language.

That is, you have a C question, not a Perl question.

comp.lang.c is over thataway ==>




> Here comes the question: How can I return 0 or 1 from Perl script to
> the C program?



That is not the same question as in your Subject...

perldoc -f exit


> I made a C test program, and called the Perl script
> this way:
>
> int ret_val = system("perl_script email_file_name");
>
> When I call exit(0) in the Perl script,



It looks like you already know how to exit with a 0 or 1 from
your Perl program.


> the ret_val in the C test
> program is 0; but when I call exit(1) in the Perl script, the ret_val
> in the C test program is 256,
>
> How come it happens this way? Any suggestion would be appreciated.



I would suggest reading the documentation for the (C) system() function.

(it very likely behaves similarly to Perl's system() function,
so maybe you could get a clue from reading that description...)


--
Tad McClellan SGML consulting
http://www.velocityreviews.com/forums/(E-Mail Removed) Perl programming
Fort Worth, Texas
 
Reply With Quote
 
mike
Guest
Posts: n/a
 
      05-01-2007
Thanks a lot for all you guys suggestion.

 
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
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
Hi is there a simple way to turn the value returned byGetLastError() into a readable string thanks Jack Boot C Programming 1 12-22-2010 05:15 PM
The best way to retrieve a returned value... by const reference? Niels Dekker - no reply address C++ 19 06-04-2009 09:45 AM
how to retrieve CGI rss feed using asp.net but error The remote server returned an error: (503) Server Unavailable. rote ASP .Net 0 03-06-2008 11:26 PM
Perl Help - Windows Perl script accessing a Unix perl Script dpackwood Perl 3 09-30-2003 02:56 AM



Advertisments