codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  perl remote execution  jasper at 10:35 on Friday, October 26, 2007
 

Hello,
I am developing a cgi-perl script that takes some value from a html form as input and stores them in a data file. I have a program called "irr" in my server, it is executed just by typing irr at the shell prompt. Upon execution the program first displays a line describing the types of input required and waits for the input in the next line.I intend to pass the inputs from the values stored in the data file by the script. The following is the code that i came up with:


#!/usr/bin/perl -w
use warnings;
use CGI qw(:all);
use CGI::Carp qw(fatalsToBrowser);
use Fcntl qw(:flock);
use strict;

my $dataFile="/forum/data.txt";
print header(-type=>'text/html');
print start_html("Internal Rate of Return Calculator");

my $value = `date`;
print $value,"<br\>";

my $irr;
if(!param)
{
form();
print end_html();
}
else
{
store();
result();
print end_html();

}

#-----------------------------------
sub form(){
print << "HERE";
<form id="form" action="" method="POST"/>
<h1> Welcome to IRR Calculator </h1>
<p>Net-Present-Value: <input name="value" type="text"/></p>
<p>Amortization-In-Years: <input name="years" type="text"/></p>
<p>Monthly-Cashflow: <input name="monthly" type = "text"/></p>
<p><input name="submit" type="submit" value="submit"/></p>
</form>
HERE
}

#------------------------------------
sub store(){
my $value = param('value');
my $years = param('years');
my $monthly = param('monthly');
open (DH, ">$dataFile") || die "Coudn't open the data file: $!";
print DH $value, " ", $years, " ", $monthly;
close(DH);

}

#-------------------------------------
sub result(){
my $irr = `irr<data.txt`;
print $irr;
}

----------------------------------------------------------------
Unfortunately the result is never displayed on the browser. I have tried using the command : `irr<data.txt | cat` but that doesn't work either. Where am I doing wrong? A little help would be greatly appreciated. Thank you.










CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums
//








Recent Forum Threads
•  onChange issue
•  Remote program execution using cgi-perl
•  Chat application
•  How to send multiple perameters in SOAP request.
•  Java code for Insert picture on the table in spreadsheet
•  Re: Problem with concatenation
•  how to genrates the crystal report by sending a id at runtime
•  help me
•  pls help me with this..


Recent Articles
ASP GetTempName
Decode and Encode UTF-8
ASP GetFile
ASP FolderExists
ASP FileExists
ASP OpenTextFile
ASP FilesystemObject
ASP CreateFolder
ASP CreateTextFile
Javascript Get Selected Text


© Copyright codetoad.com 2001-2007