Jump to content

Recommended Posts

Posted (edited)

Hi Everyone,

 

I'm trying to install this Perl script that will be a webserver for a program called NetGPS. Basically, a client sends GPS coordinates to this server and then any computer (with the username and password) can retrieve them from it. Here's the code for the perl script:

 

>#!/usr/local/bin/perl 

# netgps.pl 
# Robert Pepper <robert@peppernet.org> 
# Version 1.1 
# Use at your own risk.  Email problems to root@127.0.0.1 

# ----- User defined 
my $filedir    = '/your/file/path/';   # NOT in the webroot! 
my $maxlength   = 10;                        # max length 

of usernames 

# ----- Other variables, don't mess with them 
my $username    = ''; 
my $password   = ''; 
my $mode      = ''; 
my $result       = 1; 
my $returncode    = ''; 
my $coords      = ''; 
my $filename   = ''; 
my %FORM      = ''; 

#-----------------------------------

(Unnecessary code removed by TCH-David.)

 

And here are the directions for installing the script:

 

It is assumed Perl is already installed on your webserver. If not, see Appendix

F for assistance.

1. Decide on a directory that is outside the web root, and that the UID

running perl has RWD access to.

2. Edit the Perl script, netgps.pl and change the variable defining the

directory to the directory you defined in Step 1.

3. Test (see below).

I am slightly confused as to step one (I want to install the script in the root, right? and then pick a directory that is outside of the root.....?).

 

Right now, I have the script installed to the root in my webpage:

 

>http://lilsadam.cogia.net/

 

with it pointing to the GPS2 folder also in the root. I know that isn't right, but what should I do?

 

Also, I've already changed all the permissions to 755.

 

The error log reads right now:

 

[7307] VDB# exec failed for '/home/users/lilsadam/www/lilsadam.cogia.net/netgps.pl' [11]

[Thu May 26 22:27:58 2005] [error] [client 67.11.228.222] Premature end of script headers: /home/users/lilsadam/www/lilsadam.cogia.net/netgps.pl

 

 

Well, I hope I haven't given too much information (or not enough). Thank you So much for your help in advance.

 

Take care,

 

~Adam

Edited by TCH-David
Posted

Welcome to the forums, Adam! :)

 

Right now, I have the script installed to the root in my webpage:

>http://lilsadam.cogia.net/

with it pointing to the GPS2 folder also in the root. I know that isn't right, but what should I do?

The GPS2 folder needs to be created outside of or above your www directory. Once you've picked a location and created the directory, then you need to edit the script so $filedir contains the path of that directory. Example:

>my $filedir    = '/home/users/lilsadam/GPS2';   # NOT in the webroot!

Posted
Welcome to the forums, Adam!  :)

 

Right now, I have the script installed to the root in my webpage:

>http://lilsadam.cogia.net/

with it pointing to the GPS2 folder also in the root. I know that isn't right, but what should I do?

The GPS2 folder needs to be created outside of or above your www directory. Once you've picked a location and created the directory, then you need to edit the script so $filedir contains the path of that directory. Example:

>my $filedir    = '/home/users/lilsadam/GPS2';   # NOT in the webroot!

 

Will do. Thanks for the welcome!!!

 

I'll let you know how it turns out.

 

~Adam

Posted (edited)

Hey again,

 

I modified the script to read as follows:

 

># ----- User defined
my $filedir  = '/sys/Home/Users/lilsadam/';	# NOT in the webroot!
my $maxlength	= 10; 	 # max length of usernames

 

I know the folder at /sys/Home/Users/lilsadam/ is there and has 755 permissions.

But when I navigate to the pearl script using a web browser to http://lilsadam.cogia.net/netgps.pl, I get the following error:

 

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

 

Please contact the server administrator, support@100webspace.com and inform them of the time the error occurred, and anything you might have done that may have caused the error.

 

More information about this error may be available in the server error log.

 

Apache/1.3.33 Server at lilsadam.cogia.net Port 80

I check the error logs and they read:

 

[15048] VDB# exec failed for '/home/users/lilsadam/www/lilsadam.cogia.net/netgps.pl' [11]

[Fri May 27 06:41:17 2005] [error] [client 70.117.25.6] Premature end of script headers: /home/users/lilsadam/www/lilsadam.cogia.net/netgps.pl

 

Any other ideas?

 

Thanks again for your help,

 

~Adam

Edited by lilsadam
Posted

Does your host allow executable scripts outside of the cgi-bin directory? If not, you'd need to place the script in the cgi-bin directory (or a subdirectory of cgi-bin).

