Re: uninitialised variable error

2003-01-24 Thread WilliamGunther
In a message dated 1/24/2003 1:42:42 AM Eastern Standard Time, 
[EMAIL PROTECTED] writes:


> #!/usr/bin/perl -w
> #
> # emails comments from the site to my address
> #
> use strict;
> use CGI;
> #
> #
> my $q = new CGI;
> my $name = $q->param( "name" );
> my $email = $q->param( "email" );
> my $comments = $q->param( "comments" );
> my $info = ("$name\n$email\n$comments\n");
> 

Works for me. Make sure you have a value for $name, $email, and $comments. 
Run a querry string with it or something, because if there is no 
param('name') then $name is initialized, as in it's 0, right?



Re: Help in running cgi script to append passwd file, shadow and group

2003-01-24 Thread WilliamGunther
In a message dated 1/24/2003 2:32:26 AM Eastern Standard Time, 
[EMAIL PROTECTED] writes:


> my problem is, the cgi can't append the password, shadow and group
> file. How can I make my script to work? I don't have any idea now if
> its possible to make the script work

I won't act like I know the Linux system. Appending a file though: 
open(FILE, ">>path/to/file");



Re: HoH Crash II

2003-01-24 Thread Dave K
Ed, Wiggins, et al

> >   $newH{'TS'} => $TS; # TS is the outer key.   <<== line 33
>
> This sets the outer hash key to the string 'TS' and gives it the value of
the time ($TS) from above.
>
I don't think so. It's late I'm beat but
$newH{'TS'} = $TS;
as opposed to
$newH{'TS'} => $TS;
Which generates the warning.

HTH



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




Re: Help in running cgi script to append passwd file, shadow and group

2003-01-24 Thread zentara
On Fri, 24 Jan 2003 15:30:59 +0800, [EMAIL PROTECTED] (Glynn
S. Condez) wrote:

>Hi All,
>
>I created a cgi perl script, its an account creation script, means you 
>can add an account to a linux system.
>
>my problem is, the cgi can't append the password, shadow and group
>file. How can I make my script to work? I don't have any idea now if
>its possible to make the script work.

When you are asking to do alot with just a simple script.
First of all, you need root access to do this, and running anything
as root thru cgi is asking for trouble.

Usually the answer to this is to use something like suexec, so the
web browser runs as a user, then put that user in the sudoers file,
with the power to do it. It still is dangerous.

Another better solution, is to have the cgi write the requests for
user and password change to a file, and run a cron script by root,
which periodically checks it for errors, and does the changes.

Unless you are really good at this, and few are, it might be best
to use an already developed package to do this. Maybe webmin,
or whatever, I forget the names.




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




Re: Help in running cgi script to append passwd file, shadow and group

2003-01-24 Thread Jason S

> On Fri, 24 Jan 2003 15:30:59 +0800, [EMAIL PROTECTED] (Glynn
> S. Condez) wrote:
>
> >Hi All,
> >
> >I created a cgi perl script, its an account creation script, means you
> >can add an account to a linux system.
> >
> >my problem is, the cgi can't append the password, shadow and group
> >file. How can I make my script to work? I don't have any idea now if
> >its possible to make the script work.
>
> When you are asking to do alot with just a simple script.
> First of all, you need root access to do this, and running anything
> as root thru cgi is asking for trouble.
>
> Usually the answer to this is to use something like suexec, so the
> web browser runs as a user, then put that user in the sudoers file,
> with the power to do it. It still is dangerous.
>
> Another better solution, is to have the cgi write the requests for
> user and password change to a file, and run a cron script by root,
> which periodically checks it for errors, and does the changes.
>
> Unless you are really good at this, and few are, it might be best
> to use an already developed package to do this. Maybe webmin,
> or whatever, I forget the names.

If you need this functionality, I would definitely go with the second option
above. Have your cgi script add the accounts and passwords to a text file,
and run a cron job every 5 minutes or so (which executes another perl
script) to read the file and exec useradd/groupadd on the data contained
therein.

This will allow your second script to do whatever QA and error checking you
require on the submitted username/passwords before adding them, and it
alleviates the need to use sudo, etc.

Make sure the cron job is root owned.



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




Need Some Help!!!!!

2003-01-24 Thread perl
 I looked up to see what the server
error log was saying.  This is what it has:
Premature end of script headers: /home/donmike/www/cgi-bin/file.cgi

I live in Panama City, Fl.  As you can see, I am kinda new at using perl.
I have taken courses on C++, so I do understand some of the commands.

Any help would be great, as I have spent over 5 hours trying to make this
work.  Maybe you have a different way to do what I am trying to acomplish.

I have a directory with about 150 text files and html files and I want to
replace certain words.  For example:

http://www.panamacityrealtors.com/jimmy/contact.html";
target=rightbottom>

This link maybe in 100 different files and I would like to replace the word 
jimmy with a differnt word, like bob.

So I use the this command to do it

$a=~ s/jimmy/bob/;

It works if I do perl file.cgi on the command line but not over the
interent.  I hope, I have given you plenty of information on what I am
trying to acomplish.  

Any help would be great.

Thanks alot for your time.

Mike


- Original Message -
From: "James Tillman" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Sunday, January 19, 2003 7:26 PM
Subject: Re: [Tallahassee-pm] (No subject)


