Gossamer Forum
Home : Products : DBMan : Customization :

get_email problem

Quote Reply
get_email problem
Hi there,

I hope someone is able to help me with a small problem before I either pull all my hair out or finally take my frustration out on my poor PC.... I've searched through this form for a similar problem, but it seems that everyone else has a different problem with this sub than I. I'm a novice at perl, using this program as a "learn by example" because it does what I want it to do while explaining every single step so efficiently.

Anyway, the problem. I've put the basic Secure Password mod in and it works a dream. However, once I add the sub get_email, I start to get 500 Internal Server errors. In the cgi log it says:


Can't open perl script " ": No such file or directory


Is this an error with the script or with my cgi-bin/server?

Any ideas will be gratefully received. Thanks for taking the time to read this.
Quote Reply
Re: [Manawydan] get_email problem In reply to
I could be wrong but it doesn't sound like a an error with the script.

There is a snippet of code you can add to your files to get useful error messages.

This can be found in the FAQ (noted below) under the section "Troubleshooting" it's called:

Debugging - How To Obtain Useful Error Messages

You can put this at the top of all your DBMan files and it will really help you to track down any problems within the script.

Unoffical DBMan FAQ

http://creativecomputingweb.com/dbman/index.shtml/
Quote Reply
Re: [LoisC] get_email problem In reply to
Hi LoisC,

Thanks for the direction - I've put the lines into the db.cgi at the place advised and created the error.txt file. However, I get the 500 Internal error but the error.txt file is still empty. I've check permissions and the location of the text file and they should be fine but the text file stays empty.

Am I doing something incredibly stupid here?

Thanks again for the help.
Quote Reply
Re: [Manawydan] get_email problem In reply to
After you made the changes in your files are you sure you uploaded them in ASCII mode and rechecked the file permissions on the files?

I would think if there were other problems they would have appeared before just adding the get_email sub.

Perhaps check that again and be sure it wasn't placed within another sub by mistake.

If you turn on debugging in your .cfg file does it tell you anything? I add that error code snippet to the .cfg, html.pl, and db.cgi files when I'm first setting up a database.

Unoffical DBMan FAQ

http://creativecomputingweb.com/dbman/index.shtml/
Quote Reply
Re: [LoisC] get_email problem In reply to
Hi LoisC,

I use WS-FTP and I've set it to automatically send .cgi, .txt, .pl, .cfg and .db files as ASCII. I've used DOS FTP as well just in case and still get the error. File permissions are correct.

I would also believe that errors would occur before I added another sub but what is happening is that it is working fine without the get_email sub and as soon as I put that in I get the 500 Internal Server errors. Even with debugging turned on it won't get passed the 500 error :(

A working script, before the addition of get_email, is at:


www.webeye.myby.co.uk/cgi-bin/aradia/dbman-dev/db.cgi


A non-working script, with the addition of get_mail, is at:


www.webeye.myby.co.uk/cgi-bin/aradia/dbman-dev2/db.cgi


I've also put both scripts as txt files at:


www.webeye.myby.co.uk/nogetemail.txt

www.webeye.myby.co.uk/withgetemail.txt




BTW, talking of permissions, I take it that the readme file that comes with dbman is wrong when it says that db.cgi should have 755 but then says this is -rwxr--r--. I'm assuming it means 744 and have set it to that (it works with that and still doesn't work with get_mail if set to 755).

As an addition, I've just uploaded db.cgi again, with the get_email sub, to make sure I have sent it ASCII with the right permissions and just got this, which I've never noticed before:

sending db.cgi as db.cgi (1 of 3)
PORT 213,48,100,153,6,147
200 PORT command successful.
STOR db.cgi
150 Opening ASCII mode data connection for db.cgi.
Transmitted 55297 bytes in 7.1 secs, (76.05 Kbps), transfer succeeded
226 Transfer complete.
MDTM 20030505220050 db.cgi
550 20030505220050: No such file or directory


I didn't get this error when sending the db.cgi without the get_email sub - so I have a feeling that it won't be anything to do with the script at all and may be my server that is at fault.


***** Just found out that this is because WS-FTP was set for passive transfers and my ISP doesn't like them. Resent without passive transfer and it still won't work *****

Thanks for your time looking at this problem.

Last edited by:

Manawydan: May 6, 2003, 3:48 AM
Quote Reply
Re: [Manawydan] get_email problem In reply to
When you use the error snippet you need to use the full path ... not a url.


