hi...
i am beginner in perl cgi programming..i am atempting to read from a file....
my cgi script is -
#!c:\perl\bin\perl -wT
-
#print "content-type: text/html \n\n";
-
use CGI qw(:standard);
-
use strict;
-
print header;
-
print start_html ("ebanking");
-
-
my $ne=param('name');
-
my $pwid=param('pwd');
-
-
open(FP,"input.txt") or die "cannot open file";
-
@raw_data=<DAT>;
-
close(DAT);
-
-
foreach $account (@raw_data) {
-
chop($account);
-
($w_name, $pswd, $accno, $address, $type, $balance) = split(/\|/,$account);
-
-
if (( $ne eq $w_name) and ( $pwid eq $pswd)) {
-
print " \nName: $w_name Balance: $balance" ;
-
} else {
-
print "\n User name and password not match";
-
}
-
}#fore each
-
-
print end_html;
-
when the above code is executed using WIN 32 apache it shows an internal error...this is the syntax given in every website....
if i remove the print statements corresponding to cgi and run in command line perl it works perfectly....
please help...
9 1492
To begin with, you do not need the shebang line (#!c:\perl\bin\perl -wT) in Windows perl scripting. It is completely ignored. To use taint mode, I believe when you trigger the script on the command line, you would simply specify "perl -T <scriptname>" to trigger it correctly.
Next, do not use the "-w" switch. It is better to use the "use warnings;" pragma instead of the switch.
As for the following code: -
print header;
-
print start_html ("ebanking");
-
print end_html;
-
You should really get into the practice of using either just quotes around the text you wish to print or the proper syntax as shown below for these lines. Also, if you have warnings turned on, then Perl will throw an error regarding the use of unquotted strings and their possible conflict with commands or future reserved words. -
print("header");
-
print ("start_html","ebanking");
-
print("end_html");
-
Now, try correcting those minor issues and if you could please provide the error that you are seeing, that would be great as well. We just want to see what it is kicking back at you.
Regards,
Jeff
Actually Jeff, these are functions of the CGI module (in bold):
print header;
print start_html ("ebanking");
print end_html;
so that is proper syntax. Putting quotes around print statements is actually not very proper:
print("header");
print ("start_html","ebanking");
print("end_html");
Just use quotes sans the parenthesis for simple prints. But as noted, the original code was correct so no parenthesis or quotes are needed in this case.
While it is true that Windows ignores the shebang line, apache does not. So using the -T switch should work if apache is being used even on Windows.
While it is true that Windows ignores the shebang line, apache does not. So using the -T switch should work if apache is being used even on Windows.
The problem appears to be the use of "strict" (a good thing) but there are a number of undeclared variables:
@raw_data=<DAT>;
foreach $account (@raw_data)
($w_name,$pswd,$accno,$address,$type,$balance)=spl it(/\|/,$account);
the above three lines need to be changed to:
my @raw_data=<DAT>;
foreach my $account (@raw_data) my ($w_name,$pswd,$accno,$address,$type,$balance)=spl it(/\|/,$account);
See, this is why I need to learn more CGI!!! Sorry about that!
Jeff
While it is true that Windows ignores the shebang line, apache does not. So using the -T switch should work if apache is being used even on Windows.
See, that I didn't know. I thought it was completely ignored and not use. I was unaware that Apache still read it. Must keep that bit if information in mind.
Regards,
Jeff
I'll make a CGI programmer of you if it kills me.... err.... wounds me.... errr.... causes me mild discomfort in me gulliver. ;)
I'll make a CGI programmer of you if it kills me.... err.... wounds me.... errr.... causes me mild discomfort in me gulliver. ;)
No worries, it'll only be a flesh wound. ;-)
i am beginner in perl cgi programming..i am atempting to read from a file....
my cgi script is -
open(FP,"input.txt") or die "cannot open file";
-
@raw_data=<DAT>;
-
close(DAT);
-
You're opening the file handle FP, but attempting to read from the handle DAT. Most likely this is a copy and paste error, but that's your most glaring problem.
- Miller
Sign in to post your reply or Sign up for a free account.
Similar topics
by: cnu |
last post by:
Hi
I have to write images(.gif/.bmp/.jpg/.ico), to db and read them. Uploading
images to db works fine for me. Reading from db to byte is also ok. But,
when I try to display them in my form...
|
by: Pedro Bautista |
last post by:
Status: Unsolved and puzzling
Steps to reproduce the error:
1.- Delete IUSER from server
2.- Reboot server (OS rebuilds IUSR)
3.- Assign IUSR read and execute permission on web folder
and...
|
by: Mo |
last post by:
Hi,
I'm getting an error:
Input string was not in a correct format
This happens when I try to sort a column. It seems that the sort event
handler claims that the sort expression is not in...
|
by: Nathan Sokalski |
last post by:
I am trying to write code to allow my users to upload a file. The code I am
using is as follows:
Dim upfilename As String = ""
If fileDetails.Value <> "" AndAlso...
|
by: reidarT |
last post by:
Ugyldig på toppnivået av dokumentet. Feil under behandling av ressursen
file:///C:/VB/WebBrowser/WebBrowserControl/TESTFILE...
"<?xml version=""1.0""?>","<XMLTest>"
^FileOpen(1,...
|
by: ReidarT |
last post by:
The former post was wrong, the lines where concatenated so here it goes
again.
I am wrriting to a file (XML-format) and using
FileOpen(1, "C:\vb\WebBrowser\WebBrowserControl\TESTFILE.XML",...
|
by: News |
last post by:
Hi Everyone,
The attached code creates client connections to websphere queue managers
and then processes an inquiry against them.
The program functions when it gets options from the command...
|
by: shrimpy |
last post by:
hi every one, i am new to python,
and coz i want to write a handy command for my linux machine, to find
a word in all the files which are under the current folder.
the code is half done, but...
|
by: diegoblin |
last post by:
hello, i have this issue.Every time i use sockets if i use a "String" as a parameter the connection resets. but if i put the ip address like this "127.0.0.1" it okay.
and i got this message if i...
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
| |