msql + cgi form parse error

2003-11-21 Thread Chris Cosner
If someone could point me in the right direction...
I have a form on a system I am maintaining that works fine most of the 
time, but sporadically spits out an error. Users hit the back button, 
only to find that the data they had filled in is no longer in the form 
(but sometimes it stays).
The system is using latest RH9 apache2, perl, msql2.
Other forms on the system work fine.

Some details:
Here is the most common error on screen (in the browser) that I can 
reproduce:
   parse error at line 1 near , ,::S1000
However, according to error_log for httpd, the error is on line 130 of 
the cgi:
$sth-execute;
The $sth is executing an insert query to insert all of the values from 
the form into the msql database. I *think* the parse error is referring 
to this query. So there's something wrong at the time of the query.
The query lists its values in this manner:
,\'$form{pub_title}\', # so a hash ref
but some are referenced directly as variables
,$num_pages,
which were given the value of the $form{num_pages} earlier, and then 
checked with eval().
if ($num_pages){
$num_pages = eval($num_pages);
}
But if I comment out these eval lines it does not change the behavior of 
the page. Seems like old debugging cruft from a previous coder.
I don't see this doubled comma from the parse error anywhere in the 
code, and the query syntax seems kosher, so I guess maybe it's getting 
into one of the variables somehow? I'm definitely not putting it into 
the form.
To summarize my questions:
--Where can I read the code for a good example of such a cgi page? (I am 
already studying what the oreilly books have to offer)
--Could this be caused by a variable being null?, hence , , instead of , 
value ,?
--Any debugging advice for forms? i.e. best way to check/correct form 
data as it submits, so that the db on the receiving end will be happy?
Thanks

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


Re: msql + cgi form parse error

2003-11-21 Thread Wiggins d Anconia


 If someone could point me in the right direction...
 I have a form on a system I am maintaining that works fine most of the 
 time, but sporadically spits out an error. Users hit the back button, 
 only to find that the data they had filled in is no longer in the form 
 (but sometimes it stays).

The form not still being filled in sounds like a browser issue rather
than a scripting issue, does it exhibit itself when using the same
browser for multiple failed queries? On top of the fact that this is
browser (version) implementation specific it will also depend on the
chosen cache settings in the browser used, at least for some browsers.

 The system is using latest RH9 apache2, perl, msql2.
 Other forms on the system work fine.
 

Wow, msql, been a while...

 Some details:
 Here is the most common error on screen (in the browser) that I can 
 reproduce:
 parse error at line 1 near , ,::S1000

In general I believe the line number in the above error represents the
line number of the query *not of the perl script*.  

 However, according to error_log for httpd, the error is on line 130 of 
 the cgi:
  $sth-execute;

Right which is the line that executes 'line 1' of the query.

 The $sth is executing an insert query to insert all of the values from 
 the form into the msql database. I *think* the parse error is referring 
 to this query. So there's something wrong at the time of the query.
 The query lists its values in this manner:
 ,\'$form{pub_title}\', # so a hash ref

This is confusing to me, why are the single quotes escaped? Is this in a
larger double quoted string?  

 but some are referenced directly as variables
 ,$num_pages,
 which were given the value of the $form{num_pages} earlier, and then 
 checked with eval().

Right because they are numbers which don't need to be quoted, though
this whole scheme is not the best way to handle things, see below.

 if ($num_pages){
  $num_pages = eval($num_pages);
 }

As to why the num_pages is being checked like this I have no idea, there
is *no* reason to do this, not to mention it is insecure, slow, yada
yada yada... yikes in fact.  What happens when someone comes along and
decides to put arbitrary Perl code in the form, for instance an 'unlink'
or something.  If you want to check 'num_pages' for a number (integer
presumably and not 0), then something like:

if ($num_pages =~ /^[1-9]+$/) {
  # good a number
}

Would be much better. Unless you know why you need an 'eval' you don't.
When you understand why you would need an eval, you wouldn't use it for
doing the above kind of things.

 But if I comment out these eval lines it does not change the behavior of 
 the page. Seems like old debugging cruft from a previous coder.

It is a good thing to do form validation, just don't do it the way they
did it.

 I don't see this doubled comma from the parse error anywhere in the 
 code, and the query syntax seems kosher, so I guess maybe it's getting 
 into one of the variables somehow? I'm definitely not putting it into 
 the form.
 To summarize my questions:
 --Where can I read the code for a good example of such a cgi page? (I am 
 already studying what the oreilly books have to offer)

That is probably a good start. Ask specific questions on this forum.
Presumably you should also read the documentation for the CGI.pm module
and the DBI module (you are using it right?).

 --Could this be caused by a variable being null?, hence , , instead of , 
 value ,?

Yep.  But again I don't understand where the ? is coming from, is that
an explicit question mark or one of the form entry?

 --Any debugging advice for forms? i.e. best way to check/correct form 
 data as it submits, so that the db on the receiving end will be happy?

Well not specifically about your form data, as that is a rather generic
question, your form data needs to be checked or not depending on how
dumb your user is likely to be and how weird your data will be.

I would highly suggest using binding variables for SQL (insert)
statements. If you haven't already done so check out the binding section
of DBI's docs. This should allow you to separate the building of your
statements from the actual values to be inserted.  This will also
prevent the need for all the escaping of quotes, whether or not to quote
numbers, etc. which is so very nice.  

I generally use something along the lines of:

my $fields = '';
my $values = '';
my @bind = ();

# in here do your form validation, field setting and value string setting

if ($num_pages =~ /^\d+$/) {
  $fields .= ', ' if ($fields ne '');
  $fields .= 'num_pages';
  $values .= ', ' if ($values ne '');
  $values .= '?';
  push @bind, $num_pages;
}

# setup the rest of our statement
my $st = INSERT INTO table_name ($fields) VALUES ($values);
my $sth = $dbh-prepare($st);
unless ($sth) {
  # error here
}
unless ($sth-execute(@bind)) {
   # error here
}

You get the general idea.  Obviously checking multiple values in a loop
may help depending on the type of 

Hidden field on a form in perl

2003-11-21 Thread Derrick_Ballentine
I was wondering if anyone knows how to hide a field in a form so that it 
can be passed on to other forms, mainly for version number and some other 
information that i wish the user not to see and/or change. I know in HTML 
i could simply input type=hidden name=version value=1.0 yet I've 
looked through the manpages and a few books and can't seem to find the 
translation for this in perl. I will say I've only been using perl for 
maybe 3 weeks, so if your response is RTFM... i ask that you refer me to 
what section of the FM i should look to.

Thank you for any and all assistance.

Derrick 

RE: Hidden field on a form in perl

2003-11-21 Thread Hanson, Rob
I'll see if I can explain it gently as you seem to be a gov't worker ;)

There is no perl translation... you just aren't thinking about it in a
web-app type of way.  The sequence would look like this...

1. display page A to user
2. user submits page A with hidden form field
3. perl script process input from page A
4. perl script prints new form page, creating a new hidden input field that
has the value that the script recieved from step 3.

If that makes sense, then the rest is easy... but I am sure something there
won't make sense.  So you might need to ask a more detailed question.

BTW - for step #3 you would probably use the CGI module to extract the form
data from the input to the script.  The code for steps #3 and #4 might look
like this...

use CGI qw(:cgi);

my $hidden_val = param('name_of_hidden_field');

print Content-type: text/html\n\n;
print EOF;
html
body
form action=foo.cgi
 input type=hidden name=name_of_hidden_field value=$hidden_val
 input type=text name=bar
 input type=submit
/form
/body
/html
EOF



-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]
Sent: Friday, November 21, 2003 2:21 PM
To: [EMAIL PROTECTED]
Subject: Hidden field on a form in perl


I was wondering if anyone knows how to hide a field in a form so that it 
can be passed on to other forms, mainly for version number and some other 
information that i wish the user not to see and/or change. I know in HTML 
i could simply input type=hidden name=version value=1.0 yet I've 
looked through the manpages and a few books and can't seem to find the 
translation for this in perl. I will say I've only been using perl for 
maybe 3 weeks, so if your response is RTFM... i ask that you refer me to 
what section of the FM i should look to.