Posted
Does your host allow executable scripts outside of the cgi-bin directory?  If not, you'd need to place the script in the cgi-bin directory (or a subdirectory of cgi-bin).

 

I looked on the help file for the host, and yes, it allows executable scripts in any directory.

Posted

Perhaps this might provide some kind of help?

 

Yes, you are allowed to use .cgi and .pl files in your account.

The Perl scripts do not require a special /cgi-bin/ directory. You can place Perl and PHP scripts into any directory you wish.

 

The path to the Perl directory is /usr/bin/perl

The path to the Sendmail directory is: /usr/sbin/sendmail

 

The required permissions are as follows:

PHP scripts - chmod 755 filename.php

Perl scripts - chmod 755 filemane.cgi

 

I don't know what the /usr/bin/perl directory means when it talks about it...maybe it's something I should be looking for....

 

~Adam

Posted
The correct path to perl must be the first line of your script.  You need to change the first line from this:

>#!/usr/local/bin/perl

...to this:

>#!/usr/bin/perl

 

 

YOU ROCK DAVID!!!!!!!!! It works now. This is great.

 

Thanks^100000000. I really appreciate this.

 

Take care,

 

~Adam

Posted (edited)
Welcome to the forums Adam 

 

Now that you see how friendly and helpful we are around here maybe we'll see you as a customer.  :)

 

Maybe I will join!! Probably after I get back from vacation (which is why I'm setting up this GPS script......we leave on Saturday)

 

One last quick question:

 

I was following these steps to "test" my script:

 

3.3.2. Testing

As all components do exactly the same thing, the test is the same. Change the

URL to suit.

1. Run the steps in order.

2. Use a standard web browser.

3. netgps.pl is used as an example, substitute netgps.aspx or whatever as

required.

Test Step 1

Test

Invalid Access

Input

http://servername/netgps.pl

Expected Result

GPSERROR:Invalid Parameters

Test Step 2

Test

No user data found for Receiver.

Input

http://servername/netgps.pl?un=joe&pw=bloggs

Expected Result

GPSERROR:No user data found.

Test Step 3

Test

Valid Remote input.

Input

http://servername/netgps.pl?un=joe&pw=blog...244.2749,S,1480

9.9369,E,21.6,0.0,211202,11.8,E,S*07

Expected Result

GPSOK

Test Step 4

Test

Valid Receiver input.

Input

http://servername/netgps.pl?un=joe&pw=bloggs

Expected Result

GPSOK$GPRMC,065954,V,3244.2749,S,14809.9369,E,21.6,0.0,211202,11.8,E,S*07

Test Step 5

Test

Invalid credentials

Input

http://servername/netgps.pl?un=joe&pw=bloggs33

Expected Result

GPSERROR:Invalid credentials.

If the results aren’t as expected, fix them!

 

And I'm getting quite a few different errors:

 

You can try the different url combinations here:

 

http://servername/netgps.pl

http://servername/netgps.pl?un=joe&pw=bloggs

http://cogia.lilsadam.net/netgps.pl?un=joe...202,11.8,E,S*07

http://servername/netgps.pl?un=joe&pw=bloggs

http://servername/netgps.pl?un=joe&pw=bloggs33

 

Then if you search the script for these errors, the always occur after a call for "FNAME" like here:

 

>#----------------------------------
# Remote is calling, supplying coords.  

sub remote() {
if (-e "$filedir$filename") {
 my $filecont	= '';
 my $pwd2  = '';
 open FNAME, "$filedir$filename" or &failed("Proc error: RCV-FN1");
 $filecont = <FNAME> or &failed("Proc error: RCV-FN2");
 close FNAME or &failed("Proc error: RCV-FN3");

 ($pwd2,) = split /\@/, $filecont;

 if ($pwd2 ne $password) {
	 &failed("Incorrect password/unknown username.");
 }
}

open FNAME, ">$filedir$filename" or &failed("{Proc error: REM-FN1");
print FNAME "$password\@$coords\n" or &failed("Proc error: REM-FN2");
close FNAME or &failed("Proc error: REM-FN3");
}

#----------------------------------

 

Thanks for looking at this again. You guys really are a great support site.

 

~Adam

Edited by lilsadam
Posted

Your URLs needed a little editing to actually test them:

>http://lilsadam.cogia.net/netgps.pl
http://lilsadam.cogia.net/netgps.pl?un=joe&pw=bloggs
http://lilsadam.cogia.net/netgps.pl?un=joe&pw=bloggs&cds=$GPRMC,065954,V,3244.2749,S,14809.9369,E,21.6,0.0,211202,11.8,E,S*07
http://lilsadam.cogia.net/netgps.pl?un=joe&pw=bloggs
http://lilsadam.cogia.net/netgps.pl?un=joe&pw=bloggs33

URLs #2 and #4 are the same URL, but your testing instructions indicate that they should generate different results for some reason.

 

URL #1 produced this error:

>GPSERROR:Incorrect password/unknown username.:

 

URLs #2, #4, and #5 produced this error:

>GPSERROR:Proc error: RCV-FN1:

 

URL #3 produced this error:

>GPSERROR:{Proc error: REM-FN1:

 

Where the RCV-FN1 and REM-FN1 errors occur in the script, the script is trying to open a file ($filedir$filename). I would first suspect a permissions problem on whatever file "$filedir$filename" is supposed to represent, but it's also possible that either $filedir or $filename may not be specified correctly (whatever "$filedir$filename" evaluates to isn't a valid path/filename).

Posted

Hi David,

 

Actually, the first time the script encounters a new/unknown username and password combo, it creates a file for it. Then, if a command to call that username in the future is made, the password is checked, and then the data retrieved. The problem is that the directory I'm trying to write to has permissions, yet the script doesn't want to do that.....In the directions, it says:

 

1. Decide on a directory that is outside the web root, and that the UID

running perl has RWD access to.

 

I don't know exactly where to put the directory (besides not in the /www/lilsadam.cogia.net folder <--which I assume is the root).

 

RWD Access? Any ideas?

 

~Adam

Posted

Earlier you said that you set $filedir to the following:

>my $filedir  = '/sys/Home/Users/lilsadam/'; # NOT in the webroot!

Are you sure this is a valid directory, and one that you are authorized to access from a script running in your account? I don't know what you thought was wrong with my suggestion for the location of $filedir:

>my $filedir  = '/home/users/lilsadam/GPS2/';   # NOT in the webroot!

:thumbup1:

Posted (edited)
Earlier you said that you set $filedir to the following:

>my $filedir  = '/sys/Home/Users/lilsadam/'; # NOT in the webroot!

Are you sure this is a valid directory, and one that you are authorized to access from a script running in your account?  I don't know what you thought was wrong with my suggestion for the location of $filedir:

>my $filedir  = '/home/users/lilsadam/GPS2/';   # NOT in the webroot!

:thumbup1:

 

I wanted to try and create the directory just as you said, but when I tried to add the folder "Home" to the root of my free server, it wouldn't let me, so I went into one of the premade folders "sys" and created the filestructure in there.

 

I know we're working with servers you're not familiar with. If I switch over to your servers today (paid), do you think you could help me out? I'm willing to complete the signup right now. I just hope this all works.

 

:)

 

