Re: Why Premature end of script headers?

2002-07-15 Thread Lisa Nyman

Hi,

On Mon, 15 Jul 2002, Octavian Rasnita wrote:

 I've made a little script that takes the lines from a file, removes the
 dupplicate lines and prints the result to a new file.
 The problem is that after printing almost 10% from the original file into
 the new file, the script dies and the only error I get in the log file is:
 [Mon Jul 15 14:44:48 2002] [error] [client 127.0.0.1] Premature end of
 script headers: clean.pl

 #!/perl/bin/perl -w

 print Content-type: text/html\n\n;

I'm not sure why you are doing this.  You never output anything to
the web page aside  from the header.  Did you want this to be a web
application?  If so, you know the web server needs the correct
permissions to manipulate the files.  You would catch permission problems
if you check the error return $! from your open statements.  That's
always a wise thing to do.

As for editing files, take a look at Tie::File.

-lisa


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Matt Wright's formMail

2002-05-13 Thread Lisa Nyman

Hi,

Not Matt's Scripts

http://nms-cgi.sourceforge.net/scripts.shtml

-lisa


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Headers

2002-03-06 Thread Lisa Nyman

Hi,

On Wed, 6 Mar 2002, Octavian Rasnita wrote:

 Why if I use:
 print $q-header;
 print$q-start_multipart_form;

 the result does not contain the result of the first line, but only the form
  line?

print $q-header; prints out HTTP headers like 'Content-type: text/html'
and not html code.  You don't see HTTP headers visible in your browser.
This is like if you used print $q-redirect, you would get a Location:
HTTP header also not visible in the browser.

HTTP headers send information back and forth from the server and client,
while HTML is displayed in the client.  You can read about these headers
in the HTTP specs in RFC 2616 at the W3C web site.


Lisa Wolfisch Nyman  [EMAIL PROTECTED]  IT Warrior Princess
Life is too short to wear ugly underwear.
Get the facts at http://quickfacts.census.gov/




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Environment Variables help

2002-03-02 Thread Lisa Nyman

Hi,

On Sat, 2 Mar 2002, Naika - EV1 wrote:

 $user = $ENV{'REMOTE_USER'};
 ### Not working

Note that this is only set for authenticated pages.  You didn't mention if
your script autheticates or not.

Also, you don't need to cross post to both beginners lists.  It's best if
you pick the most appropriate one.  I have sent this reply to
beginners-cgi only.

Lisa Wolfisch Nyman  [EMAIL PROTECTED]  IT Warrior Princess
Life is too short to wear ugly underwear.
Get the facts at http://quickfacts.census.gov/


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: SSI errors?

2001-12-14 Thread Lisa Nyman

Hi,

On Thu, 13 Dec 2001, Steven Vargas wrote:

 I'm trying to run a Perl program in my .shtml file using this directive:
 !--#include virtual=/snogtofile.pl?file=home--

 I know includes work, because we're using them already. And, I've already
 got one CGI application running, but this is the first one using an SSI
 directive.

Web servers can be configured to allow includes but not execs.  Make sure
your server is configured to allow execs (not always a good idea, though).

 Either it prints the program in the browser: yikes. Or it prints this
 message at the top of the window: [an error occurred while trying to process
 this directive].

You've run the perl script by itself to be sure it executes at all, right?

 This is a Netscape server, running on a Solaris box. Anyone with any
 knowledge of where to look for server configuration.

The Netscape server has a GUI to the configuration options and under the
'content management' section, there is a link to 'parse html'.  That's
where to find the SSI settings.  You would have to contact your admin (if
it isn't you) to check this out.


Lisa Wolfisch Nyman  [EMAIL PROTECTED]  IT Warrior Princess
Life is too short to wear ugly underwear.
Get the facts at http://quickfacts.census.gov/



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: why wont images in webpages created with perl show up?

2001-12-05 Thread Lisa Nyman

Hi,

On Wed, 5 Dec 2001, jeremy wrote:

 Here is a small followup question though.  After I moved the files, say, to
 directory /var/www/html/files  and I tried to reference them from the perl
 generated html with a hard reference...

   img src=/var/www/html/files/titlePic.gif

 it didnt work, however, if I referenced it with a URL...

 img src=http://localhost/files/titlePic.gif;

 it DID work (will I have to change localhost to the server IP address when
 im ready to go live?).  I thought this was odd.  But nevertheless, it works
 now and I'm happy.  Thanks for everyones help

Is /var/www/html/files/ the path from your web server root or is
it the physical path on your computer?  Remember you need to use the relative
path from your web server root in this case.


Lisa Wolfisch Nyman  [EMAIL PROTECTED]  IT Warrior Princess
Life is too short to wear ugly underwear.
Get the facts at http://quickfacts.census.gov/




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Generating static HTML Pages

2001-12-05 Thread Lisa Nyman

Hi,

On Wed, 5 Dec 2001, John Griffiths wrote:

 I agree, I make   update static web site pages routinely, using the
 methods recommended  in other posts to this thread, but rather than
 flocking files I write the new copy in a 'safe' place and then make a
 copy of it on the web server. This has the adv antage of maintaining a backup
 file, and I also backup the old web site file before replacing it with
 the new copy.

Staging systems are a good thing.

If you are limited to a single development and live production host,
with Apache (I don't use other servers so I can speak to them) you can set
up a staging server virtual host and do file creating there.  Then just
move the files over to the production directories.  I would not recommend
creating new pages directly in your production server directories (unless
of course you have a script users run which does this by intent).

Lisa Wolfisch Nyman  [EMAIL PROTECTED]  IT Warrior Princess
Life is too short to wear ugly underwear.
Get the facts at http://quickfacts.census.gov/




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




CGI and NAME v. ID

2001-12-03 Thread Lisa Nyman

Hi,


The HTML4 spec reads:

Each scripting language has its own conventions for referring to HTML
objects from within a script. This specification does not define a
standard mechanism for referring to HTML objects. However, scripts should
refer to an element according to its assigned name. Scripting engines
should observe the following precedence rules when identifying an
element: a name attribute takes precedence over an id if both are
set. Otherwise, one or the other may be used.

I looked this up because someone handed me a script which used the ID
attribute of an INPUT element with a param() call to retrieve the INPUT's
value.  In my tests on Apache, this didn't work.  My assumption is that ID
cannot be used to assign a name to a form element, or at least CGI.pm
won't pick it up.

Does anyone have any insight to this?

-lisa


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: error reports

2001-10-31 Thread Lisa Nyman

Hi,


On Tue, 30 Oct 2001, Guy Tubbs wrote:

 Does anybody know if it is possible to trap errors in Perl when they occur
 and then send them with a bit of info with sendmail?

Sure it is.  In fact, you always want to trap errors in a web app so you
can die gracefully and give the user some nice message rather than an icky
server error page.

 For example, if one of my web scripts messed up when someone was using it
 they'd get the standard error page and I would receive an email with the
 referring page and any other useful info as to why the problem occurred.

I use a custom error routine in my web apps.  Say a database error occurs,
I tell the user, in a pretty web page, that the database is temporarily
unavailable, but I log the real error.  I could also email it to myself.

sub db_down {
# if the db connections fail
my ($err) = shift;
print qq!The database is temporarily unavailable.P\n!;
print qq!/BODY/HTML\n!;
my $date= scalar localtime();
if (open (LOG, $logfile) )  {
print LOG $0: $date: $err\n;
close (LOG);
}
exit (0);
}

Where I print to a log file, I could email using nice modules for that
purpose, or I could (safely) use the old pipe to sendmail.

I call this routine for example, like this, to trap a bd error:

$sth-execute or db_down ($DBI::errstr);


-lisa


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Docs

2001-10-15 Thread Lisa Nyman



  Where's a good place to find documentation in HTML of the CGI and DBI
  modules?

CGI:  http://stein.cshl.org/WWW/CGI/
DBI:  http://dbi.symbolstone.org/index.html

Lisa Wolfisch Nyman  [EMAIL PROTECTED]  IT Warrior Princess
Life is too short to wear ugly underwear.
Get the facts at http://quickfacts.census.gov/



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: redirection with perl

2001-09-26 Thread Lisa Nyman

Hi,

You can do a couple of things.

1) just print a Location: header like

if ($name eq 'invader') {
print Location:http://www.foo.com/invader\n\n;;
}


Or, using CGI.pm, use the redirect function:

if ($name eq 'invader') {
print redirect('http://www.foo.com/invader');
}

On Wed, 26 Sep 2001, Wagner wrote:

 Hi,

 I want to do a redirection based on a variable

 for example:

 if ($name eq 'invader') {

 redirection to some URL ;

 }

Lisa Wolfisch Nyman  [EMAIL PROTECTED]  IT Warrior Princess
Life is too short to wear ugly underwear.
Get the facts at http://quickfacts.census.gov/



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: I'm stuck

2001-09-10 Thread Lisa Nyman

Hi,

You need to establish your headers before you print anything.

Lisa Wolfisch Nyman  [EMAIL PROTECTED]  IT Warrior Princess
Life is too short to wear ugly underwear.
Get the facts at http://quickfacts.census.gov/

On Mon, 10 Sep 2001, Peter Bosmans wrote:

 But if i comment the 3 lines between comment out, then this script
 will work. (i see the generated HTML-page at my browser)
 Does anybody see what the problem is ?
 Thanks in advance

 #!/usr/local/bin/perl -w

 use CGI;

 $query = new CGI;
 $teamleader = me.myself\@my_island.see;

 $mailfile = /home/myself/mymail..$$;

 # Comment out these lines and this perl script will work
 open (mailfile,.$mailfile);
 print mailfile Originator : .$query-param('ORIG').\n;
 close (mailfile);
 # End comment out

 #unlink ($mailfile);


Move this up before you print anything.

 print $query-header('text/html');
 print $query-start_html('Input CR','me.myself\@my_island.see');


 print $query-h1('Your request is sended to the teamleader
 :'.$teamleader);
 print $query-end_html();



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: I'm stuck

2001-09-10 Thread Lisa Nyman

Hi,

Oops - sorry - didn't see you were printing to the mailfile -

Nevermind that one.

You may not have permissions to open the mailfile.  Try printing $! and
see what you get as an error.  It's always best to do error trapping on
open() calls.  If you print $! to standard output, you will need the
headers first.


-lisa

On Mon, 10 Sep 2001, Lisa Nyman wrote too quickly:

 You need to establish your headers before you print anything.

  But if i comment the 3 lines between comment out, then this script
  will work. (i see the generated HTML-page at my browser)
  Does anybody see what the problem is ?
  Thanks in advance
 
  #!/usr/local/bin/perl -w
 
  use CGI;
 
  $query = new CGI;
  $teamleader = me.myself\@my_island.see;
 
  $mailfile = /home/myself/mymail..$$;
 
  # Comment out these lines and this perl script will work
  open (mailfile,.$mailfile);
  print mailfile Originator : .$query-param('ORIG').\n;
  close (mailfile);
  # End comment out
 
  #unlink ($mailfile);
 

 Move this up before you print anything.

  print $query-header('text/html');
  print $query-start_html('Input CR','me.myself\@my_island.see');


  print $query-h1('Your request is sended to the teamleader
  :'.$teamleader);
  print $query-end_html();
 


 --
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Newbie -- got a question

2001-08-07 Thread Lisa Nyman

Hi,

On Tue, 7 Aug 2001, Lee Hoffner wrote:

 use strict;
 use CGI qw/:standard/;
 my $dir = param('dir');
 
 #Verify that the requested directory exists.
 #I imagine I want to say something like:
 if (-d $dir) {
 
  print END;
  Content-Type: text/html\n\n
  html
  body
  table
  END

  @filearray = opendir(D,$dir) or die $!;

Since you've already opened the HTML page, you would want a graceful die
procedure here, something like

dieNice {  # assume http headers sent already and html page has begun
print Sorry, this system is unavailable now.P
print /BODY/HTML;
exit;
} 

I like to tell users that a system is unavailable rather than some not
found message.   Of course in this case, you'd want to send yourself a
message since you're passing the image directory to yourself, but a user
can change it.

Lastly, you could also pass the image directory as a PATH_INFO variable:

http://foo.com/script.pl/image_dir

$ENV{PATH_INFO} = image_dir  (I can't remember if / is included or not)


Lisa Wolfisch Nyman  [EMAIL PROTECTED]  IT Warrior Princess
Life is too short to wear ugly underwear.
Get the facts at http://quickfacts.census.gov/




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Exec cgi

2001-07-31 Thread Lisa Nyman

Hi,

Lotts of things could be going wrong.

On Tue, 31 Jul 2001, Tiago Almeida Spritzer wrote:

  Anybody help me with this question?
  I have two folders at the server, one with perl files and other with
 html files. I need that the page index.html execute perl file, and I know
 that this TAG do that !--#exec cgi
 =/usr/local/web/w3/CGI-Bin/leituradois.pl--.  But I try and don't obtain
 any result.

leituradois.pl could have errors or return no data.

leituradois.pl may have incorrect permissions.

The server may not be configured to allow exec server-side includes.

The server may not have exectuable directories set up correctly.

Do you get any error message at all on screen or in the logs?

Lisa Wolfisch Nyman  [EMAIL PROTECTED]  IT Warrior Princess
Life is too short to wear ugly underwear.
Get the facts at http://quickfacts.census.gov/



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: matching on a variable

2001-07-30 Thread Lisa Nyman

Hi,

Have you printed the variable $vars::name to be sure it contains what you
think it does?

Also, try the grep command:

open(LINKS, $statedir/links.dat) or die Error at LINKS: $!\n
my @all_matches = grep (/$vars::name/, LINKS);
print_link (@all_matches)

You can use arguments to grep to get inverse lists and such.

Lisa Wolfisch Nyman  [EMAIL PROTECTED]  IT Warrior Princess
Life is too short to wear ugly underwear.
Get the facts at http://quickfacts.census.gov/

On Mon, 30 Jul 2001 [EMAIL PROTECTED] wrote:

 How can I test whether a person's name (which is the variable called
 $vars::name) is in a particular file  ( links.dat)? The file is simply a
 list of names all separated by the newline character, i.e,
 
 open(LINKS, $statedir/links.dat) || die Error at LINKS: $!;
 @people = LINKS;
 $pattern_to_match = $vars::name;  #$vars::name is Harry, but the code
 won't find him
#$pattern_to_match = Harry; # the code will find Harry
 
 for (@people) {
   if ( /$pattern_to_match/) {
   print a match ;
} # end if
   else {
   print no match  ;
   print_link; # print a hyperlink to the home page
   } # end else
  } #end for loop




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Dreaded Internal Server Error

2001-07-18 Thread Lisa Nyman

Hi,

When a CGI script runs from the command line but not from the web server,
a common culprit is permissions.  Be sure that anything the script does,
like create files, write to files, read files, execute commands, etc, are
allowed for the web server user and group.

Lisa Wolfisch Nyman  [EMAIL PROTECTED]  IT Warrior Princess
Life is too short to wear ugly underwear.
Get the facts at http://quickfacts.census.gov/

On Tue, 17 Jul 2001, Rob Yale wrote:

 Hi,
 
 I'm trying to get a cgi program working (I didn't write it) and I'm
 experiencing some mysterious problems. 
 
 3) I can execute a simple 'hello world' program in the same cgi-bin
 directory both from the shell, and through CGI.  The permissions for all the
 files are 755.  The owner of the file is 'nobody', and the group is 'root'.


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]