Thank you for any and all assistance.

Derrick 

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



RE: OLE Hash problem getting AD lastLogon

2003-11-21 Thread Tim Johnson
 
Okay, I made it one step further.  I had to convert the variable to a
VT_R8 variable.  Now I can't seem to find any documentation on how this
relates to the date.  I guess from here on out it's a Microsoft, not a
Perl question, but I'll post the code I have so far, because I know
others have run into this issue.  At the end I printed out time so that
it was obvious that it was a different time format.  Or maybe I just
have to pack() or unpack() it?  Still researching...



use strict;
use warnings;
no warnings qw(uninitialized);
use Win32::OLE qw(in);
use Win32::OLE::Variant;
use Tim::Date_Time;

my @dc = qw(dc1 dc2);
my %users;

foreach my $dc(@dc){
print Checking $dc...\n\n;
my $ADUser = Win32::OLE-GetObject(LDAP://$dc/OU=Groups and
Users,OU=HQ,DC=domain,DC=com) || die;
foreach(in($ADUser)){
unless($_-{objectCategory} =~ /Group/i){
my $lastlogon =
Win32::OLE::Variant-new(VT_R8,$_-{lastLogon});
my $name = $_-{name};
print $lastlogon.\n;
$name =~ s/^CN=//;
push @{$users{$name}},$lastlogon;
}
}
}

open(OUTFILE,lastlogon.csv) || die;
print Finding last logon...\n;
foreach(sort keys %users){
my $name = $_;
print $name = ;
my $lastlogon;
foreach my $logon(@{$users{$_}}){
print $logon,;
if($logon  $lastlogon){
$lastlogon = $logon;
}
}
print ($lastlogon)\n;
$lastlogon = (Date_Time::SimpleDT($lastlogon))[0];
print OUTFILE $name,$lastlogon\n;
}
print time;

close OUTFILE;

#

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



Re: buffered output?

2003-11-21 Thread Ramprasad A Padmanabhan
Bryan Harris wrote:
I have an odd problem...

I have a perl script that execs another program:

$cmd = motuds t1.dat t2.dat t3.dat  out1;
exec $cmd;
Motuds takes awhile to run, though, and I often want to see how it's doing:

% tail -f out1

The problem is, the output of motuds is not getting written out to the file
immediately.  Somehow it's getting cached somewhere, and only gets written
out once in a while.  If I type that command on the command line, the tail
command works properly.  So something with the exec process is causing the
output to be buffered.
Does anyone happen to know why?

TIA.

- Bryan


In the beginning of the perlscript  put

$|=1;

That is the simplest way of stopping bufferring on STDOUT.
( For no  bufferring on any other stream use select(HANDLE) ; $|=1 )
Or I think u could use some module like IO::File that has functions do that

Ram



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


RE: OLE Hash problem getting AD lastLogon (final version)

2003-11-21 Thread Tim Johnson
 
