Re: PERL/Linux

2001-07-11 Thread Bill Pierson

My apologies -
I use:
$who = `whoami`;
not
$who = `who`;

Thanks,
--Bill


- Original Message -
From: "Simas Cepaitis" <[EMAIL PROTECTED]>
To: "Bill Pierson" <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Wednesday, July 11, 2001 9:33 AM
Subject: Re: PERL/Linux


Good day ;-)

On Wed, Jul 11, 2001 at 09:20:08AM -0400, Bill Pierson wrote:
> Good morning, afternoon, or evening depending on when you read this. :o)
>
> To aid in system administration and to track whom is accessing my servers,
I wrote a little PERL script that is called from /etc/bashrc. As soon as
someone logs in, the program gets the date and executes:
> $who = `who`;
>
> I then have it E-Mail me who just logged in and at what time.
>
> I'd like to find a way to also have it report to me the IP address from
where the user is connecting.

  $who = `w`; ? Is this what you need?


  Simas Cepaitis

--
"If I have been able to see further, it was only because I
 stood on the shoulders of giants"

  --Isaac Newton





PERL/Linux

2001-07-11 Thread Bill Pierson

Good morning, afternoon, or evening depending on when you read this. :o)

To aid in system administration and to track whom is accessing my servers, I wrote a 
little PERL script that is called from /etc/bashrc. As soon as someone logs in, the 
program gets the date and executes:
$who = `who`;

I then have it E-Mail me who just logged in and at what time.

I'd like to find a way to also have it report to me the IP address from where the user 
is connecting.

If someone could enlighten me as to if PERL would offer this capability, or if there 
is another linux system call that I could use, I would appreciate it. Also, if anyone 
has any suggestions on doing the same thing in a "better" way, I'm all eyes.

Thanks for your time,
--Bill

PS - Just a quick note - I've been on the list for a few weeks, and I wanted to take a 
moment and thank those of you who have vast knowledge of PERL and are willing to share 
it. Your help is appreciated.



Re: Simple

2001-07-09 Thread Bill Pierson

Thanks! In just a moment you'll hear a loud "pop." That will be the sound of
my head coming out of my buttocks with great force. :)

--Bill

- Original Message -
From: "Ledbetter, Jason" <[EMAIL PROTECTED]>
To: "'Bill Pierson '" <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Monday, July 09, 2001 2:24 PM
Subject: RE: Simple



open(IN,"something.txt");
while($line = ) {
chomp($line);
if ($line eq "something") {
## HOW DO I STOP THE WHILE AND MOVE ON?
last; ##Here's how. :)
}
}






Simple

2001-07-09 Thread Bill Pierson

Easy question.

open(IN,"something.txt");
while($line = ) {
chomp($line);
if ($line eq "something") {
## HOW DO I STOP THE WHILE AND MOVE ON?
}
}


Too little sleep + too much perl = deer in headlights.

Any help will be appreciated,
--Bill




Re: Mysteries of the STDIN

2001-07-04 Thread Bill Pierson

Dave,
I tested it with the <> on both *nix and windows - both worked with no
problems. I'm guessing that it may be beneficial to see the whole
program.

--Bill


- Original Message -
From: "SAWMaster" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, July 04, 2001 1:32 PM
Subject: Re: Mysteries of the STDIN


Paul, yeah the print is there just to help me debug.  Isn't <> the same as
?  Are you saying I should change that?

Bill, it is a perl file that I used pl2bat to convert to a batch file.  I
can run it either way, as a .pl or as a .bat...the result is the same.

-Dave





Re: Mysterys of the Unknown STDIN

2001-07-04 Thread Bill Pierson

Dave,
Are you running this as a batch file, or as a PERL file?

--Bill

- Original Message -
From: "SAWMaster" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, July 04, 2001 12:48 PM
Subject: Mysterys of the Unknown STDIN


I'm working on a fairly lengthy ( for a newbie like me) program that has two
modes.  The user can type "mine blah" and my program will find all "blah" or
he/she can type "mine !" to enter interactive mode.  The problem is that
when I get to this snippet:

sub getinteractivesearch
{
 #print "We're interactive!\n\n";
 opendir(logdirectory, '.') or die "Can't open directory.";
 print "Enter string to search for: ";
 $searchstring = <>;
 chomp $searchstring;
 print $searchstring;
 &searchfiles;
}

My program dies with this:

Enter string to search for: Can't open !: No such file or directory at
C:\PERLPR~1/mine.bat line 46.

So basically it looks like it's skipping the part where is asks for the
search string.  I have had this problem before, and I have never been able
to figure it out.  Is there some way to flush the <>?  Or what?  I'm totally
in the dark here.  Maybe I'm looking in a completely wrong direction.  Can
someone be my guide?  If you need more code I'd be happy to provide it.  My
problem might not even exist in this snippet.

-Dave






Editor

2001-07-03 Thread Bill Pierson

Hello again, all.

May I get some suggestions for any Windows-based PERL development tools? Preferably, 
free ones?

Thanks,
--Bill




Re: arrays

2001-06-28 Thread Bill Pierson

I'm a learner myself, but here is a quick guess:
open(IN,"/etc/httpd/conf/httpd.conf") || die $!;
@conf = ;
close(IN);

foreach (@conf) {
if ($_ =~ /ServerName (.*)/i) {
push (@servers,$1);
}
}
print "@servers\n";

You may also need to put in a exclusion for the main servername directive at
the beginning of the conf file if you don't want that included in your list.
This example also assumes that there is only 1 space between the server name
and the actual server name.

Hope this helps,
--Bill



- Original Message -
From: "Tyler Longren" <[EMAIL PROTECTED]>
To: "Perl Beginners" <[EMAIL PROTECTED]>
Sent: Thursday, June 28, 2001 9:44 AM
Subject: arrays


Hello everyone,

I'm just starting perl.  I want to search through httpd.conf and get the
ServerName from each virtual host.
Ex:

DocumentRoot /home2/ploo.net/www
ServerName www.ploo.net
CustomLog /home2/ploo.net/logs/access_log
ErrorLog /home2/ploo.net/logs/error_log
TransferLog /home2/ploo.net/logs/transfer_log
ScriptAlias /cgi-bin/ /home2/ploo.net/cgi-bin/


DocumentRoot /home2/test.net/www
ServerName www.test.net
CustomLog /home2/test.net/logs/access_log
ErrorLog /home2/test.net/logs/error_log
TransferLog /home2/test.net/logs/transfer_log
ScriptAlias /cgi-bin/ /home2/test.net/cgi-bin/


Could I get the ServerName values put into an array so I can do something
with each different ServerName?  Thank you everyone.

Tyler






RE: Running PERL as root

2001-06-27 Thread Bill Pierson

Thanks for your replies. Actually, I'd like to be able to modify system
config files, stop and restart daemons, etc.

I'm not aware of the different ways to accomplish this; any tips would be
appreciated.

The server is in a "protected" environment.


--Bill


-Original Message-
From: Farouk Khawaja [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, June 27, 2001 10:44 PM
To: Bill Pierson; [EMAIL PROTECTED]
Subject: Re: Running PERL as root

 Bill Pierson <[EMAIL PROTECTED]> wrote:
> I have a quick question about running a perl
program as root via CGI.
> I would assume it's platform dependant, and in my
situation I have Linux
> Redhat 7.1 w/Apache 1.3.19 webserver.
>
> This question is a little off-topic, however I'm
guessing that a few of you
> may have tackled this issue before.
>
> Thanks again,
> --Bill

I wouldn't run any CGI script as root, no matter how
securly I belive I've written it.  What are you
trying to do that would require root permission to
accomplish?

Maybe you can explore alternatives.






Running PERL as root

2001-06-27 Thread Bill Pierson

I have a quick question about running a perl program as root via CGI.
I would assume it's platform dependant, and in my situation I have Linux
Redhat 7.1 w/Apache 1.3.19 webserver.

This question is a little off-topic, however I'm guessing that a few of you
may have tackled this issue before.

Thanks again,
--Bill





Suggestions?

2001-06-27 Thread Bill Pierson

Greetings all - I realize this is a very broad question, however any suggestions would 
be appreciated.

I'm looking to purchase good learning tools about programming in PERL. I've been 
programming with it for several years, but I've never truly learned the basics - just 
looked at other code and learned from that.
Specifically I'd like to learn from "ground zero" about variables, hashes, etc. as 
well as MySQL connectivity.

I'd like to find something that is concise - I have several projects that I'll be 
working on in the very near future, and fine-tuning my knowledge would be of great 
benefit.

Again, any suggestions will be appreciated.




Large File Sort

2001-06-25 Thread Bill Pierson

Greetings all. I'm new to the list, and this is my first post, please excuse my 
ignorance if I ask a question that has already been addressed.

I need some help finding a program or script that will merge/sort a 250+MB file as 
quickly as possible.

For example - I have 2 files. File A, and File B. I need to take File A and compare it 
against File B, and the result will be File C which is File A with all the entries in 
File B removed, sorted alphabetically. Please note that File B is over 250MB in size, 
and file A can range from 1MB to 100MB in size.
I also need to take the contents of File A and File B, merge them together, and remove 
the duplicates.

Any help would be appreciated!