open (STDERR, ''>http://www.webeye.pwp.blueyonder.co.uk/cgi-bin/error.txt'');

Also it look like you have 2 single quote instead of ".


It would look something like this:

BEGIN {
open (STDERR, ">/home/messages/timelymessages-www/error.txt");
}

When looking at your file you have:

sub get_email {
# --------------------------------------------------------
# Pulls the email address from the password file.

my ($userid, $pw, $view, $add, $del, $mod, $admin, $email);

open (PASSWD, ";
close PASSWD;

foreach $pass (@passwds) { # Go through each pass and see if we match..
next if ($pass =~ /^$/); # Skip blank lines.
next if ($pass =~ /^#/); # Skip Comment lines.
chomp ($pass);
($userid, $pw, $view, $add, $del, $mod, $admin, $email) = split (/:/, $pass);
if ($db_userid eq $userid) {
return $email;
}
}
return "$db_userid not found in password file";
}


The instruction have the following which includes the name of the file to open:

sub get_email {
# --------------------------------------------------------
# Pulls the email address from the password file.
#### Following subroutine added for secure_password_lookup mod

my ($userid, $pw, $view, $add, $del, $mod, $admin, $email);

open (PASSWD, "<$auth_pw_file") || &cgierr("unable to open password file. Reason: $!\n");
@passwds = <PASSWD>;
close PASSWD;

foreach $pass (@passwds) { # Go through each pass and see if we match..
next if ($pass =~ /^$/); # Skip blank lines.
next if ($pass =~ /^#/); # Skip Comment lines.
chomp ($pass);
($userid, $pw, $view, $add, $del, $mod, $admin, $email) = split (/:/, $pass);
if ($db_userid eq $userid) {
return $email;
}
}
return "$db_userid not found in password file";
}


Hope this solves your problem as it will now know which file to open.

Unoffical DBMan FAQ

http://creativecomputingweb.com/dbman/index.shtml/
Quote Reply
Re: [LoisC] get_email problem In reply to
Hi LoisC,

I hang my head in shame - it was exactly because the script was missing some bits :( I'd missed it when I was looking through it and I have no idea why it is missing as I just copy and pasted it all together rather than line by line. :( Also, that ''/" is strange - I use WordPad to script and pasted directly from your site so WordPad must have been confused and thought it was 2 singles instead of one double.

Still can't seem to get that error line to work - I think I'm confused on how I should reference it. When I FTP in it says that the path is:


/htdocs/cgi-bin/aradia/dbman-dev/


but if I put that it still doesn't write to the file even though the file is 777.

Anyway, thank you so much for taking the time to look into my problem - I am in your debt. If you're ever in Liverpool, England, there'll be a couple of drinks for you! :)

Cheers!
Quote Reply
Re: [Manawydan] get_email problem In reply to
Try using just:

BEGIN {
open (STDERR, ">/htdocs/error.txt");
}

This sure be right after the path to perl such as:
#!/usr/bin/perl

in your .cgi file and at the very top of other files. It may have a problem writing to the error.txt file if it's within your cgi-bin directory.

Create and upload the error.txt file in your root directory. When testing your script ... you can just open another browser window and then check that file for any errors. You may need to refresh the file to get the latest version.

Unoffical DBMan FAQ

http://creativecomputingweb.com/dbman/index.shtml/
Quote Reply
Re: [LoisC] get_email problem In reply to
Hi LoisC,

Will try the modification you've advised. Thanks again for the support you've given me with this little problem, it is appreciated.

Edit: ***** Have tried these lines and as soon as I upload the file I start to get 500 Internal errors again until I delete the file and replace it with one without the lines *sigh* Permissions are correct and it's uploaded as ASCII. *****

Now to try and make some modifications myself - am trying to display either a welcome, if logged in, or a "Please log in" if not, like on the top of the forums here. The only way I'm going to learn is to try! :)

Thanks again, you're a star!

Last edited by:

Manawydan: May 6, 2003, 7:26 PM
Quote Reply
Re: [Manawydan] get_email problem In reply to
The DBMan FAQ below is a great resource with many tips and tricks presented in the forums over the past several years.

For the welcome message check under the section "Admin" for a thread called "Display personalized welcome message"

Scanning the FAQ will give you many ideas for modification to your database.

Glad i could be of help.

Unoffical DBMan FAQ

http://creativecomputingweb.com/dbman/index.shtml/
Quote Reply
Re: [Manawydan] get_email problem In reply to
There's no reason I can see for that code to create an error. The best thing to do when getting an error is view your error log. It will tell you what went wrong.
Quote Reply
Re: [LoisC] get_email problem In reply to
Hi LoisC,

Thanks for the advice! I'm going to attempt to create my own modifications first (I really want to learn perl and I seem to have quite a steep learning curve - most books just don't seem to explain the language in the way I learn) but I'll certainly look through your FAQ for any further help.

Thanks again - you're a benefit to this board and it's users.
Quote Reply
Re: [Paul] get_email problem In reply to
Hi Paul,

Thanks for taking a look. After I made my post I gave up for the night and went to bed. When I got up it was working fine! :/ Don't know what's causing this as I'm not running through a cache and reloaded direct from server so I can only assume that it is something on my server that is causing the fault.

I'll just have to remember that, in future, I'll leave and errors until the morning! *grin*

Cheers!
Quote Reply
Re: [Manawydan] get_email problem In reply to
Interesting problem. For quite a long time I have been running a dbman script, heavily modified with mail functions. It has been working perfectly - until my host "upgraded" all its servers and installed new machines.

The mail functions ceased to work, and the host naturally denied any responsibility. I moved the script to another of my servers, that was yet to be upgraded, and it ran perfectly once again - until they upgraded that one.

What I did notice, was that one part of the mail script worked, but mails were delayed by many hours. That still baffles me.

I have had to employ a different method for performing the previous function, using a non GT script. It does not do what I want it to do, however.

Who do you use as your server host? I have a "virtual server" facility with Host Europe.
-------------
David Olley
Anglo & Foreign International Limited,
http://www.firehelmets.co.uk

There are 10 types of people in the world: those who understand binary, and those who don't.
Quote Reply
Re: [LoisC] get_email problem In reply to
In Reply To:
For the welcome message check under the section "Admin" for a thread called "Display personalized welcome message"


I've probably done this a bit long, but this is what I added to the html.pl file in the footer and, amazingly, it worked! :)

Code:
if ($db_userid eq "") {

print qq|

<P><CENTER><FONT FACE="Times New Roman" COLOR="#000000">Currently not logged in.</FONT></CENTER></P>

|;

}

else {

print qq|

<P><CENTER><FONT FACE="Times New Roman" COLOR="#000000">Currently logged in as: <B>$db_userid</B>. If you are not <B>$db_userid</B> then please <A HREF="$db_script_link_url&logoff=1">log off</A>.</FONT></CENTER></P>

|;

}

endif;

Quote Reply
Re: [davidolley] get_email problem In reply to
Hi David,

I'm using the webspace I get from my ISP, blueyonder, but I think I've tracked down the problem.

I was using WS-FTP but then switched to using IE instead and that's when the problems started (was using IE because it was easier to use that WS-FTP - but it's back to old faithful now *grin*). Once I uploaded the files with WS-FTP it all started to work fine.

So much time wasted :(

Cheers!
Quote Reply
Re: [Manawydan] get_email problem In reply to
That code works, but better syntax is:

if ($db_userid) {

print qq| <P><CENTER><FONT FACE="Times New Roman" COLOR="#000000">Currently logged in as: <B>$db_userid</B>. If you are not <B>$db_userid</B> then please <A HREF="$db_script_link_url&logoff=1">log off</A>.</FONT></CENTER></P> |;
}

else {

print qq| <P><CENTER><FONT FACE="Times New Roman" COLOR="#000000">Currently not logged in.</FONT></CENTER></P> |;
}

There is no need for endif; as far as I know.

You might want to use a font definition at the start of sub-routines to save a lot of formatting tags. Such as:

my $font = 'Font face="Verdana, Arial, Helvetica" Size=2 Color=#000000';

Then you can specify the font in each case as <$font> </font>

Remember that you can define several different fonts, such as my $small_font = ...... and so on.
-------------
David Olley
Anglo & Foreign International Limited,
http://www.firehelmets.co.uk

There are 10 types of people in the world: those who understand binary, and those who don't.
Quote Reply
Re: [davidolley] get_email problem In reply to
Hi David,

Thanks for the extra info - I'm going to change my files so they fit with your suggestions.

I must admit, I'm finding this a bit more awkward that I initially thought. I'm used to the full programming in VB so the shortcuts in Perl do confuse me a little. :) However, even the simple things aren't working and I don't know where to start. Such as I want users to be able to list all names in the database by the initial first letter. Look at the unofficial FAQ (thanks for the link LoisC) and it seems simple enough. So I use:

Code:


print qq![ <A HREF="$db_script_link_url&view_records=1&$screen_name=^A&re=on&sb=2&so=ascend>A</A> ]!;

print qq![ <A HREF="$db_script_link_url&view_records=1&$screen_name=^B&re=on&sb=2&so=ascend>B</A> ]!;

print qq![ <A HREF="$db_script_link_url&view_records=1&$screen_name=^C&re=on&sb=2&so=ascend>C</A> ]!;
However, what it shows is:

[ D ][ F ][ H ][ J ]....

Missing each odd located letter but when you click on a letter it takes you to the previous one (B opens A, D opens C etc) and, even then, it's not picking up the entries that are there. :( Problems like this are going to make this a little bit more difficult to get the grasp of - but, I'll not quit! ;) Anyway, back to work - I'll get this going if it kills me - or causes me to kill someone else! *grin*

Cheers!

Quote Reply
Re: [Manawydan] get_email problem In reply to
It could be just a matter of a missing quotation mark at the end of the url path.

Change:
print qq![ <A HREF="$db_script_link_url&view_records=1&$screen_name=^A&re=on&sb=2&so=ascend>A</A> ]!;

to:

print qq![ <A HREF="$db_script_link_url&view_records=1&$screen_name=^A&re=on&sb=2&so=ascend">A</A> ]!;

and see if that helps

Unoffical DBMan FAQ

http://creativecomputingweb.com/dbman/index.shtml/
Quote Reply
Re: [LoisC] get_email problem In reply to
Hi LoisC,

I realised this not long before I read your post - well, to be more precise, I was that fed up with the whole thing, I printed of that section, deleted the lines and typed them myself. It was then that I saw the " was missing.

It's the little things..... ;)

Thanks for taking the time to point it out.