CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner: Re: Perl beginner - I need help please: Edit Log



mhx
Enthusiast / Moderator

May 24, 2001, 12:29 PM


Views: 31785
Re: Perl beginner - I need help please

Hi Jenny,

I've written this offline and it took a while. I wouldn't want to delete the already answered questions... ;-)

> I had a lot of login problems with Leetch. Basically, it wouldn’t let me login to certain ftp clients once in a while.

Interesting... I'm using it for years now, and I didn't have any problems. Anyway, I think you'll be happy with WSFTP, too.

> I can’t get my Form to work. I always receive this error

First, the modifications to your file were (mostly) correct (see below).
This error mostly shows when there's a problem with the file rather than with the source code.
There were two problems: First, you have to convert all your CGI-scripts to Unix format. The file you linked to was in DOS format, meaning each line was terminated by a CR/LF sequence, while lines in Unix files are only terminated with a LF character.
To do this conversion, you can use a good text editor (e.g. UltraEdit, use File / Convert / DOS to Unix) or the following script:

Code
#!/bin/perl -w 

undef $/;
$file = shift || 'filename.cgi';

open FILE, $file or die "cannot open $file: $!\n";
$_ = <FILE>;
close FILE;

rename $file, "$file.bak";
s/\r\n/\n/g;

open FILE, ">$file" or die "cannot open $file: $!\n";
binmode FILE;
print FILE;
close FILE;

Provide it with the name of the file you'd like to convert as the first parameter.
The second problem I discovered is that CGI files at netfirms need to be mode 700 instead of mode 755. By the time I registered at netfirms, they also wrote 700 on their page. Perhaps they're making a transition here and it'll work with 755, but if you change to 700 I think you're safe.

> Am I suppose to do anything with either of the following?

No, not really. You should keep in mind that when you reference from HTML to CGI you must use cgi-bin/file.cgi instead of plain file.cgi and when you reference from CGI to HTML, you must use ../file.html instead of plain file.html. So, in your script you should rather write

Code
$ErrorPage = "../a_fail.html";

instead of

Code
$ErrorPage = "a_fail.html";

if a_fail.html is in your www directory.

> http://jennyw.netfirms.com/cgi/printenv

Are you sure with this url? Shouldn't that be http://jennyw.netfirms.com/cgi-bin/printenv.cgi?

> 3. My .cgi file used to be a .pl file, but I just saved it as a .cgi document? Is that ok?

Absolutely.

> 4. If I have html documents that call on .cgi docs then what folder do I put my pages in?
> Do I put them all in the same folder? Or do html docs go in the /www folder and .cgi docs in the /cgi-bin ?

Separate them. The cgi-bin is for CGI scripts, logs, data accessed by CGI scripts, Perl libraries, etc.
The www is for all your HTML, CSS, pictures, files that can be downloaded.

> How do YOU upload your .cgi scripts to netfirms.com?

Actually, I've written a tricky upload script in Perl. That's because first, the site has lots of images, and I don't want to keep track of which of them I have updated locally, and second, I can't (and don't want to) remember when I locally modify my scripts.
Well, my upload script first connects to the netfirms server, recursively retrieves a list of all files on the server, retrieves such a list of the local files on my machine, and checks which files are different. If files differ, it is assumed that the local files are up-to-date. These files are uploaded. If files are available locally, but not on the server, these are uploaded, too. If files are available on the server, but missing locally, these files are removed from the server.
The script also converts all my CGI scripts before uploading so they will have the right shebang line. And last but not least the script sends a chmod 700 for every uploaded CGI script.
Using this script saves me from worrying about synchronization of local and remote files and also saves my money because it significantly reduces my internet costs ;-)
If you're interested in the script, tell me. But be aware that you surely will have to modify it before you can use it. As I said it's a quite tricky sort of script.

> I tried uploading the .cgi email catching script you gave me to netfirms, but it didn’t work. The page wouldn’t come up when I called it in the browser.

Well, I also tried it and it showed up. I don't know if it actually works, but at least it showed up. Are you sure it hasn't got something to do with Unix format or mode 700?

> But some of the files have a slash ( / ) in front of the file name, so should I have a slash before the file name?

Normally files don't have slashes in front of their names ;-) The slash only indicates that the file is located in the root directory. I don't believe this is correct. But, as I mentioned above, you should reference the file from the CGI script as if it was located in the parent directory (../).

Bye,
Marcus

P.S.: There's a successor to LeechFTP, called BitBeamer (ftp://ftp.cuhk.edu.hk/.1/chinese/cpatch/ftp/bitbeamer/bitbeamer2001.exe), which has a synchronize option. This should be quite similar to my upload script, except for modifying scripts and the chmod. It's still in beta state, and I haven't tested it. Since I don't know if WSFTP has a synchronize option, perhaps this is interesting for you.

(This post was edited by mhx on May 24, 2001, 1:06 PM)


This post has not been edited


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives