Perl form as a wrapper to a C program.

D

Dave

I have a C program (called dipole) that takes 3 command line arguments.
I want a user to be able to run the program with their choice of
arguments from a web page.

I wrote a simple form in perl that allows the user to enter the 3
required parameters. How can I pass them from perl to the C program,
using perl as a wrapper?

The form is at
http://www.southminster-branch-line.org.uk/cgi-bin/test3-cgi

and the source below of it below.

Is there a way I can call execute

'dipole frequency length diameter'

and return standard output of that C program to the browser?


I think I need to use 'open' rather than exec or system, but I can't get
any sense from anything. I am new to perl.

#!/usr/bin/perl
use CGI qw:)standard);


print header;
print start_html('Self Impedance of a dipole'),
h1('Self impedance of a simple dipole (not folded)'),
start_form,
"Frequency (MHz)? ",textfield('frequency'),
p,
"Length (m) ? ",textfield('length'),
p,
"Diameter (mm) ?",textfield('diameter'),
submit,
end_form,
hr;

if (param()) {
print
"Frequency is ",em(param('frequency')),
p,
"Length is ",em(param('length')),
p,
"Diameter is ",em(param('diameter')),
hr;
}
print end_html;
 
A

A. Sinan Unur

Dave said:
Is there a way I can call execute

'dipole frequency length diameter'

and return standard output of that C program to the browser?

I think I need to use 'open' rather than exec or system, but I can't
get any sense from anything. I am new to perl.

Have you actually read

perldoc -f system

Sinan
 
J

Joe Smith

Dave said:
I wrote a simple form in perl that allows the user to enter the 3
required parameters. How can I pass them from perl to the C program,
using perl as a wrapper?

Here's a hint (or two):

unix% perl -e '$_=`expr 2 + 3`; print "Answer=$_"'
Answer=5
unix% perl -e '$_=qx(expr 2 + 3); print "Answer=$_"'
Answer=5

-Joe
 

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

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top