Okay, this was such a pain in the buttocks that I decided to post the
final code. (I'll tweak it a bit later, but this is functional)  My
apologies to someone, I found the pack(),unpack() part on the Internet,
and I'm not sure who the original author is.



use strict;
use warnings;
no warnings qw(uninitialized);
use Win32::OLE qw(in);
use Win32::OLE::Variant;
use Tim::Date_Time;
use Tim::GetClients;

my @dc = qw(dc1 dc2 dc3 dc4);
print \n\nFinding all available DCs...\n\n;
for(0..$#dc){
unless(GetClients::Ping($dc[$_])){
delete $dc[$_];
}
}
my %users;

foreach my $dc(@dc){
print Checking $dc;
my $ADUser = Win32::OLE-GetObject(LDAP://$dc/OU=Groups and
Users,OU=HQ,DC=domain,DC=com) || die;
foreach(in($ADUser)){
unless($_-{objectCategory} =~ /Group/i){
my $lastlogon = $_-{lastLogon};
my $name = $_-{name};
my $lastlogontime = 1;
if($lastlogon){
  my $Hval = $lastlogon-{HighPart};
  my $Lval = $lastlogon-{LowPart};
  my $Factor = 1000;   # convert to seconds
  my $uPval = pack(II,$Lval,$Hval);
  my($bVp, $aVp) = unpack(LL, $uPval);
  $uPval = ($aVp * 2**32 + $bVp)/$Factor;
  $lastlogontime = $uPval - (134774*86400);
#convert to Perl time
}
print .;
$name =~ s/^CN=//;
push @{$users{$name}},$lastlogontime;
}
}
print \n\n
}

open(OUTFILE,lastlogon.csv) || die;
print Finding last logon...\n;
foreach(sort keys %users){
my $name = $_;
my $lastlogon;
foreach my $logon(@{$users{$_}}){
if($logon  $lastlogon){
$lastlogon = $logon;
}
}
$lastlogon = (Date_Time::SimpleDT($lastlogon))[0];
print OUTFILE $name,$lastlogon\n;
}
close OUTFILE;

##

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



Need to extract an Installshield archive

2003-11-21 Thread Rajesh Dorairajan
Hello,

I've an archive (.exe) generated by Installshield that contains the
distribution. I need to extract it to a temporary location and execute the
setup.exe from the Bundle. I tried Archive::Zip, but it bombed with the
message 

format error: can't find EOCD signature 

Archive::Zip::Archive::_findEndOfCentralDirectory('Archive::Zip::Archive=HAS
H(0x3cc3240)','IO::File=GLOB(0x3cc4b1c)') called at
C:/Perl/site/lib/Archive/Zip.pm line 931

Archive::Zip::Archive::readFromFileHandle('Archive::Zip::Archive=HASH(0x3cc3
240)','IO::File=GLOB(0x3cc4b1c)'

I am not sure if Archive::Zip module recognizes the archive created by
Installshield. Does anybody have a suggestion on how this can be done?
Perhaps there is another Module that extract the contents? My search on CPAN
did not yield any results. Any help will be deeply appreciated.

Thanks,

Rajesh Dorairajan 
Valicert/Tumbleweed Communications. 
[EMAIL PROTECTED] 
650-216-2018 
http://www.tumbleweed.com


RE: using Getopt with subroutines

2003-11-21 Thread Freimuth,Robert
  Since I anticipate using this module in multiple programs,
  I'd like to keep the parameter list as generic
  as possible (in terms of order and requirements).
 
 That is a worthy cause, but remember that the arguments
 that will be passed in need to be passed in a specific order:
 
   my ($input1, $input2) = qw/bob fried/;
   my $answer1 = some_function($input1, $input2);
   my $answer2 = some_function($input2, $input1);
 
 are not the same inputs, since the ordering is important.

Right - which is why I was thinking Getopt would be an option
(pun intended).

  For that reason, I'd like to use the Getopt::Long module
  to parse the parameter list, but as far as I can tell it
  will only look at @ARGV.  I could simply do a @ARGV = @_,
  but I'd hate to alter @ARGV without knowing what might
  still be there.
 
 Have you thought about merely passing a reference to a Hash
 And then managing the excecptions?

Excellent suggestion!  I should have thought of that before.
(I can tell I'm tired...)  Passing a hash would solve both the
required/optional and parameter order problem.

  Does anyone know if Getopt can be pointed to a different 
  array other than @ARGV?  I couldn't find anything in the
  docs or in the archives.
 
 if you do perldoc -m Getopt::Long you will notice that the
 module is using @ARGV, since it is a module for parsing the
 command line arguments, and not a general purpose parser.
 
 Remember it is trying to deal with issues like
 
   -a -ifg --bob=frodo
 
 and that is WAY too heavy for merely passing between functions.

Good point.  I had a feeling the idea was a bit over-engineered.
I knew Getopt could do what I wanted if I was using the command
line, and I thought I could tweek it for subs.

  I am willing to write my own parser for the argument list 
  (snip)
  idea was to add the 5 non-required variables to @EXPORT_OK and set 
 
 If it is any help, I sooo think that this is a bad idea.
 Exporting 'defaults' is, well, messy as you note, and
 may not even be taking you in the right direction.

That was my last choice.  Thanks for confirming my hesitation.

Thank you for your help.  I think I'll pass a hash as you
suggested and leave it at that.

Bob

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



search and replace in complexed text file?

2003-11-21 Thread Nick Ellson
I have a search and replace task and was hoping to get some advice. I
have a large text file of remote access users from Cisco's ACS
dumpfile that I need to batch alter 2000 of 3000 users. And example
user record (they are not all the same size)

#---
--
Name  : myuser
State : 0
S_flags   : 0
Aging policy  : group1
Good count: 0
Warning count : 0
Change count  : 0
Last change Lo: 1648245808
Last change Hi: 29591352
Last auth Lo  : 0
Last auth Hi  : 0
Rights: 1
Type  : 256
EnableType: 4
Status: 4
Reset : 1
Expiry: 302 103 0   4294963983  0   5
MaxSession: 65535
MaxSess2  : 0
Profile   : 1
LogonHrs  : 0x0016 00 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
ff ff ff ff ff ff
Alias : 0
Value Flags   : 524336
CounterVals_00: 0   0   0   0
CounterRst_00 : 0   0
CounterVals_01: 0   0   0   0
CounterRst_01 : 0   0
##--- User End

I have a simple text file of all the usernames that must be acted on
already, and i was hoping to find a scripted method of searching this
file to locate my usernames, then change the TYPE and STATUS lines for
each respective user to alternate values.

My problem is how to do a search that will stop at a username, reach
forward in the file to find the next occurance of TYPE and then
STATUS, make the replacements, and then continue searching the file
for the rest of the usernames.

Doing a bulk replace of all status and type, that's easy with sed',
and if i could get Grep to go through a file, lock on a name match,
and start sed off from that point I might be ok, but I don't see how
that could be done. So I am betting Perl is my best and perhaps only
option to do this with minimal developement time. Any text
manipulators out there see a way to do this from what I have
described?

Nick
[EMAIL PROTECTED]



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



Array de-referencing problem

2003-11-21 Thread Paul Harwood
I wrote the following code:



$thread = TEFD0;
$logfile = V_DEBUG12121.txt;
$delay = 10232;
@servers = qw (SERVER1 SERVER2 SERVER3 SERVER4);
$server {$thread}-{$logfile}-{$delay} = @servers;

print @$server {$thread}-{$logfile}-{$delay};

My expectation is that it would simply print out the list value of
@servers. Instead I get an error: Can't use an undefined value as a HASH
reference.

If I use: print $server {$thread}-{$logfile}-{$delay};

Then I get the scalar context of the # of values in @servers - 4. So I
know I am missing something obvious. Since the value I am looking for is
the contents of an array, why do I get that error?


--Paul





how to send mail using Perl

2003-11-21 Thread liuxu
I want to send mail using perl,the following is my code.
There are not any error or warning when the program run.
But i can not receive the mail. Please help me ! thanks!

use Net::SMTP;
$smtp = Net::SMTP-new('192.168.1.169') or die Can not connect to the mail
server : $! \n;
$smtp-mail('[EMAIL PROTECTED]');
$smtp-to('[EMAIL PROTECTED]');
$smtp-data();
$smtp-datasend(To: postmaster\n);
$smtp-datasend(\n);
$smtp-datasend(A simple test message\n);
$smtp-dataend();
$smtp-quit;



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



Re: best beginning perl book is?

2003-11-21 Thread Bob X
http://www.manning.com/Johnson/index.html



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



sh: bad number

2003-11-21 Thread but however
Hi,
I compiled a simple program with perl. But I ran into some problems.
sh: campusUnderAttack.out: bad number

I try to execute a program and input the result to antother file 
campusunderAttack.out
like this:

#!/usr/bin/perl
#
# Run campus scenario and plot result
#
#run 'campus network under attack'
print STDERR Running campus under attack scenario...\n;
#`java SSF.Net.Net 57600 campusUnderAttack.dml  campusUnderAttack.out`;
I executed this program under Unix (sun) with bash shell.

Thanks,

wenpeng

_
Tired of spam? Get advanced junk mail protection with MSN 8. 
http://join.msn.com/?page=features/junkmail

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


Re: Array de-referencing problem

2003-11-21 Thread Jenda Krynicky
From: Paul Harwood [EMAIL PROTECTED]
 I wrote the following code:
 
 $thread = TEFD0;
 $logfile = V_DEBUG12121.txt;
 $delay = 10232;
 @servers = qw (SERVER1 SERVER2 SERVER3 SERVER4);
 $server {$thread}-{$logfile}-{$delay} = @servers;

The first problem is here. You are evaluating the array in scalar 
context and storing the resut (the length of the array) into the 
hash.

The line above is equivalent to

$length = @servers;
$server {$thread}-{$logfile}-{$delay} = $length;

The values of a hash can only be scalars!
This means that you have to store a reference to the array in the 
hash:

$server{$thread}-{$logfile}-{$delay} = [EMAIL PROTECTED];

 print @$server {$thread}-{$logfile}-{$delay};
 
 My expectation is that it would simply print out the list value of
 @servers. Instead I get an error: Can't use an undefined value as a
 HASH reference.

The problem in this case is that perl thinks that you want to use the 
$server as a reference to a hash (or a name of a hash variable in 
your case), then take a hash slice, and then use that hash slice as a 
reference to hash.

That is it treats the line like this:

print @{$server}{$thread}-{$logfile}-{$delay};
while what you want is
print @{$server{$thread}-{$logfile}-{$delay}};

P.S.: You've accidentaly used symbolic references. They are a bad 
idea usualy even if you do want to use them, but in this case they 
just confused the matter. You DO want to 
use strict;
use warnings;
no warnings 'uninitialized';
on top of all your scripts.

Jenda
= [EMAIL PROTECTED] === http://Jenda.Krynicky.cz =
When it comes to wine, women and song, wizards are allowed 
to get drunk and croon as much as they like.
-- Terry Pratchett in Sourcery


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



RE: best beginning perl book is?

2003-11-21 Thread Levon Barker
Hi Eric,

I was a novice too when I read Learning Perl by Randal L. Schwartz  Tom
Phoenix, the O'reilly Lama book.

I thought this book was very well written. The authors did a great job of
intoducing topics in the proper sequence, as to accomodate beginners.

I highly recomend it for anyone learning Perl.

Levon Barker



 -Original Message-
 From: Eric Greene [mailto:[EMAIL PROTECTED]
 Sent: Thursday, November 20, 2003 4:20 PM
 To: [EMAIL PROTECTED]
 Subject: best beginning perl book is?


 thanks for any suggestions.  I am a programming novice.



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



RE: how to send mail using Perl

2003-11-21 Thread Levon Barker
 -Original Message-
 From: liuxu [mailto:[EMAIL PROTECTED]
 Sent: Thursday, November 20, 2003 10:13 PM
 To: [EMAIL PROTECTED]
 Subject: how to send mail using Perl


 I want to send mail using perl,the following is my code.
 There are not any error or warning when the program run.
 But i can not receive the mail. Please help me ! thanks!

 use Net::SMTP;
 $smtp = Net::SMTP-new('192.168.1.169') or die Can not connect
 to the mail
 server : $! \n;
 $smtp-mail('[EMAIL PROTECTED]');
 $smtp-to('[EMAIL PROTECTED]');
 $smtp-data();
 $smtp-datasend(To: postmaster\n);
 $smtp-datasend(\n);
 $smtp-datasend(A simple test message\n);
 $smtp-dataend();
 $smtp-quit;

Tail the logs of the SMTP server to see whats going on. I presume you have
control over it as its IP is internal.


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



Re: Need to extract an Installshield archive

2003-11-21 Thread Andrew Gaffney
Rajesh Dorairajan wrote:
Hello,

I've an archive (.exe) generated by Installshield that contains the
distribution. I need to extract it to a temporary location and execute the
setup.exe from the Bundle. I tried Archive::Zip, but it bombed with the
message 

format error: can't find EOCD signature 
	
Archive::Zip::Archive::_findEndOfCentralDirectory('Archive::Zip::Archive=HAS
H(0x3cc3240)','IO::File=GLOB(0x3cc4b1c)') called at
C:/Perl/site/lib/Archive/Zip.pm line 931
	
Archive::Zip::Archive::readFromFileHandle('Archive::Zip::Archive=HASH(0x3cc3
240)','IO::File=GLOB(0x3cc4b1c)'

I am not sure if Archive::Zip module recognizes the archive created by
Installshield. Does anybody have a suggestion on how this can be done?
Perhaps there is another Module that extract the contents? My search on CPAN
did not yield any results. Any help will be deeply appreciated.
I don't believe that InstallShield uses the ZIP format for its archive. I do seem to 
remember that I have been able to open one in either WinRar or WinAce, so it should be a 
common format.

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


RE: how to send mail using Perl

2003-11-21 Thread Paul Kraus
Check out MIME::Lite.

-Original Message-
From: liuxu [mailto:[EMAIL PROTECTED] 
Sent: Thursday, November 20, 2003 10:13 PM
To: [EMAIL PROTECTED]
Subject: how to send mail using Perl


I want to send mail using perl,the following is my code.
There are not any error or warning when the program run.
But i can not receive the mail. Please help me ! thanks!

use Net::SMTP;
$smtp = Net::SMTP-new('192.168.1.169') or die Can not connect to the
mail server : $! \n; $smtp-mail('[EMAIL PROTECTED]');
$smtp-to('[EMAIL PROTECTED]'); $smtp-data();
$smtp-datasend(To: postmaster\n);
$smtp-datasend(\n);
$smtp-datasend(A simple test message\n);
$smtp-dataend();
$smtp-quit;



-- 
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: best beginning perl book is?

2003-11-21 Thread Paul Kraus
Lets not forget http://safari.oreilly.com

This site would have saved me 1000's if I had known about it sooner :)

Paul


-Original Message-
From: Eric Greene [mailto:[EMAIL PROTECTED] 
Sent: Thursday, November 20, 2003 4:20 PM
To: [EMAIL PROTECTED]
Subject: best beginning perl book is?


thanks for any suggestions.  I am a programming novice.


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



RE: Need to extract an Installshield archive

2003-11-21 Thread Rajesh Dorairajan
Yes. I am able to open the archive using Winzip. However,

my $zip = Archive::Zip-new();
my $status = $zip-read( $archive );
return ( -1 ) if $status != AZ_OK;

fails with the message below. Is there another module that can extract the
archive?

Thanks

Rajesh

-Original Message-
From: Andrew Gaffney [mailto:[EMAIL PROTECTED]
Sent: Friday, November 21, 2003 7:09 AM
To: '[EMAIL PROTECTED]'
Subject: Re: Need to extract an Installshield archive


Rajesh Dorairajan wrote:
 Hello,
 
 I've an archive (.exe) generated by Installshield that contains the
 distribution. I need to extract it to a temporary location and execute the
 setup.exe from the Bundle. I tried Archive::Zip, but it bombed with the
 message 
 
 format error: can't find EOCD signature 
   

Archive::Zip::Archive::_findEndOfCentralDirectory('Archive::Zip::Archive=HAS
 H(0x3cc3240)','IO::File=GLOB(0x3cc4b1c)') called at
 C:/Perl/site/lib/Archive/Zip.pm line 931
   

Archive::Zip::Archive::readFromFileHandle('Archive::Zip::Archive=HASH(0x3cc3
 240)','IO::File=GLOB(0x3cc4b1c)'
 
 I am not sure if Archive::Zip module recognizes the archive created by
 Installshield. Does anybody have a suggestion on how this can be done?
 Perhaps there is another Module that extract the contents? My search on
CPAN
 did not yield any results. Any help will be deeply appreciated.

I don't believe that InstallShield uses the ZIP format for its archive. I do
seem to 
remember that I have been able to open one in either WinRar or WinAce, so it
should be a 
common format.

-- 
Andrew Gaffney


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


RE: how to send mail using Perl

2003-11-21 Thread Rajesh Dorairajan
Sendmail is a nice Perl module that lets you do this.

http://www.tneoh.zoneit.com/perl/SendMail/

Rajesh

-Original Message-
From: Paul Kraus [mailto:[EMAIL PROTECTED]
Sent: Friday, November 21, 2003 8:36 AM
To: 'liuxu'; [EMAIL PROTECTED]
Subject: RE: how to send mail using Perl


Check out MIME::Lite.

-Original Message-
From: liuxu [mailto:[EMAIL PROTECTED] 
Sent: Thursday, November 20, 2003 10:13 PM
To: [EMAIL PROTECTED]
Subject: how to send mail using Perl


I want to send mail using perl,the following is my code.
There are not any error or warning when the program run.
But i can not receive the mail. Please help me ! thanks!

use Net::SMTP;
$smtp = Net::SMTP-new('192.168.1.169') or die Can not connect to the
mail server : $! \n; $smtp-mail('[EMAIL PROTECTED]');
$smtp-to('[EMAIL PROTECTED]'); $smtp-data();
$smtp-datasend(To: postmaster\n);
$smtp-datasend(\n);
$smtp-datasend(A simple test message\n);
$smtp-dataend();
$smtp-quit;



-- 
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: Fedora and Findmodules Script

2003-11-21 Thread LoBue, Mark
At 06:47 PM 11/20/2003, Clint wrote:
Ah that's what's up! The findmodules script is only finding those modules 
installed with the new version of Perl (5.8.1) that came on FC1!

How can I modify the findmodules script to find modules that are available 
for use, even if I brought them in via CPAN using a prior version of Perl?


I think the way to do this would be to forget about using the rpm version 
of perl from now on.  When you upgrade perl, upgrade from the 
tarballs.  Then this won't happen the next time.  There should be a way to 
tell yum to never upgrade perl from rpms.

-Mark

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


Re: how to send mail using Perl

2003-11-21 Thread LoBue, Mark
At 07:12 PM 11/20/2003, liuxu wrote:
I want to send mail using perl,the following is my code.
There are not any error or warning when the program run.
But i can not receive the mail. Please help me ! thanks!
use Net::SMTP;
$smtp = Net::SMTP-new('192.168.1.169') or die Can not connect to the mail
server : $! \n;


First thing I would do is change this line to
$smtp = Net::SMTP-new('192.168.1.169' , Debug = 1)
  or die Can not connect to the mail server : $! \n;
This allows you to see the responses from the smtp server, which will help 
track this down.

$smtp-mail('[EMAIL PROTECTED]');
$smtp-to('[EMAIL PROTECTED]');
$smtp-data();
$smtp-datasend(To: postmaster\n);


Are you postmaster?


$smtp-datasend(\n);
$smtp-datasend(A simple test message\n);
$smtp-dataend();
$smtp-quit;
-Mark 

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


RE: how to send mail using Perl

2003-11-21 Thread Ned Cunningham
I would interest in this answer also. 

I have a similar script, however I had to include this line in the beginning to get it 
to dial.

(`rasphone -d`);

Not sure why?


Ned Cunningham
POS Systems Development
Monro Muffler Brake
200 Holleder Parkway
Rochester, NY 14615
(585) 647-6400 ext. 310
[EMAIL PROTECTED]

-Original Message-
From:   LoBue, Mark [mailto:[EMAIL PROTECTED]
Sent:   Friday, November 21, 2003 12:53 PM
To: liuxu; [EMAIL PROTECTED]
Subject:Re: how to send mail using Perl

At 07:12 PM 11/20/2003, liuxu wrote:
I want to send mail using perl,the following is my code.
There are not any error or warning when the program run.
But i can not receive the mail. Please help me ! thanks!

use Net::SMTP;
$smtp = Net::SMTP-new('192.168.1.169') or die Can not connect to 
the mail
server : $! \n;


First thing I would do is change this line to
$smtp = Net::SMTP-new('192.168.1.169' , Debug = 1)
   or die Can not connect to the mail server : $! \n;

This allows you to see the responses from the smtp server, which will 
help 
track this down.

$smtp-mail('[EMAIL PROTECTED]');
$smtp-to('[EMAIL PROTECTED]');
$smtp-data();
$smtp-datasend(To: postmaster\n);


Are you postmaster?


$smtp-datasend(\n);
$smtp-datasend(A simple test message\n);
$smtp-dataend();
$smtp-quit;

-Mark 


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



dbmopen replacement in perl 5.8.0

2003-11-21 Thread Robert Brown
I have had to relocate my business and its network to another state.
As a result, I had to change my internet connection.  The new
arrangement required that I use l2tp tunnelling, so I had to upgrade
the fireware to redhat 9 to accomodate this (it was RH 6.1!).  The
upgrade seemed like a good idea, so I upgraded *ALL* the machines to
rh9.  This caused some grief with my web server (formerly RH 7.x), as
it caused apache to upgrade from 1.3x to 2.0.x, which meant all my
config files were history.  :-(

Now that I have a workable apache config setup, I discover that some
of my cgi scripts written in perl no longer work because rh9 also
upgraded my perl from 5.6.x to 5.8.0, and 5.8.0 no longer has the
dbmopen call working the same way.  Apache also now runs under
username apache, instead of nobody like it used to.  I changed the
ownership of the db file, but alas, still no joy.

Here is an excerpt of the code that fails:

# open the username/password database or create it
dbmopen(%passwd, $passwd_db, 0600)
  || die cannot open $passwd_db: $!;

And here is what gets logged in /var/log/httpd/error_log:

[Fri Nov 21 12:12:59 2003] [error] [client 192.168.1.3] cannot open 
/home/rj/chat/login.db: File exists at /var/www/cgi-bin/rj_chat_login.cgi line 109., 
referer: http://www.elilabs.com/~rj/chat/rj_chat_login.html

Obviously, from the viewpoint of perl 5.6.x programs, perl 5.8.0 has a
very broken dbmopen.  Of course the file exists!  Its a passwoed
database; you can't go creating that new every time you want to use
it!  So why can't it open it?

I have a number of other places where dbmopen is used to implement a
hash as a disk file, and I really do not want to have to go and
redesign the logic of all those programs to make them work.  Surely I
am not the first person to hit this problem.  Surely there is some
simple compatibility fix for this.  Can somebody suggest a fix?

I *HATE* upgrades!

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



RE: Array de-referencing problem

2003-11-21 Thread Paul Harwood
Thanks!

I got it to work using: 

$server {$thread}-{$logfile}-{$delay} = [EMAIL PROTECTED];

But I guess it's better to use an array reference?

-Original Message-
From: Jenda Krynicky [mailto:[EMAIL PROTECTED] 
Posted At: Friday, November 21, 2003 3:37 AM
Posted To: Perl
Conversation: Array de-referencing problem
Subject: Re: Array de-referencing problem

From: Paul Harwood [EMAIL PROTECTED]
 I wrote the following code:
 
 $thread = TEFD0;
 $logfile = V_DEBUG12121.txt;
 $delay = 10232;
 @servers = qw (SERVER1 SERVER2 SERVER3 SERVER4);
 $server {$thread}-{$logfile}-{$delay} = @servers;

The first problem is here. You are evaluating the array in scalar 
context and storing the resut (the length of the array) into the 
hash.

The line above is equivalent to

$length = @servers;
$server {$thread}-{$logfile}-{$delay} = $length;

The values of a hash can only be scalars!
This means that you have to store a reference to the array in the 
hash:

$server{$thread}-{$logfile}-{$delay} = [EMAIL PROTECTED];

 print @$server {$thread}-{$logfile}-{$delay};
 
 My expectation is that it would simply print out the list value of
 @servers. Instead I get an error: Can't use an undefined value as a
 HASH reference.

The problem in this case is that perl thinks that you want to use the 
$server as a reference to a hash (or a name of a hash variable in 
your case), then take a hash slice, and then use that hash slice as a 
reference to hash.

That is it treats the line like this:

print @{$server}{$thread}-{$logfile}-{$delay};
while what you want is
print @{$server{$thread}-{$logfile}-{$delay}};

P.S.: You've accidentaly used symbolic references. They are a bad 
idea usualy even if you do want to use them, but in this case they 
just confused the matter. You DO want to 
use strict;
use warnings;
no warnings 'uninitialized';
on top of all your scripts.

Jenda
= [EMAIL PROTECTED] === http://Jenda.Krynicky.cz =
When it comes to wine, women and song, wizards are allowed 
to get drunk and croon as much as they like.
-- Terry Pratchett in Sourcery


-- 
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: Array de-referencing problem

2003-11-21 Thread Jenda Krynicky
From: Paul Harwood [EMAIL PROTECTED]
 Thanks!
 
 I got it to work using: 
 
 $server {$thread}-{$logfile}-{$delay} = [EMAIL PROTECTED];
 
 But I guess it's better to use an array reference?

You are using an array reference.

The difference is that 
$server {$thread}-{$logfile}-{$delay} = [EMAIL PROTECTED];
creates a copy of the array and stores the reference to the copy 
while
$server {$thread}-{$logfile}-{$delay} = [EMAIL PROTECTED];
stored copy to the original array.

Which of these two do you need I'm not sure.

Try this:

@a = (1,2,3);
$ref1 = [EMAIL PROTECTED];
$ref2 = [EMAIL PROTECTED];

print (@$ref1) == (@$ref2)\n;

$a[0] = 99;
print (@$ref1) != (@$ref2)\n;

HTH, Jenda
= [EMAIL PROTECTED] === http://Jenda.Krynicky.cz =
When it comes to wine, women and song, wizards are allowed 
to get drunk and croon as much as they like.
-- Terry Pratchett in Sourcery


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



Library to parse mail files

2003-11-21 Thread John Manko
Hi,
What would be that best library/module for parsing a mail file.  I want to be able 
to extract the values for header tags as well as the body(including 'recieved by'). 

Thanks,
John

Re: Library to parse mail files

2003-11-21 Thread Wiggins d Anconia


 
 Hi,
 What would be that best library/module for parsing a mail file.  I
want to be able to extract the values for header tags as well as the
body(including 'recieved by'). 
 

I have successfully used:

MIME::Parser
Mail::Box

What is best is *very* subjective, for me it turned out to be Mail::Box,
because it provides the whole range of mail services in similar
interface, is frequently updated (currently maintained), has a support
mailing list, etc. For others it is probably not because it has a steep
learning curve, is slow compared to others, etc.  There are others
available...

http://danconia.org

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



Re: Library to parse mail files

2003-11-21 Thread Kevin Old
On Fri, 2003-11-21 at 14:05, John Manko wrote:
 Hi,
 What would be that best library/module for parsing a mail file.
   I want to be able to extract the values for header tags as well as 
 the body(including 'recieved by'). 

John,

Here's a script I wrote to parse mbox files for a spammers email
address.  I then take the results and build SpamAssassin rules from it.

Read the POD's for each module to get a feel for everything you can do
with them.  This should get you started


#!/usr/bin/perl
#
use warnings;
use strict;
use Mail::MboxParser;
use Email::Find;

my $parseropts = {
enable_cache = 1,
enable_grep = 1,
cache_file_name = 'cache-file',
};

my $mb = Mail::MboxParser-new('probably-spam',
decode  = 'ALL',
parseropts = $parseropts);

while( my $msg = $mb-next_message) {
#print $msg-header-{from}, \n;
#print $msg-header-{to}, \n;
#print $msg-header-{subject}, \n;
my $tmpeml = $msg-header-{from};

find_emails($tmpeml, sub {
my $email = pop @_;
print $email, \n;
$email;
});
}


HTH,
Kevin

-- 
Kevin Old [EMAIL PROTECTED]


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



Re: search and replace in complexed text file?

2003-11-21 Thread david
Nick Ellson wrote:

 I have a search and replace task and was hoping to get some advice. I
 have a large text file of remote access users from Cisco's ACS
 dumpfile that I need to batch alter 2000 of 3000 users. And example
 user record (they are not all the same size)

they are not all the same size means the number of rows for each record 
might be different or that each line can have variable length or both? 
depending on those, your solution can be much simpler.

 
#---
 --
 Name  :   myuser
 State :   0
 S_flags   :   0
 Aging policy  :   group1
 Good count:   0
 Warning count :   0
 Change count  :   0
 Last change Lo:   1648245808
 Last change Hi:   29591352
 Last auth Lo  :   0
 Last auth Hi  :   0
 Rights:   1
 Type  :   256
 EnableType:   4
 Status:   4
 Reset :   1
 Expiry:   302 103 0   4294963983  0   5
 MaxSession:   65535
 MaxSess2  :   0
 Profile   :   1
 LogonHrs  :   0x0016 00 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 ff ff ff ff ff ff
 Alias :   0
 Value Flags   :   524336
 CounterVals_00:   0   0   0   0
 CounterRst_00 :   0   0
 CounterVals_01:   0   0   0   0
 CounterRst_01 :   0   0
 ##--- User End
 

you didn't mention how each record is separated from the other records. 

[snip]

 So I am betting Perl is my best and perhaps only
 option to do this with minimal developement time. Any text
 manipulators out there see a way to do this from what I have
 described?

maybe, we will see. :-) see if the following works for you:

#!/usr/bin/perl -w
use strict;

my $user;

while(){
chomp;
if(/^Name\s+:\s+(\S+)/){
$user = $1;
print $_\n;
}else{
if(/^(Type\s+:\s+)\S+/  defined $user){
#--
#-- look up Type for $user. i am
#-- giving it a type of -1 here for demo
#--
print $1,-1\n;
}elsif(/^(Status\s+:\s+)\S+/  defined $user){
#--
#-- look up Status for $user. i am
#-- giving it a status of -2 here for demo
#--
print $1,-2\n;
$user = undef;
}else{
print $_\n;
}
}
}

__END__

like i said, depends on how your records are stored, your solution can be 
much simpler. for example, if each record is separated by '--' on its own, 
you might be able to set $/ to '--' and just read each record as they come 
along. Or if all records have the same number of rows, you can read a fixed 
number of lines for each record and do something with them. what i suggest 
do not make any of those assumption.

david
-- 
s,.*,,e,y,\n,,d,y,.s,10,,s
.ss.s.s...s.sss.s.ss
s.s.s...s...s..s
...s.ss..s.sss..ss.sss.s
s.s.s...ss.sss.s
..s..sss.s.ss.sss...
..ssss.sss.sss.s

,{4},|?{*=}_'y!'+0!$;
,ge,y,!#:$_(-*[./[EMAIL PROTECTED],b-t,
.y...,$~=q~=?,;^_#+?{~,,$~=~
y.!-*-/:[EMAIL PROTECTED] ().;s,;,
);,g,s,s,$~s,g,y,y,%,,g,eval

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



Ticked Off..

2003-11-21 Thread Eric Walker
Hey all I know I have been told but I can't seem to access this hash.
Can anyone look and see why I can't print out any values.  The print
item statement works and prints out the first level of the hash.
I send in a pointer to $data and $rule.

sub COMMENTSYNC{
my($rule,$data) = @_;
my($crule,$temp,@map,$count);
foreach my $item (keys %{$$data}){
 print  %{$$data{$item}{'rule_desc'}} . \n;
 #print $item . \n;
 }

Thanks




Re: Ticked Off..

2003-11-21 Thread Joshua Colson
It looks to me like you're trying to dereference the wrong hash.

Try this...

sub COMMENTSYNC {
  my($rule,$data) = @_;
  my($crule,$temp,@map,$count);
  foreach my $item ( keys %{$data} ) {
print ${$item}{'rule_desc'} . \n;
  }
}

If the $data is a reference to a hash of hashes, then when the foreach
saves the key in $item, it is actually saving the inner hash in $item.
Then you just dereference $item as though it is a hash reference unto
itself.

On Fri, 2003-11-21 at 13:36, Eric Walker wrote:
 Hey all I know I have been told but I can't seem to access this hash.
 Can anyone look and see why I can't print out any values.  The print
 item statement works and prints out the first level of the hash.
 I send in a pointer to $data and $rule.
 
 sub COMMENTSYNC{
 my($rule,$data) = @_;
 my($crule,$temp,@map,$count);
 foreach my $item (keys %{$$data}){
  print  %{$$data{$item}{'rule_desc'}} . \n;
  #print $item . \n;
  }
 
 Thanks
 
 


signature.asc
Description: This is a digitally signed message part


RE: Ticked Off..

2003-11-21 Thread Bob Showalter
Eric Walker wrote:
 Hey all I know I have been told but I can't seem to access this hash.
 Can anyone look and see why I can't print out any values.  The print
 item statement works and prints out the first level of the hash.
 I send in a pointer to $data and $rule.
 
 sub COMMENTSYNC{
 my($rule,$data) = @_;
 my($crule,$temp,@map,$count);
 foreach my $item (keys %{$$data}){

Here you're using $data as a reference to a scalar (which is in turn a
reference to a hash). Is that really what $data is?

  print  %{$$data{$item}{'rule_desc'}} . \n;

Here you're using $data as a reference to a hash. To be consistent with the
usage above, you would write that as $$data-{$item}. Also, why are you
trying to print a hash? That's odd.

  #print $item . \n; }

Show us your data, and show us what you expect to be printed. I can't figure
out what's going on. But then again, I'm not real smart.

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



RE: Ticked Off..

2003-11-21 Thread Eric Walker
OK hash should look like this.

M -anonhash
 a - value;
 b-  value;
 c-  value;

does that help?



On Fri, 2003-11-21 at 14:04, Bob Showalter wrote:

Eric Walker wrote:
 Hey all I know I have been told but I can't seem to access this hash.
 Can anyone look and see why I can't print out any values.  The print
 item statement works and prints out the first level of the hash.
 I send in a pointer to $data and $rule.
 
 sub COMMENTSYNC{
 my($rule,$data) = @_;
 my($crule,$temp,@map,$count);
 foreach my $item (keys %{$$data}){

Here you're using $data as a reference to a scalar (which is in turn a
reference to a hash). Is that really what $data is?

  print  %{$$data{$item}{'rule_desc'}} . \n;

Here you're using $data as a reference to a hash. To be consistent with the
usage above, you would write that as $$data-{$item}. Also, why are you
trying to print a hash? That's odd.

  #print $item . \n; }

Show us your data, and show us what you expect to be printed. I can't figure
out what's going on. But then again, I'm not real smart.



RE: Ticked Off..

2003-11-21 Thread Eric Walker
I got it thanks. I see my mistake.. 
wow this list is nice..

Thanks again
newbie



On Fri, 2003-11-21 at 14:10, Eric Walker wrote:

OK hash should look like this.

M -anonhash
 a - value;
 b-  value;
 c-  value;

does that help?



On Fri, 2003-11-21 at 14:04, Bob Showalter wrote:

Eric Walker wrote:
 Hey all I know I have been told but I can't seem to access this hash.
 Can anyone look and see why I can't print out any values.  The print
 item statement works and prints out the first level of the hash.
 I send in a pointer to $data and $rule.
 
 sub COMMENTSYNC{
 my($rule,$data) = @_;
 my($crule,$temp,@map,$count);
 foreach my $item (keys %{$$data}){

Here you're using $data as a reference to a scalar (which is in turn a
reference to a hash). Is that really what $data is?

  print  %{$$data{$item}{'rule_desc'}} . \n;

Here you're using $data as a reference to a hash. To be consistent with the
usage above, you would write that as $$data-{$item}. Also, why are you
trying to print a hash? That's odd.

  #print $item . \n; }

Show us your data, and show us what you expect to be printed. I can't figure
out what's going on. But then again, I'm not real smart.




search

2003-11-21 Thread Eric Walker
I am trying to search a string for a [].  I want to count the amount
of [] in the string. 

Any IDeas





RE: search

2003-11-21 Thread Mark Anderson


 From: Eric Walker [mailto:[EMAIL PROTECTED]
 Sent: Friday, November 21, 2003 1:34 PM
 Subject: search


 I am trying to search a string for a [].  I want to count the amount
 of [] in the string.

 Any IDeas

perldoc -q count

gives you:

  How can I count the number of occurrences of a substring within a string?

There are a number of ways, with varying efficiency. If you want
a count of a certain single character (X) within a string, you
can use the tr/// function like so:

$string = ThisXlineXhasXsomeXx'sXinXit;
$count = ($string =~ tr/X//);
print There are $count X characters in the string;

This is fine if you are just looking for a single character.
However, if you are trying to count multiple character
substrings within a larger string, tr/// won't work. What you
can do is wrap a while() loop around a global pattern match. For
example, let's count negative integers:

$string = -9 55 48 -2 23 -76 4 14 -44;
while ($string =~ /-\d+/g) { $count++ }
print There are $count negative numbers in the string;


You want the second example, but you want to use /\[\]/g as your pattern
match.

/\/\ark




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



Re: dbmopen replacement in perl 5.8.0

2003-11-21 Thread drieux
On Friday, Nov 21, 2003, at 10:40 US/Pacific, Robert Brown wrote:
[..]
# open the username/password database or create it
dbmopen(%passwd, $passwd_db, 0600)
  || die cannot open $passwd_db: $!;
And here is what gets logged in /var/log/httpd/error_log:

[Fri Nov 21 12:12:59 2003] [error] [client 192.168.1.3] cannot open 
/home/rj/chat/login.db: File exists at 
/var/www/cgi-bin/rj_chat_login.cgi line 109., referer: 
http://www.elilabs.com/~rj/chat/rj_chat_login.html

Obviously, from the viewpoint of perl 5.6.x programs, perl 5.8.0 has a
very broken dbmopen.  Of course the file exists!  Its a passwoed
database; you can't go creating that new every time you want to use
it!  So why can't it open it?
[..]

I guess the first question I would ask is which
DB_FILE format were you using under 5.6.x that
seems not to have arrived in 5.8.0.
the dbmopen()

I remember hoving some issue with dbm/ndbm...

perl the 'perldoc DB_File' it notes that if you
are going to use the newer versions of Berkley DB 2.x or 3.X
you will want to use BerkleyDB.
cf:
http://search.cpan.org/~pmqs/BerkeleyDB-0.25/BerkeleyDB.pod
It is possible that this has happened 'under the sheets'
for you with the shift from 6.x to 9.x so you will need
to essentially dump the old format into a new format,
assuing that is the real issue here.
the alternative of course is the simpler problem of
permissions, and that the web-server can not actually
read the file. Do you have a piece of test code that
merely opens and reads it?
ciao
drieux
---

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


Re: sh: bad number

2003-11-21 Thread drieux
On Friday, Nov 21, 2003, at 02:21 US/Pacific, but however wrote:

Hi,
I compiled a simple program with perl. But I ran into some problems.
sh: campusUnderAttack.out: bad number

I try to execute a program and input the result to antother file 
campusunderAttack.out
like this:

#!/usr/bin/perl
#
# Run campus scenario and plot result
#
#run 'campus network under attack'
print STDERR Running campus under attack scenario...\n;
#`java SSF.Net.Net 57600 campusUnderAttack.dml  
campusUnderAttack.out`;

I executed this program under Unix (sun) with bash shell.
[..]

I think you may have more than a few issues here.

i'm not at all sure what you mean by

	'compiled a simple program with perl'

nor how exactly you tried to run it.

so you may need to provide us with a whole lot more details
about
a. what you did
b. how you did it
c. what issues you really need answered.
ciao
drieux
---

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


Re: dbmopen replacement in perl 5.8.0

2003-11-21 Thread Robert Brown
drieux writes:
  
  On Friday, Nov 21, 2003, at 10:40 US/Pacific, Robert Brown wrote:
  [..]
  
   # open the username/password database or create it
   dbmopen(%passwd, $passwd_db, 0600)
 || die cannot open $passwd_db: $!;
  
   And here is what gets logged in /var/log/httpd/error_log:
  
   [Fri Nov 21 12:12:59 2003] [error] [client 192.168.1.3] cannot open 
   /home/rj/chat/login.db: File exists at 
   /var/www/cgi-bin/rj_chat_login.cgi line 109., referer: 
   http://www.elilabs.com/~rj/chat/rj_chat_login.html
  
   Obviously, from the viewpoint of perl 5.6.x programs, perl 5.8.0 has a
   very broken dbmopen.  Of course the file exists!  Its a passwoed
   database; you can't go creating that new every time you want to use
   it!  So why can't it open it?
  [..]
  
  I guess the first question I would ask is which
  DB_FILE format were you using under 5.6.x that
  seems not to have arrived in 5.8.0.

Whatever DB_FILE format was the default under perl 5.6.x and Linux 7.x 
was it, as I did nothing to specify any particular format, so I guess
I got the default.

In particular, it would be *VERY* inconvenient, to say the least, to
have to change formats when I cannot read the old file, as I do not
know what usernames and passwords other users might have stored in it; 
all I know is my own.  Since passwords are stored MD5 encrypted, there 
is no easy way for me to recreate this database in a new format,
unless I can read the old format.  And if I can read the old format,
why would I want to change formats anyway?

I suspect this file -- and the other files used by other scripts as
well -- was either Berkeley or Gnu format DB, but I really don't
know.  I used to just work, and now its yet another componet broken
by the latest improvement.  :-(

  the dbmopen()
  
  I remember hoving some issue with dbm/ndbm...
  
  perl the 'perldoc DB_File' it notes that if you
  are going to use the newer versions of Berkley DB 2.x or 3.X
  you will want to use BerkleyDB.
  
  cf:
  http://search.cpan.org/~pmqs/BerkeleyDB-0.25/BerkeleyDB.pod
  
  It is possible that this has happened 'under the sheets'
  for you with the shift from 6.x to 9.x so you will need
  to essentially dump the old format into a new format,
  assuing that is the real issue here.
  
  the alternative of course is the simpler problem of
  permissions, and that the web-server can not actually
  read the file. Do you have a piece of test code that
  merely opens and reads it?

The perms problem was actually an ownership problem.  The fine folks
at Red Hat changed the username that Apache runs ynder from nobody
to apache.  While this sounds like a good idea at first glance, it
means I have a lot of files to change from nobody to apache, and some
of them probably still want to be owned by nobody, as they are
probably not being used by Apache anyway, but some other precess that
still does run under nobody.

I originally could not open the file because of perms, but I fixed
that by chown-ing it to apache.  Now the problem is that it refuses to 
open it because file already exists, which tells me that the
description of dbmopen() that says open the db file or create it if
it does not exist is no longer accurate.

Is theree some conversion utility that I can use to read the old file
and write a new one in a more desirable format?

  ciao
  drieux
  
  ---
  
  
  -- 
  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: Need to extract an Installshield archive

2003-11-21 Thread Andrew Gaffney
Rajesh Dorairajan wrote:
Yes. I am able to open the archive using Winzip. However,

my $zip = Archive::Zip-new();
my $status = $zip-read( $archive );
return ( -1 ) if $status != AZ_OK;
fails with the message below. Is there another module that can extract the
archive?
That still doesn't mean that it is in ZIP format. WinZip *can* open file formats other 
than ZIP.

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


Can I improve the performance of script by using constant?

2003-11-21 Thread pagoda
Can I improve the performance of script by using constant?

Which is the better one?

use constant const = 1e-12

or

my $const = 1e-12


Thanks.
just another perl beginner

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



Re: dbmopen replacement in perl 5.8.0

2003-11-21 Thread Robert Brown
Robert Brown writes:
  drieux writes:
the alternative of course is the simpler problem of
permissions, and that the web-server can not actually
read the file. Do you have a piece of test code that
merely opens and reads it?

I have a very simple utility -- actually a debug tool I wrote over a
year ago -- that likewise no longer works:

#!/usr/bin/perl

# get_dbm_record.pl filename key  -- output data for key on stdout

$filename = shift;
$key = shift;

dbmopen(DBM, $filename, undef) || die cannot open $filename: $!;

$record = $DBM{$key};

print $record;

Here is the file I am trying to read:

# ls -l login.db 
-rwxrwxrwx1 apache   apache  12288 Aug 26 08:12 login.db

(I even did a chmod 777 on it so perms could not be the problem)

This is what happens when I try to run this little script:

# get_dbm_record.pl login.db  rj
cannot open login.db:  at /bin/get_dbm_record.pl line 8.

BTW line 8 is:

dbmopen(DBM, $filename, undef) || die cannot open $filename: $!;

So it is not a case of a key that does not exist.

The improvement squad in perl-land just broke dbmopen(); there is no 
nicer way to put it.  If they wanted a better way to do it, fine, but
please do not break legacy stuff just because a more elegant way comes 
along.  Add the elegance, but keep the stuff people are already
depending on in production code.  Don't gratuitously break stuff that
has worked for years!  

I have no idea how many perl scripts have been broken by this little
improvement.  I can only fix them as they come to light.  But I
cannot even fix them if I do not have another way to make it work.

Grrr.

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



Re: An Alternative to Test::Harness was Re: external sub routine

2003-11-21 Thread drieux
On Monday, Nov 17, 2003, at 00:27 US/Pacific, Rajesh Dorairajan wrote:

Forgive me for not making myself clear in the first place.
forgive me for having to defer a response,
But this is a really interesting problem and
still requires a bit of thinking.
What I'm trying to do is create a Test framework for a
server-class product that validates digital certificates using Perl.
Not a bad idea.

I've a driver script that reads
configuration variables from an XML file using XML::Simple and execute 
a
bunch of tests on the server based on pre-set configuration variables. 
My
effort is to build an optimal, extensible test-suite, whereby I'll 
develop a
reasonably generic framework to which others (developers) can 
contribute
tests in future. This framework will also allow me to execute some 
tests and
skip others based on my requirements.
Oh not simple, but ultimately a reasonablish approach.
What concerns me here is whether
	there needs to be more XML or less

a point I will address later on.

The need to pass variables mainly
arises because I build relative paths to various directories in my
configuration file and the test scripts will need these values based 
on the
tests executed. One approach would be initialize all these values into
environment variables in my driver script. But this did not appeal to 
me as
an optimal approach. Can you share your ideas on this approach?
The idea of passing them through the environment is
very UGLY.
That said, the issue I'm facing is to create atomic test scripts 
that'll be
executed by my driver script based on some configuration file (such as
MANIFEST). These atomic scripts will import functions (and variables) 
from
the modules I've created and also from standard CPAN-modules as and 
when
necessary. I am looking for a mechanism whereby I can integrate these 
test
scripts with my driver program. Right now I've this huge driver program
where the tests are executed in sequence. To this extent I tried 
resuing the
capability already available in Test::Harness (instead of re-inventing 
the
wheel). But as Wiggins mentioned in an earlier mail, Test::Harness 
does not
allow variables to be exported to test scripts. So, I'm trying to 
find a
mechanism to overcome this problem.

Hope I gave a better picture. Till now I've been going around in 
circles and
getting frustrated in the process. So, I decided to seek help from Perl
experts such as you :) I am trying to find out how I can go about
architecting the whole thing.
[..]

{ note: I was actually afraid we were off on this adventure... }

I think you may actually have a couple of core 'design issues'
that you may want to think through here. You might want to
step back and review some of your assumptions. Similarly
you might want to look at the 'jam project',
cf
http://www.perforce.com/jam/jam.html which is written,
unfortunately in 'c' - but it may help your thinking,
the idea here is to create the 'input' that will be used by Make
without having the coder understand all of the arcanea Make, hence
it is a two step process
jam
make
You may want to think in a similar manner as to which part of the
problem your Generic Test Harness is really trying to solve.
I was involved with 'jel' which was a perl based variation of
the jam. That project turned out to have about 15 or so Perl Modules
in the Project namespace. { oh dear, I still have some of
that code, which is the giggler of answering this... 8-) }
our 'jel' of course was essentially a simple piece of code,
in of and by it self that basically did:
	my $result = eval use lib '.top'; require './Jelfile.pm';;

Everything Before and after that was the usual sorts of

die $prog error: No Jelfile.pm in $pwd.\n unless (-f 'Jelfile.pm');
and what did we get for $result, and the various switches
based upon OS specific
	if ($Config{'osname'} ne 'MSWin32') {...}

The Money Maker was turning non-perl coders into, perl coders
without TELLING THEM that was what was happening, since they
merely had to create a 'Jelfile.pm' that would use the appropriate
perl module call outs, and then invoke the right types of methods
with the sorts of things one needs to create a real Makefile
with all the required smack in it.
So if you thought of the problem in the form of say

corp_name_test_harness - a simpler driver script
{ note my presumption is that one would grow this out
with Getopt::Long to take alternative config information
and/or additional stuff. }
as being little more than an fancy wrapper that does an 'eval'
with some appropriate tests for
a. the xml_configfile.conf - the default xml_config file name
b. the corp_test_case.pm   - the default thing to be eval'ed
then what you wind up getting into is a slightly more maintainable
strategy, i think, where all you have to do is worry about
the name space issues. So for you
	sub test1 {}

if that is merely a 'method' in say

	

Re: search and replace in complexed text file?

2003-11-21 Thread Tore Aursand
On Thu, 20 Nov 2003 13:37:33 -0800, Nick Ellson wrote:
 My problem is how to do a search that will stop at a username, reach
 forward in the file to find the next occurance of TYPE and then STATUS,
 make the replacements, and then continue searching the file for the rest
 of the usernames.

Easy enough.  What have you tried so far?


-- 
Tore Aursand [EMAIL PROTECTED]
A teacher is never a giver of truth - he is a guide, a pointer to the
 truth that each student must find for himself.  A good teacher is
 merely a catalyst. -- Bruce Lee


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



Re: buffered output?

2003-11-21 Thread Bryan Harris


 The problem is, the output of motuds is not getting written out to the file
 immediately.  Somehow it's getting cached somewhere, and only gets written
 out once in a while.  If I type that command on the command line, the tail
 command works properly.  So something with the exec process is causing the
 output to be buffered.
 
 Does anyone happen to know why?

 In the beginning of the perlscript  put
 
 $|=1;


That line was already in the script.  Any other ideas?

- B



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



Re: buffered output?

2003-11-21 Thread Ramprasad A Padmanabhan
Bryan Harris wrote:

The problem is, the output of motuds is not getting written out to the file
immediately.  Somehow it's getting cached somewhere, and only gets written
out once in a while.  If I type that command on the command line, the tail
command works properly.  So something with the exec process is causing the
output to be buffered.
Does anyone happen to know why?
In the beginning of the perlscript  put

$|=1;


That line was already in the script.  Any other ideas?

- B




Put
BEGIN { $|=1; }
 in both your scripts , ie the wrapper script  and the script that it 
calls

Ram

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


CGI Script Fork

2003-11-21 Thread James Taylor
I'm working on a cgi script that basically, upon running it, runs a
separate script in the background, and displays a message saying
Script is running.  Should be done soon. on the web browser and...
that's it.  The browser can be closed, and the script will continue to
run in the background.  Here's the jest of what I have, but... The
problem is that it doesn't work.  When you run it, it does a system()
call to run the script, and then waits for completion, where it then
displays Script is running.  Should be done soon..  I tried using
exec() instead but that didn't work either.  Also tried adding  to the
end of the command, didn't help.
#!/usr/bin/perl
use strict;
use CGI qw(:cgi-lib :cgi :html2);
$SIG{CHLD}='IGNORE';
my $pid=fork();
if($pid) {
system /www/scripts/process_list.pl;   # Run script in background
} else {
# Print confirmation script to browser, that's it
print header.htmlbodyScript is running.  Should be done
soon./body/html;
}
Any ideas on how to make this work properly??  This is running on 
Solaris 8 with apache, if it matters at all.  Thanks

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