~Adam

Edited by lilsadam
Posted
I wanted to try and create the directory just as you said, but when I tried to add the folder "Home" to the root of my free server, it wouldn't let me, so I went into one of the premade folders "sys" and created the filestructure in there.

You shouldn't have had to create any folders other than the GPS2 directory. Based on the error message that you were initially receiving:

>[7307] VDB# exec failed for '/home/users/lilsadam/www/lilsadam.cogia.net/netgps.pl' [11]

... /home/users/lilsadam already exists. If you're logging with an FTP program, this may be masked from you - you may not see the "/home/users/lilsadam" part of the directory tree. If this is the case, I believe you should see the "www" directory in the list of folders when you first log in. You would need to create the GPS2 directory right there, so it appears in the folder list along with "www". The path to the GPS2 folder would still need to be what I specified above, as that is the absolute file path (which isn't masked from a script running on your account).

 

However you managed to upload the netgps.pl script to your server, it looks to me like you should be able to go up 1 or 2 levels in the directory structure to where you can see the "www" folder and create the GPS2 directory there.

 

I know we're working with servers you're not familiar with.  If I switch over to your servers today (paid), do you think you could help me out?  I'm willing to complete the signup right now.  I just hope this all works.

If you had your account here, your script would already be up and running. :thumbup1:

 

However, since you need the script up and running before tomorrow (Saturday), signing up for an account today isn't going to be of much help, as it can take 24-72 hours for a domain name to propagate through DNS. It's possible, but I wouldn't guarantee that you'd be able to access your script through your domain by tomorrow.

Posted

Gotcha. That makes perfect sense. The host server won't let me create (I'm using html browser) folders in the top level of files (along with the www) folder, so I've messaged support for help on doing this. Asa I get back from vacation, I'll be with you guys. Thanks for all your help on this, David!

 

Take care,

 

~Adam

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...