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

M

mike

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
 
M

Mumia W.

[...]
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.
 
T

Tad McClellan

mike said:
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...)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top