Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

cgi script
Hi,

I have a webpage index.html on which i call lu.cgi.
If i try to run this script i do not see the content of msg.txt on my web
page
My web server is apache

#!/usr/bin/perl -wT
open(INFO, "/usr/lib/cgi-bin/msg.txt"); # Open db for reading and display
@array=<INFO>;
close (INFO);
print "Content-type:text/html\n\n"; #Content Header
print <<End_of_head;
<html>
<head><title>Display File Contents</title></head>
<body>
<h4>This script displays the contents of names_file.txt.</h4>
End_of_head
foreach $line (@array){
($last,$first)=split(/\|/,$line);
print <<End_of_line;
$first $last<br>
End_of_line
}
print <<End_of_Doc;
</body>
</html>
End_of_Doc


ThX



Report this thread to moderator Post Follow-up to this message
Old Post
Jim roos
03-19-04 06:27 PM


Re: cgi script
It works for me, however I put my names in file "msg.txt", not
"names_file.txt" as the program suggests.
You may also want to spit out a message if the msg.txt file doesn't exist.

"Jim roos" <Jimroos@uunet.be> wrote in message
news:RxF5c.37299$eU4.2474071@phobos.telenet-ops.be...
> Hi,
>
> I have a webpage index.html on which i call lu.cgi.
> If i try to run this script i do not see the content of msg.txt on my web
> page
> My web server is apache
>
> #!/usr/bin/perl -wT
> open(INFO, "/usr/lib/cgi-bin/msg.txt"); # Open db for reading and display
> @array=<INFO>;
> close (INFO);
> print "Content-type:text/html\n\n"; #Content Header
> print <<End_of_head;
> <html>
> <head><title>Display File Contents</title></head>
> <body>
> <h4>This script displays the contents of names_file.txt.</h4>
> End_of_head
> foreach $line (@array){
> ($last,$first)=split(/\|/,$line);
> print <<End_of_line;
> $first $last<br>
> End_of_line
> }
> print <<End_of_Doc;
> </body>
> </html>
> End_of_Doc
>
>
> ThX
>
>



Report this thread to moderator Post Follow-up to this message
Old Post
RL
03-19-04 06:27 PM


Re: cgi script
"Jim roos" <Jimroos@uunet.be> wrote in message
news:RxF5c.37299$eU4.2474071@phobos.telenet-ops.be...
> Hi,
>
> I have a webpage index.html on which i call lu.cgi.
> If i try to run this script i do not see the content of msg.txt on my web
> page
> My web server is apache
>
> #!/usr/bin/perl -wT
> open(INFO, "/usr/lib/cgi-bin/msg.txt"); # Open db for reading and display

You should *always*, *always* check the success of the open

open INFO,"/usr/lib/cgi-bin/msg.txt" or die "Could not open msg.txt $!\n";

> @array=<INFO>;
> close (INFO);

Useless use of reading into an array.

This valuable advice is only going to cost you $US100 plus tax.  The invoice
is in the mail.



Report this thread to moderator Post Follow-up to this message
Old Post
Tintin
03-19-04 06:27 PM


Re: cgi script
In article <c38tbo$25d4h9$1@ID-172104.news.uni-berlin.de>, Tintin wrote:
>
>You should *always*, *always* check the success of the open

Hell, you should *always* check the success of *any* system call.  I check
the results of syswrite, for example.  You could successfully open a file
in O_RDWR or O_WRONLY modes, and still fail a write due to disk quota
limits or whatever else.

Error checking and fault tolerance is where a LOT of amateurs and hobbyists
fall short.

>open INFO,"/usr/lib/cgi-bin/msg.txt" or die "Could not open msg.txt $!\n";
> 
>
>Useless use of reading into an array.

Depends on what you're doing.  If one had a lot of time-intensive
processing in a foreach() or while() loop, or if one needed to store it for
later use, one might actually -want- to store it quickly first and process
it later.  It's not -always- useless.  In this case, I concur though, it
was patently useless.

>This valuable advice is only going to cost you $US100 plus tax.  The invoic
e
>is in the mail.

My valuable additions are only going to cost the OP $75 (USD).

--
Vorxion - Member of The Vortexa Elite

Report this thread to moderator Post Follow-up to this message
Old Post
Vorxion
03-19-04 06:27 PM


Re: cgi script
"Vorxion" <vorxion@knockingshopofthemind.com> wrote in message
news:405a1a1a$1_1@news.iglou.com...
> In article <c38tbo$25d4h9$1@ID-172104.news.uni-berlin.de>, Tintin wrote: 
>
> Depends on what you're doing.  If one had a lot of time-intensive
> processing in a foreach() or while() loop, or if one needed to store it
for
> later use, one might actually -want- to store it quickly first and process
> it later.  It's not -always- useless.  In this case, I concur though, it
> was patently useless.

Agree with you 100%.  I was specifically commenting on the OP's code.

> 
invoice 
>
> My valuable additions are only going to cost the OP $75 (USD).

Vorxion, the market will collapse if you are charging such cheap rates ;-)



Report this thread to moderator Post Follow-up to this message
Old Post
Tintin
03-19-04 06:27 PM


Re: cgi script
In article <c3ei0b$26m86k$1@ID-172104.news.uni-berlin.de>, Tintin wrote:
>
>Agree with you 100%.  I was specifically commenting on the OP's code.

*nod*  I knew -you- knew, I didn't know if -they- knew.  :)
 
>
>Vorxion, the market will collapse if you are charging such cheap rates ;-)

*chuckle*  At least it's not like the Indian or Russian programmers who
move the decimal point one place to the right.

Then again, I just had the dubious pleasure of seeing the results of some
of their work, and you get what you pay for.  Coding stylistic differences
aside, it looks like some of them are apparently maybe halfway through
"Learning Perl" (nevermind "Programming Perl").  I basically said, "You
don't want mods, you want a complete rewrite."

--
Vorxion - Member of The Vortexa Elite

Report this thread to moderator Post Follow-up to this message
Old Post
Vorxion
03-27-04 05:02 AM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

PERL CGI Freelance archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 05:53 AM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.