On Sun, 2003-01-19 at 12:40, [EMAIL PROTECTED] wrote:
> This file works on my computer but when I upload it to a unix system and
> try it from the internet it gives me a 500 error.  Can anyone tell me what
> the problem is??  Still new at perl.
>
> Thanks

Hi.  Welcome to the Tallahassee.pm mail list.  Are you in Tallahassee,
FL or nearby?  Even if not, I'll see what I can do with your problem.
See below for my notes...

>
>   #!/usr/bin/perl
>   use CGI qw(:all);
> use strict;
>
> print header;
>   print "Directory to search: ";

I assume you comment this next line out when you run it as a CGI.  If
you didn't, it would probably cause problems.

>   my $dir=; chomp $dir;

>my $dir="/home/lender/nameofdirectory/blankpage";
>
>   my($file);
>

This next line is probably your problem.  You see, when you "die" in a
CGI, you get the error 500 message.  You also get error 500 when you
have a syntax error.  Very difficult to debug.

>   opendir(DH, $dir) || die "Cannot open $dir: $!";

>   while ($file=readdir DH) {
>   next if (-d "$dir/$file");
>   if (! open(F, "$dir/$file") ) {
>   warn "Cannot search $file: $!";
>   next;
>   }
> open(DEST, "> $file") || die "$!";
>   while(defined($a=)){
> $a=~ s/blankpage/newsite/;
> print DEST $a;
> }
> close(DEST);
>   close(F);
>   }
>   closedir(DH);
>

Since there are many places your script might be dying or having
problems (due to the change in environment), I would suggest adding the
following line to your script, just below the use CGI; line:

use CGI::Carp qw/fatalsToBrowser/;

This line will load the CGI::Carp module, which will cause "die"
messages or syntax error messages to be sent to the browser, rather than
causing an Error 500.  This might help you to get more info.  If you
need further help after trying that, please let us know what you
discover!  Best of luck.

jpt



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




Re: Need Some Help!!!!!

2003-01-24 Thread Octavian Rasnita
Hi,

When printing something in the browser, you need to print first the HTTP
header:

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

But make sure your script is password protected, because someone could use
it to delete all the data from your files replacing all the words with "".

Teddy,
Teddy's Center: http://teddy.fcc.ro/
Email: [EMAIL PROTECTED]

- Original Message -
From: <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Saturday, January 25, 2003 1:25 AM
Subject: Need Some Help!


I looked up to see what the server
error log was saying.  This is what it has:
Premature end of script headers: /home/donmike/www/cgi-bin/file.cgi

I live in Panama City, Fl.  As you can see, I am kinda new at using perl.
I have taken courses on C++, so I do understand some of the commands.

Any help would be great, as I have spent over 5 hours trying to make this
work.  Maybe you have a different way to do what I am trying to acomplish.

I have a directory with about 150 text files and html files and I want to
replace certain words.  For example:

http://www.panamacityrealtors.com/jimmy/contact.html";
target=rightbottom>

This link maybe in 100 different files and I would like to replace the word
jimmy with a differnt word, like bob.

So I use the this command to do it

$a=~ s/jimmy/bob/;

It works if I do perl file.cgi on the command line but not over the
interent.  I hope, I have given you plenty of information on what I am
trying to acomplish.

Any help would be great.

Thanks alot for your time.

Mike


- Original Message -
From: "James Tillman" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Sunday, January 19, 2003 7:26 PM
Subject: Re: [Tallahassee-pm] (No subject)


On Sun, 2003-01-19 at 12:40, [EMAIL PROTECTED] wrote:
> This file works on my computer but when I upload it to a unix system and
> try it from the internet it gives me a 500 error.  Can anyone tell me what
> the problem is??  Still new at perl.
>
> Thanks

Hi.  Welcome to the Tallahassee.pm mail list.  Are you in Tallahassee,
FL or nearby?  Even if not, I'll see what I can do with your problem.
See below for my notes...

>
>   #!/usr/bin/perl
>   use CGI qw(:all);
> use strict;
>
> print header;
>   print "Directory to search: ";

I assume you comment this next line out when you run it as a CGI.  If
you didn't, it would probably cause problems.

>   my $dir=; chomp $dir;

>my $dir="/home/lender/nameofdirectory/blankpage";
>
>   my($file);
>

This next line is probably your problem.  You see, when you "die" in a
CGI, you get the error 500 message.  You also get error 500 when you
have a syntax error.  Very difficult to debug.

>   opendir(DH, $dir) || die "Cannot open $dir: $!";

>   while ($file=readdir DH) {
>   next if (-d "$dir/$file");
>   if (! open(F, "$dir/$file") ) {
>   warn "Cannot search $file: $!";
>   next;
>   }
> open(DEST, "> $file") || die "$!";
>   while(defined($a=)){
> $a=~ s/blankpage/newsite/;
> print DEST $a;
> }
> close(DEST);
>   close(F);
>   }
>   closedir(DH);
>

Since there are many places your script might be dying or having
problems (due to the change in environment), I would suggest adding the
following line to your script, just below the use CGI; line:

use CGI::Carp qw/fatalsToBrowser/;

This line will load the CGI::Carp module, which will cause "die"
messages or syntax error messages to be sent to the browser, rather than
causing an Error 500.  This might help you to get more info.  If you
need further help after trying that, please let us know what you
discover!  Best of luck.

jpt



--
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]