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 1500 numberwhun 3,509
Recognized Expert Moderator Specialist
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
KevinADC 4,059
Recognized Expert Specialist
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.
KevinADC 4,059
Recognized Expert Specialist
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.
KevinADC 4,059
Recognized Expert Specialist
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 )=split(/\|/,$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 )=split(/\|/,$account);
numberwhun 3,509
Recognized Expert Moderator Specialist
See, this is why I need to learn more CGI!!! Sorry about that!
Jeff
numberwhun 3,509
Recognized Expert Moderator Specialist
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
KevinADC 4,059
Recognized Expert Specialist
I'll make a CGI programmer of you if it kills me.... err.... wounds me.... errr.... causes me mild discomfort in me gulliver. ;)
numberwhun 3,509
Recognized Expert Moderator Specialist
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. ;-)
miller 1,089
Recognized Expert Top Contributor
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 controls, I get this error.
This is how it goes :
<code>
byte bImage1 = (byte)datasetImageList.Tables.Rows;
System.IO.MemoryStream ms = new MemoryStream(bImage1, 0, bImage1.Length);
this.lblRunImage.Image = System.Drawing.Image.FromStream(ms); //...
|
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 enable propagation
of inheritable permission on child folders.
4.- Read a file using Server.FileSystemObject into the web
|
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 String format, but it is.
Any suggestions would be greatly appreciated
'DATAGRID code:
|
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 fileDetails.PostedFile.ContentLength > 0
Then
Dim dir As String() =
fileDetails.PostedFile.FileName.Split("\".ToCharArray())
|
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, "C:\vb\WebBrowser\WebBrowserControl\TESTFILE.XML",
OpenMode.Output)
Write(1, "<?xml version=""1.0""?>")
The error on top occurs when creating the file. I can see that the
| |
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",
OpenMode.Output)
Write(1, "<?xml version=""1.0""?>")
....
|
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 line.
It also works when pulling the options from a file.
|
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 when i run it, it complain, and i don`t know why???
can anyone help me have a look at it?
here is the message it complain
|
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 use a string i read from the console
Exception in thread "main" java.net.SocketException: Connection r
at java.net.SocketInputStream.read(Unknown Source)
at sun.nio.cs.StreamDecoder.readBytes(Unknown Source)
at...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |