Re: to check directory permission and owner

2004-12-28 Thread Chandrakant Reddy
Hi 
I wrote this script but don't know how to get the owner of that directory !!

#!/usr/bin/perl 
use strict ;
use warnings ;

while ( my $line  =  ) {
my @array = split(":",$line) ; 

my $loginid = $array[0] ; 
my $uid = $array[2];
my $guid = $array[3];
my $dir = $array[5];
print "$loginid:$dir\n" ; 

if ( -d $dir ) {
print "$dir exists !! \n";
}
else {
print "$dir does not exists !! \n";
}

} # end of while 


regards
CVR



On Tue, 28 Dec 2004 12:36:29 +0530, Chandrakant Reddy
<[EMAIL PROTECTED]> wrote:
> Hi
>  How do I check  whether user's home directory exist or not, & if
> exists then whether it is owned by his uid
> 
> The perl script will have this information :
> username:x:20205:1:my name :/home/username:/bin/bash
> 
> regards
> CVR
>

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




CPAN Shell

2004-12-28 Thread Robert
I did a "r" which gives me "reinstall recommendations". It does spit out 
a list of modules. Do I use "recompile" to batch update those?

Robert

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




Use of uninitialized value in String

2004-12-28 Thread Anish Kumar K.
I am getting this  error not sure why
   Use of uninitialized value in string eq at line :6


1: $rows=$dbh->prepare("select browsername from  course where clientname 
='DEMO");
2: $rows->execute();
3: while(@row=$rows->fetchrow_array())
4: {
5:   $browserName=shift(@row);
6:   if ($browserName eq "")
7:   {
8: ++$browserHash{"EMPTY_BROWSER"};
9:  }
10:   else
11:  {
12:++$browserHash{$browserName};
13:  }
14: }


Why this is happening ...The hash is like this

%browserHash=(
"IE"=>0,
"NETSCAPE"=>0,
"FIREFOX"=>0,
"OTHER"=>0,
"EMPTY_BROWSER"=>0
);



Re: Use of uninitialized value in String

2004-12-28 Thread Ing. Branislav Gerzo
Anish Kumar K. [AKK], on Tuesday, December 28, 2004 at 16:37 (+0530)
wrote about:

AKK> 6:   if ($browserName eq "")

unless ($browserName) {
...

I think you have null value in db.

-- 

 ...m8s, cu l8r, Brano.

[Kids love the rich taste of titanium - Joel]


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




Re: Use of uninitialized value in String

2004-12-28 Thread Anish Kumar K.
Yes...Thanks for the reply..It worked

Thanks
Anish

- Original Message - 
From: "Ing. Branislav Gerzo" <[EMAIL PROTECTED]>
To: 
Sent: Wednesday, December 29, 2004 4:43 PM
Subject: Re: Use of uninitialized value in String


> Anish Kumar K. [AKK], on Tuesday, December 28, 2004 at 16:37 (+0530)
> wrote about:
> 
> AKK> 6:   if ($browserName eq "")
> 
> unless ($browserName) {
> ...
> 
> I think you have null value in db.
> 
> -- 
> 
>  ...m8s, cu l8r, Brano.
> 
> [Kids love the rich taste of titanium - Joel]
> 
> 
> -- 
> 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]
 




Re: to check directory permission and owner

2004-12-28 Thread John W. Krahn
Chandrakant Reddy wrote:
Hi 
Hello,
I wrote this script but don't know how to get the owner of that directory !!
#!/usr/bin/perl 
use strict ;
use warnings ;

while ( my $line  =  ) {
my @array = split(":",$line) ; 

my $loginid = $array[0] ; 
my $uid = $array[2];
my $guid = $array[3];
my $dir = $array[5];
You don't really need @array, you can assign to the scalars directly.
my ( $loginid, $uid, $guid, $dir ) = ( split /:/, $line )[ 0, 2, 3, 5 ];

print "$loginid:$dir\n" ; 

if ( -d $dir ) {
print "$dir exists !! \n";
}
else {
print "$dir does not exists !! \n";
}
if ( $uid == ( stat $dir )[ 4 ] ) {
print "$dir is owned by $loginid.\n";
}
if ( -d _ ) {
print "$dir exists !!\n";
}
else {
print "$dir does not exists !!\n";
}

} # end of while 

John
--
use Perl;
program
fulfillment
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Password Encryption

2004-12-28 Thread Mike Blezien
Hello,
Been trying to figure out how to encrypt a password w/Perl so it's uses the same 
scheme used in a webmin control panel for password protecting directories. It 
says it's the MD5 method, but I have tried serveral variations using the MD5 and 
Digest::MD5 but can't seem to find the correct format. This is a sample of a 
encyrpted password generated by the control panel: 
$1$03838433$k1ZFcLyZ13Q8tU.3WpK9o1

Is there a Perl method to encrypt plain text password in this same manner ??
TIA. :)
--
Mike(mickalo)Blezien
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Thunder Rain Internet Publishing
Providing Internet Solutions that work!
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: Why a program ran with mod_perl runs slower?

2004-12-28 Thread Robert
"Octavian Rasnita" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> Hi all,
>
> I have tried testing mod_perl with the following script:
>
> my $begin = (times)[0];
> print "Content-type: text/html\n\n";
>
> sub fib {
> $_[0] < 2 ? return $_[0] : return fib($_[0] - 1) + fib($_[0] - 2);
> }
>
> $f = fib(29);
> my $end = (times)[0];
> print($end - $begin);
>
> --
>
> Well, if I run this script as a common CGI application, it usually runs
> faster with 10% than if I run it using mod_perl.
> (Under Windows 2000, mod_perl 2 with Active Perl 5.8.4).
>
> I know that the advantage of mod_perl is that it doesn't require time for
> creating a new process and for the example above the time needed for
> starting the process is much lower than for running the entire program, 
> but
> does this mean that mod_perl doesn't lose the time for starting a new
> process, but it executes the program slower?
> Or why does the program runs slower with mod_perl?
>
> I have also tried to put a:
> PerlRequire f:/web/presafierbinte/perl/benchmark.pl
>
> In the corresponding virtualhost section in httpd.conf, in order to 
> preload
> this program at the server start, but it didn't change anything.
>
> Thank you.
>
> Teddy
>
mod_perl on Windows is not the greatest. It is single threaded. If you go to 
the mod_perl docs page there is a bit of information explaining why.

Robert 



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




RE: Can someone translate a small .PY to Perl?

2004-12-28 Thread Bakken, Luke
> > Or more commonly:
> > 
> > while :; do
> > ...
> > done
> > 
> > because the ":" command is true.
> 
> It works for me. That's the way I'd seen it done when I was 
> learning bash. I 
> believe the while checks the return value, not the output of 
> the command.

Just be thankful you didn't use 'cat' uselessly.

There is definitely no reason to use a separate command just for a true
value in a while loop.

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




Re: Can someone translate a small .PY to Perl?

2004-12-28 Thread Dave Gray
> was wondering if there were a translation in PERL so I could have my Netware
> servers send heartbeats to the heartbeat server?
> 
>   Title: PyHeartbeat - detecting inactive computers
>   Submitter: Nicola Larosa
> 
>   # Filename: HeartbeatClient.py
> 
>   """Heartbeat client, sends out an UDP packet periodically"""
> 
>   import socket, time
> 
>   SERVER_IP = '127.0.0.1'; SERVER_PORT = 43278; BEAT_PERIOD = 5
> 
>   print ('Sending heartbeat to IP %s , port %d\n'
>   'press Ctrl-C to stop\n') % (SERVER_IP, SERVER_PORT)
>   while True:
>   hbSocket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
>   hbSocket.sendto('PyHB', (SERVER_IP, SERVER_PORT))
>   if __debug__: print 'Time: %s' % time.ctime()
>   time.sleep(BEAT_PERIOD)

Checkout Socket [1] and Time::HiRes [2], both of which should be
installed already, depending on what version of perl you're working
with. The rest should be fairly simple to translate by following the
code examples. Let us know how that works out for you.

[1] 
[2] 

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




Re: Can someone translate a small .PY to Perl?

2004-12-28 Thread Randal L. Schwartz
> "Andrew" == Andrew Gaffney <[EMAIL PROTECTED]> writes:

Andrew> It works for me. That's the way I'd seen it done when I was learning
Andrew> bash. I believe the while checks the return value, not the output of
Andrew> the command.

That's a bash-ism then, not The One True Shell.  I was using The One
True Shell in 1980. :)

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
 http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!

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




How to throw exceptions for perl cgi program?

2004-12-28 Thread Siegfried Heintze
I'm buffering my html/javascript output in a large array of strings. This
frees me to perform my computations independently of the order they appear
in the output.

However, I have a problem: Let us suppose I have an error from my database
and I have not executed "print $q->header( ),start_html(-title =>
$case_name);"; yet.

Is there a way I can throw an exception in my function (that retrieves data
from the database) and let the main program have an exception handler that
will execute "print $q->header( ),start_html(-title => $case_name);" earlier
than normal so I can print my error messages and abort?

Thanks,
Siegfried


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




Moving Data from one table to another table

2004-12-28 Thread Chris Lyon
Maybe this is a little OT but since I am a beginner @ perl, I thought that I
would post it!

 

So, I am trying to move data from one sql table to another table called
logs_archive. It seems that I am running into some problems with memory as I
am moving this much data from one table to another. This is just syslog data
but we need to archive it in some way. Can anybody give any advice? Code is
below.

 

 

 

 

$sth = $dbh->prepare( "select * from logs where ( timestamp <=
'$start_date$start_time' )" );

$sth->execute();

 

while ( my $ref = $sth->fetchrow_hashref() ) {

$msg_field = $ref->{'msg'};

if ( $msg_field =~ /\'/ ) {

$msg_field =~ s/\'/\\'/g;

}

$string = "INSERT INTO logs_archive ( timestamp, host, facility,
priority, level, tag, date, time, program, msg ) VALUES (
'$ref->{'timestamp'}', '$ref->{'host'}', '$ref->{'facility'}',
'$ref->{'priority'}', '$ref->{'level'}', '$ref->{'tag'}', '$ref->{'date'}',
'$ref->{'time'}', '$ref->{'program'}', '$msg_field' )";

$dbh->do( $string );

}

 

$string_delete = "delete from logs where ( timestamp <=
'$start_date$start_time' )";



Re: Moving Data from one table to another table

2004-12-28 Thread Chris Devers
On Tue, 28 Dec 2004, Chris Lyon wrote:

> So, I am trying to move data from one sql table to another table 
> called logs_archive. It seems that I am running into some problems 
> with memory as I am moving this much data from one table to another. 
> This is just syslog data but we need to archive it in some way. Can 
> anybody give any advice? Code is below.
 
You're archiving syslog data? 

Then why pump it into a database to begin with?

Log data `bzip`s wonderfully well, you know...
 
> $sth = $dbh->prepare( "select * from logs where ( timestamp <=
> '$start_date$start_time' )" );

If you stub in values for $start_date and $start_time, what happens when 
you run this statement directly to your database?

You don't mention what database server you're running, but in the SQL 
dialects I'm familiar with, '<=' isn't a valid operator I'm aware of. 

In any case, you don't really spell out what the problem is. Does this 
code work, but run too slowly, or does it not work at all? What happens 
when you run this script?
 


-- 
Chris Devers

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