Re: Installing Curses.pm on Red Hat 8.0

2003-04-04 Thread Bruno Negrao
Hi everybody, I found myself the solution. To install Curses 1.06 with my
perl-5.8.0-55, i need a patch for the Curses package.
First, I  made a search on www.rmpfind.net  for the string 'perl-Curses' and
I found various rpm and src.rpm packages of it, mostly for mandrake. So, I
downloaded the perl-Curses-1.06-5mdk.src.rpm package, and installed it.
I tried the 'rpmbuild -ba perl-Curses-specfile' but it didn't work, so, I
went to the /usr/src/redhat/SOURCES where I found the patch:
Curses-1.06-fix-Perl_sv_isa.patch.bz2. I uncompressed it with bunzip2 and
applied it against my own
Curses-1.06.tar.gz package that I downloaded from CPAN.
Curses compiled and installed fine.

Bruno Negrao

- Original Message -
From: Bruno Negrao
To: [EMAIL PROTECTED]
Sent: Thursday, April 03, 2003 6:40 PM
Subject: Installing Curses.pm on Red Hat 8.0


Hi,
I tried to install the Curses.pm module (from CPAN) on my redhat linux 8.0
but I didn't
compile.
Does someone did it successfully? Any trick?

Thank you,
-
 -- Bruno Negrão -- Suporte
 -- Plugway Acesso Internet Ltda.
 -- (31)34812311
 -- bnegrao at plugway dot com dot br



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



Question about the Shell module

2003-01-22 Thread Bruno Negrao
Hi all, today I discovered a module, the Shell.pm module, which gives you
the possibility to run shell commands directly from perl.
to use it, you should try:

use Shell;
sub ls;
print ls('/etc');

What is the advantage of using all this syntax instead of simply use a:`ls
/etc`; ?
I mean, I don't know why should I use Shell.pm...

thank you,
-
 -- Bruno Negrão -- Suporte
 -- Plugway Acesso Internet Ltda.
 -- (31)34812311
 -- [EMAIL PROTECTED]


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




Re: Using MySQL

2002-10-15 Thread Bruno Negrao - Perl List

I found this excelent article about this subject at:
A Short Guide to DBI: http://www.perl.com/pub/a/1999/10/DBI.html

bnegrao.

- Original Message - 
From: Octavian Rasnita [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Tuesday, October 15, 2002 1:27 AM
Subject: Using MySQL


 Hi all,
 
 I want to start learning MySQL.
 
 I've downloaded MySQL for Windows, because I will use it under Win 2k.
 
 Can you tell me what else do I need to use MySQL databases?
 
 What DBI, DBM, DBD, etc modules I need to be able to use it?
 
 With MySQL I am at the level 0 for the moment, I don't know anything.
 
 Thank you very much for your hints.
 
 Teddy's Center for the blind: http://teddy.fcc.ro/
 Email: [EMAIL PROTECTED]
 
 
 
 -- 
 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: Regular expression

2002-10-07 Thread Bruno Negrao - Perl List

RE: Regular expressionHi Javeed.
This code:
foreach (@attt) { 
/=/  ( ($out) = (split (/=/))[1] ); 
}
stores the string HELLO in the variable $out. Then, if you issue print $out you 
would get a HELLO.

But when I read your e-mail again I realized that you want to store the entire last 
line. So yoy should use this code instead:
foreach (@attt) {
/=/  ( $out = $_ );
} 
The foreach (@attt)  starts a loop storing every line of @attt in a default variable 
called $_
Then, if the regul. exp /=/ matches against the default variable $_, the  
statement is executed, storing the variable $_ in the variable $out.
For clarifying purposes, you could write the same code as:
foreach $line (@att) {
if ($line =~ /=/){ 
$out = $line ;
print $out;
}
} 
And if you want to get rid of the blank spaces in the last line, add try this:
foreach $line (@attt) {
if ($line =~ /=/){
$out = $line ;
$out =~ s/\s*//;
print $out;
}
}   

I learnt all this from the O'reilly book Learning Perl second edition.
Tied hugs and warmfull kisses,
Bruno Negrão.


 
  - Original Message - 
  From: Javeed SAR 
  To: Bruno Negrao - Perl List 
  Sent: Monday, October 07, 2002 1:21 AM
  Subject: RE: Regular expression


  foreach (@attt) { 
  /=/  ( ($out) = (split (/=/))[1] ); 
  } 



  Can u explain this statement to me? 
  Which is the variable i should use for printing the output? 



  Regards 



  -Original Message- 
  From: Bruno Negrao - Perl List [mailto:[EMAIL PROTECTED]] 
  Sent: Friday, October 04, 2002 6:54 PM 
  To: [EMAIL PROTECTED] 
  Subject: Re: Regular expression 



   Hi Javeed , 
   
   the last element of the array is $attt[$#attt]. If you have one line per 
   element, that should do it. 
  Right. This is the easiest way. But, just to answer him, what he could do 
  using regular expression could be something like: 
  foreach (@attt) { 
  /=/  ( ($out) = (split (/=/))[1] ); 
  } 

  Bruno. 



   
   R 
   
   At 14:24 04/10/2002 +0530, Javeed SAR wrote: 
   
   I have the following output in array @attt 
   I want the last line in a variable $out. 
   What should the regular expression be? 


   attribute type SYNC_CHECK 
  created 04-Oct-02.09:36:42 by javeed.clearuser@BLRK35ED 
  for testing 
  owner: HIS\javeed 
  group: HIS\clearuser 
  scope: this VOB (ordinary type) 
  value type: string 
  Attributes: 
SYNC_CHECK = HELLO 


   Regards 
   j 
   
   
   -- 
   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: CGI simple but not working

2002-10-04 Thread Bruno Negrao - Perl List

Hi all, the problem is that the script is really erroneous. Where you read
q(... should be p( ...
The p() function is a part of the CGI.pm modules and stands for a new
paragraph.

the right script is:
#!/usr/bin/perl -w
# cgi-bin/ice_cream: program to answer *and generate* ice cream
# favorite flavor form (version 3)
use CGI qw(:standard);
my $favorite = param(flavor);
print header, start_html(Hello Ice Cream), h1(Hello Ice Cream);
if ($favorite) {
print p(Your favorite flavor is $favorite.);
} else {
print hr, start_form; # hr() emits html horizontal rule: HR
print p(Please select a flavor: , textfield(flavor,mint));
print end_form, hr;
}


Thanks,
bnegrao.


- Original Message -
From: Richard Krause [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Friday, October 04, 2002 6:07 AM
Subject: Re: CGI simple but not working


 Hi Bruno

 It's the print q-Statement, if you write it like this, it works:

 #!/usr/bin/perl -w

 use diagnostics;
 use strict;
 use CGI qw(:standard);

 my $favorite = param(flavor);
 print header, start_html(Hello Ice Cream), h1(Hello Ice Cream);
 if ($favorite) {
 print q(Your favorite flavor is $favorite.);
 } else {
 print start_form,
 Please select a flavor: , textfield(flavor,mint);
 print end_form, hr;
 };
 exit;

 I'm new to perl myself, so haven't found out why textfields aren't working
 with print q. Please let me know if you find out.

 Best Regards
 Richard



 Bruno Negrao - Perl List [EMAIL PROTECTED] wrote in message
 006d01c26b41$fa4d2040$5100a8c0@egp">news:006d01c26b41$fa4d2040$5100a8c0@egp...
  Hi all,
  I'm studying the Learning Perl Second Edition and I'm learning cgi
now.
 
  The book presents a sample cgi that doesn't produces the expected result
 as
  the book says it would. In sumary, this script should generate an one
 field
  form with a default value - mint. But what appears in the screen are
the
  strings inside the q() function.
 
  Could someone test it and say to me if there is something wrong?
 
  The following script was retired from the section 19.6  Form
Generation.
  #!/usr/bin/perl -w
  # cgi-bin/ice_cream: program to answer *and generate* ice cream
  # favorite flavor form (version 3)
  use CGI qw(:standard);
  my $favorite = param(flavor);
  print header, start_html(Hello Ice Cream), h1(Hello Ice Cream);
  if ($favorite) {
  print q(Your favorite flavor is $favorite.);
  } else {
  print hr, start_form; # hr() emits html horizontal rule: HR
  print q(Please select a flavor: , textfield(flavor,mint));
  print end_form, hr;
  }
 
  I'm running Redhat 6.2 perl version 5.005_03 built for i386-linux
  But i tested this script with RH7.2 v5.6.0 built for i386-linux and it
  doesn't work too
 
  Thanks for any help,
  -
   -- Bruno Negrão -- Suporte
   -- Plugway Acesso Internet Ltda.
   -- (31)34812311
 



 --
 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: CGI simple but not working

2002-10-04 Thread Bruno Negrao - Perl List

No Richard, just in this script. The other cgi examples are correct.


 Is this the way it is printed in your book? Did they switch q and p all
over
 the book?


 Bruno Negrao - Perl List [EMAIL PROTECTED] wrote in message
 001e01c26ba7$4b219e00$5100a8c0@egp">news:001e01c26ba7$4b219e00$5100a8c0@egp...
  Hi all, the problem is that the script is really erroneous. Where you
read
  q(... should be p( ...
  The p() function is a part of the CGI.pm modules and stands for a new
  paragraph.
 
  the right script is:
  #!/usr/bin/perl -w
  # cgi-bin/ice_cream: program to answer *and generate* ice cream
  # favorite flavor form (version 3)
  use CGI qw(:standard);
  my $favorite = param(flavor);
  print header, start_html(Hello Ice Cream), h1(Hello Ice Cream);
  if ($favorite) {
  print p(Your favorite flavor is $favorite.);
  } else {
  print hr, start_form; # hr() emits html horizontal rule: HR
  print p(Please select a flavor: , textfield(flavor,mint));
  print end_form, hr;
  }
 
 
  Thanks,
  bnegrao.
 
 
  - Original Message -
  From: Richard Krause [EMAIL PROTECTED]
  To: [EMAIL PROTECTED]
  Sent: Friday, October 04, 2002 6:07 AM
  Subject: Re: CGI simple but not working
 
 
   Hi Bruno
  
   It's the print q-Statement, if you write it like this, it works:
  
   #!/usr/bin/perl -w
  
   use diagnostics;
   use strict;
   use CGI qw(:standard);
  
   my $favorite = param(flavor);
   print header, start_html(Hello Ice Cream), h1(Hello Ice Cream);
   if ($favorite) {
   print q(Your favorite flavor is $favorite.);
   } else {
   print start_form,
   Please select a flavor: , textfield(flavor,mint);
   print end_form, hr;
   };
   exit;
  
   I'm new to perl myself, so haven't found out why textfields aren't
 working
   with print q. Please let me know if you find out.
  
   Best Regards
   Richard
  
  
  
   Bruno Negrao - Perl List [EMAIL PROTECTED] wrote in
message
   006d01c26b41$fa4d2040$5100a8c0@egp">news:006d01c26b41$fa4d2040$5100a8c0@egp...
Hi all,
I'm studying the Learning Perl Second Edition and I'm learning cgi
  now.
   
The book presents a sample cgi that doesn't produces the expected
 result
   as
the book says it would. In sumary, this script should generate an
one
   field
form with a default value - mint. But what appears in the screen
are
  the
strings inside the q() function.
   
Could someone test it and say to me if there is something wrong?
   
The following script was retired from the section 19.6  Form
  Generation.
#!/usr/bin/perl -w
# cgi-bin/ice_cream: program to answer *and generate* ice cream
# favorite flavor form (version 3)
use CGI qw(:standard);
my $favorite = param(flavor);
print header, start_html(Hello Ice Cream), h1(Hello Ice Cream);
if ($favorite) {
print q(Your favorite flavor is $favorite.);
} else {
print hr, start_form; # hr() emits html horizontal rule: HR
print q(Please select a flavor: , textfield(flavor,mint));
print end_form, hr;
}
   
I'm running Redhat 6.2 perl version 5.005_03 built for i386-linux
But i tested this script with RH7.2 v5.6.0 built for i386-linux and
it
doesn't work too
   
Thanks for any help,
-
 -- Bruno Negrão -- Suporte
 -- Plugway Acesso Internet Ltda.
 -- (31)34812311
   
  
  
  
   --
   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]




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




Re: Regular expression

2002-10-04 Thread Bruno Negrao - Perl List

 Hi Javeed ,

 the last element of the array is $attt[$#attt]. If you have one line per
 element, that should do it.
Right. This is the easiest way. But, just to answer him, what he could do
using regular expression could be something like:
foreach (@attt) {
/=/  ( ($out) = (split (/=/))[1] );
}

Bruno.



 R

 At 14:24 04/10/2002 +0530, Javeed SAR wrote:

 I have the following output in array @attt
 I want the last line in a variable $out.
 What should the regular expression be?
 
 
 attribute type SYNC_CHECK
created 04-Oct-02.09:36:42 by javeed.clearuser@BLRK35ED
for testing
owner: HIS\javeed
group: HIS\clearuser
scope: this VOB (ordinary type)
value type: string
Attributes:
  SYNC_CHECK = HELLO
 
 
 Regards
 j


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




CGI simple but not working

2002-10-03 Thread Bruno Negrao - Perl List

Hi all,
I'm studying the Learning Perl Second Edition and I'm learning cgi now.

The book presents a sample cgi that doesn't produces the expected result as
the book says it would. In sumary, this script should generate an one field
form with a default value - mint. But what appears in the screen are the
strings inside the q() function.

Could someone test it and say to me if there is something wrong?

The following script was retired from the section 19.6  Form Generation.
#!/usr/bin/perl -w
# cgi-bin/ice_cream: program to answer *and generate* ice cream
# favorite flavor form (version 3)
use CGI qw(:standard);
my $favorite = param(flavor);
print header, start_html(Hello Ice Cream), h1(Hello Ice Cream);
if ($favorite) {
print q(Your favorite flavor is $favorite.);
} else {
print hr, start_form; # hr() emits html horizontal rule: HR
print q(Please select a flavor: , textfield(flavor,mint));
print end_form, hr;
}

I'm running Redhat 6.2 perl version 5.005_03 built for i386-linux
But i tested this script with RH7.2 v5.6.0 built for i386-linux and it
doesn't work too

Thanks for any help,
-
 -- Bruno Negrão -- Suporte
 -- Plugway Acesso Internet Ltda.
 -- (31)34812311


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




CGI simple but not working

2002-10-03 Thread Bruno Negrao - Perl List

Hi all,
I'm studying the Learning Perl Second Edition and I'm learning cgi now.

The book presents a sample cgi that doesn't produces the expected result as
the book says it would.
Could someone test it and say to me if there is something wrong?

The following script was retired from the section 19.6  Form Generation.
#!/usr/bin/perl -w
# cgi-bin/ice_cream: program to answer *and generate* ice cream
# favorite flavor form (version 3)
use CGI qw(:standard);
my $favorite = param(flavor);
print header, start_html(Hello Ice Cream), h1(Hello Ice Cream);
if ($favorite) {
print q(Your favorite flavor is $favorite.);
} else {
print hr, start_form; # hr() emits html horizontal rule: HR
print q(Please select a flavor: , textfield(flavor,mint));
print end_form, hr;
}


Thanks for any help,
-
 -- Bruno Negrão -- Suporte
 -- Plugway Acesso Internet Ltda.
 -- (31)34812311


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




Re: CGI simple but not working

2002-10-03 Thread Bruno Negrao - Perl List

Hello Nathanael and other guys,
 First of all, if possible, use the Llama 3rd, not 2nd.
It's not... :-(

 Second, can you give the expected output and the actual output.
I tried to send the pictures to this list but my e-mail was rejected as it
grew upon 5 bytes
In sumary, this script should generate an one field form. But what appears
in the screen are the strings inside the q() function.

 What platform are you on, what version of perl are you using, etc?
Redhat 6.2 perl version 5.005_03 built for i386-linux
But i tested this script with RH7.2 v5.6.0 built for i386-linux and it
doesn't work too

Thanks
Bruno.
 Nathanael

 Ain't no blood in my body, it's liquid soul in my veins
 ~Roots Manuva


 --
 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: CGI simple but not working - I discovered

2002-10-03 Thread Bruno Negrao - Perl List

Hi all, the problem is that the script is really erroneous. Where you read
q(... should be p( ...
The p() function is a part of the CGI.pm modules and stands for a new
paragraph.

the right script is:
#!/usr/bin/perl -w
# cgi-bin/ice_cream: program to answer *and generate* ice cream
# favorite flavor form (version 3)
use CGI qw(:standard);
my $favorite = param(flavor);
print header, start_html(Hello Ice Cream), h1(Hello Ice Cream);
if ($favorite) {
print p(Your favorite flavor is $favorite.);
} else {
print hr, start_form; # hr() emits html horizontal rule: HR
print p(Please select a flavor: , textfield(flavor,mint));
print end_form, hr;
}


Thanks,
bnegrao.

- Original Message -
From: Bruno Negrao - Perl List [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Sent: Thursday, October 03, 2002 9:44 PM
Subject: Re: CGI simple but not working


 Hello Nathanael and other guys,
  First of all, if possible, use the Llama 3rd, not 2nd.
 It's not... :-(

  Second, can you give the expected output and the actual output.
 I tried to send the pictures to this list but my e-mail was rejected as it
 grew upon 5 bytes
 In sumary, this script should generate an one field form. But what appears
 in the screen are the strings inside the q() function.

  What platform are you on, what version of perl are you using, etc?
 Redhat 6.2 perl version 5.005_03 built for i386-linux
 But i tested this script with RH7.2 v5.6.0 built for i386-linux and it
 doesn't work too

 Thanks
 Bruno.
  Nathanael
 
  Ain't no blood in my body, it's liquid soul in my veins
  ~Roots Manuva
 
 
  --
  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]




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




Re: dbmopen can't open /etc/aliases.db file

2002-09-27 Thread Bruno Negrao - Perl List

Hi Michael,  the problem is not with the undef value - undef is fine - if
you read the dbmopen's documentation you could see it.

If I choose a value like 0644 the script still doesn't work.
Bellow, is the output of the execution of the same program, but with 0644 in
place of undef:

Uncaught exception from user code:
No aliases!: Invalid argument at ./zz line 3.

I must admit that the errors are shorter but the program still doesn't
work!!
Oh, hell!!!

Thank you for any help,
bnegrao.


- Original Message -
From: Michael Kelly [EMAIL PROTECTED]
To: Perl Beginners List [EMAIL PROTECTED]
Sent: Friday, September 27, 2002 1:04 AM
Subject: Re: dbmopen can't open /etc/aliases.db file


 On Thu, Sep 26, 2002 at 09:38:18PM -0300, Bruno Negrao - Perl List wrote:
  Hi,

 Hi Bruno,

  I'm triyng to open the /etc/aliases.db file for reading with the dbmopen
  function - the result is that I can't open the file for reading, or
  something like this. yes, I have permission because I'm root.
 
  My script is:
  #!/usr/bin/perl -w
  use diagnostics;
  dbmopen(%ALIAS,'/etc/aliases',undef) ||
  die No aliases!: $!;
  while (($key,$value) = each(%ALIAS)) {
  chop($key,$value);
  print $key $value\n;
  }

 Disclaimer: I've never messed around with dbmopen() before, so I can't
test this
 example, but seeing as nobody with more authority has answered this yet,
I'll
 give it a shot:

 dbmopen() expects a file permission mask (an octal number) as its third
argument,
 which 'undef' is not. You might try something like this as your lines 3
and 4:

 dbmopen(%ALIAS,'/etc/aliases', 0644) ||
 die No aliases!: $!;

 Even if you're sure /etc/aliases is there, that should make dbmopen()
happy.

 Again, not sure if that's the answer, but it seems logical to me,
 --
 Michael

 --
 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: dbmopen can't open /etc/aliases.db file

2002-09-27 Thread Bruno Negrao - Perl List

Thank you nkuipers for answering.

I already tried declaring variables with my, i already checked the path, i
tested the hash with another name - all this doesn't make difference.

To me, it seems that my /etc/aliases.db in written in a format uncompatible
with the dbmopen().

I'm on the 17 chapter of the book Learning Perl second edition and I'm
stuck in this problem. (to open the /etc/aliases.db file for reading is an
exercise of the chapter 17).

If somebody there has a server runing Sendmail, you have the aliases.db file
too.

Moreover to simply solve this exercise, i'd like to know it the dbmopen()
really works with my system files.

Thanks for any help,
Bruno.


- Original Message -
From: nkuipers [EMAIL PROTECTED]
To: Bruno Negrao - Perl List [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Sent: Friday, September 27, 2002 12:30 PM
Subject: RE: dbmopen can't open /etc/aliases.db file


 Uncaught exception from user code:
 No aliases!: Invalid argument at ./zz line 3.

 Well you have three arguments.  If you are *sure* that the undef is not
the
 problem, that leaves only two to possibly be invalid.  To start, try
battening
 down the hatches with use strict, predeclaring your vars with my.  Does
using
 a hash NOT called ALIAS make a difference (the implication being maybe
that is
 somehow a reserved identifier for hashes on your system or distro)?  Are
you
 *sure* that the path specified in the dbmopen call is 100% correct?  Dumb,
 dumb questions but most problems in programming turn out to be really
stupid,
 and it doesn't hurt to brainstorm and try anything.


 
 I must admit that the errors are shorter but the program still doesn't
 work!!
 Oh, hell!!!
 
 Thank you for any help,
 bnegrao.
 
 
 - Original Message -
 From: Michael Kelly [EMAIL PROTECTED]
 To: Perl Beginners List [EMAIL PROTECTED]
 Sent: Friday, September 27, 2002 1:04 AM
 Subject: Re: dbmopen can't open /etc/aliases.db file
 
 
  On Thu, Sep 26, 2002 at 09:38:18PM -0300, Bruno Negrao - Perl List
wrote:
   Hi,
 
  Hi Bruno,
 
   I'm triyng to open the /etc/aliases.db file for reading with the
dbmopen
   function - the result is that I can't open the file for reading, or
   something like this. yes, I have permission because I'm root.
  
   My script is:
   #!/usr/bin/perl -w
   use diagnostics;
   dbmopen(%ALIAS,'/etc/aliases',undef) ||
   die No aliases!: $!;
   while (($key,$value) = each(%ALIAS)) {
   chop($key,$value);
   print $key $value\n;
   }
 
  Disclaimer: I've never messed around with dbmopen() before, so I can't
 test this
  example, but seeing as nobody with more authority has answered this
yet,
 I'll
  give it a shot:
 
  dbmopen() expects a file permission mask (an octal number) as its third
 argument,
  which 'undef' is not. You might try something like this as your lines 3
 and 4:
 
  dbmopen(%ALIAS,'/etc/aliases', 0644) ||
  die No aliases!: $!;
 
  Even if you're sure /etc/aliases is there, that should make dbmopen()
 happy.
 
  Again, not sure if that's the answer, but it seems logical to me,
  --
  Michael
 
  --
  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]




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




Re: dbmopen can't open /etc/aliases.db file

2002-09-27 Thread Bruno Negrao - Perl List

Thank you nkuipers for answering.

I already tried declaring variables with my, i already checked the path, i
tested the hash with another name - all this doesn't make difference.

To me, it seems that my /etc/aliases.db in written in a format uncompatible
with the dbmopen().

I'm on the 17 chapter of the book Learning Perl second edition and I'm
stuck in this problem. (to open the /etc/aliases.db file for reading is an
exercise of the chapter 17).

If somebody there has a server runing Sendmail, you have the aliases.db file
too.

Moreover to simply solve this exercise, i'd like to know it the dbmopen()
really works with my system files.

Thanks for any help,
Bruno.


- Original Message -
From: nkuipers [EMAIL PROTECTED]
To: Bruno Negrao - Perl List [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Sent: Friday, September 27, 2002 12:30 PM
Subject: RE: dbmopen can't open /etc/aliases.db file


 Uncaught exception from user code:
 No aliases!: Invalid argument at ./zz line 3.

 Well you have three arguments.  If you are *sure* that the undef is not
the
 problem, that leaves only two to possibly be invalid.  To start, try
battening
 down the hatches with use strict, predeclaring your vars with my.  Does
using
 a hash NOT called ALIAS make a difference (the implication being maybe
that is
 somehow a reserved identifier for hashes on your system or distro)?  Are
you
 *sure* that the path specified in the dbmopen call is 100% correct?  Dumb,
 dumb questions but most problems in programming turn out to be really
stupid,
 and it doesn't hurt to brainstorm and try anything.


 
 I must admit that the errors are shorter but the program still doesn't
 work!!
 Oh, hell!!!
 
 Thank you for any help,
 bnegrao.
 
 
 - Original Message -
 From: Michael Kelly [EMAIL PROTECTED]
 To: Perl Beginners List [EMAIL PROTECTED]
 Sent: Friday, September 27, 2002 1:04 AM
 Subject: Re: dbmopen can't open /etc/aliases.db file
 
 
  On Thu, Sep 26, 2002 at 09:38:18PM -0300, Bruno Negrao - Perl List
wrote:
   Hi,
 
  Hi Bruno,
 
   I'm triyng to open the /etc/aliases.db file for reading with the
dbmopen
   function - the result is that I can't open the file for reading, or
   something like this. yes, I have permission because I'm root.
  
   My script is:
   #!/usr/bin/perl -w
   use diagnostics;
   dbmopen(%ALIAS,'/etc/aliases',undef) ||
   die No aliases!: $!;
   while (($key,$value) = each(%ALIAS)) {
   chop($key,$value);
   print $key $value\n;
   }
 
  Disclaimer: I've never messed around with dbmopen() before, so I can't
 test this
  example, but seeing as nobody with more authority has answered this
yet,
 I'll
  give it a shot:
 
  dbmopen() expects a file permission mask (an octal number) as its third
 argument,
  which 'undef' is not. You might try something like this as your lines 3
 and 4:
 
  dbmopen(%ALIAS,'/etc/aliases', 0644) ||
  die No aliases!: $!;
 
  Even if you're sure /etc/aliases is there, that should make dbmopen()
 happy.
 
  Again, not sure if that's the answer, but it seems logical to me,
  --
  Michael
 
  --
  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]




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




Re: dbmopen can't open /etc/aliases.db file

2002-09-27 Thread Bruno Negrao - Perl List

Ok david.

Could you send me a code example of a database file being opened for reading
with tie?

thanks,
bnegrao.
- Original Message -
From: david [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Friday, September 27, 2002 2:41 PM
Subject: Re: dbmopen can't open /etc/aliases.db file


 Bruno Negrao - Perl List wrote:

  Hi Michael,  the problem is not with the undef value - undef is fine -
  if you read the dbmopen's documentation you could see it.
 
  If I choose a value like 0644 the script still doesn't work.
  Bellow, is the output of the execution of the same program, but with
0644
  in place of undef:
 
  Uncaught exception from user code:
  No aliases!: Invalid argument at ./zz line 3.
 
  I must admit that the errors are shorter but the program still doesn't
  work!!
  Oh, hell!!!
 

 the dbmopen function has been largely superseded by the tie function.
 you shouldn't use it in the first place.

 in older version of Perl or that your system do not support DBM or ndbm,
 calling dbmopen generates a fatal error and it tries the sdbm calls.

 try eval{ dbmopen(..) } and check the $@ error

 if you can, try not to use dbmopen at all, tie is better, safer and
faster.

 david

 --
 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: dbmopen can't open /etc/aliases.db file

2002-09-27 Thread Bruno Negrao - Perl List

Yeah it worked! I simply changed the '/usr/lib/news/history' for
'/etc/aliases' and
the script showed the file contents.
But, why? Why dbmopen didn't work?

thanks,
Bruno.
- Original Message -
From: david [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Friday, September 27, 2002 3:49 PM
Subject: Re: dbmopen can't open /etc/aliases.db file


 Bruno Negrao - Perl List wrote:

  Ok david.
 
  Could you send me a code example of a database file being opened for
  reading with tie?
 
  thanks,
  bnegrao.

 use NDBM_File;
 tie(%HIST, 'NDBM_File', '/usr/lib/news/history', 1, 0);
 while (($key,$val) = each %HIST) {
 print $key, ' = ', unpack('L',$val), \n;
 }
 untie(%HIST);

 this example is directly from perldoc -f tie

 david

 --
 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: autoftp

2002-09-27 Thread Bruno Negrao - Perl List

Yes. Exist the Net::FTP module. The following text comes from the Oreilly's
book Perl in a Nutshell

16.2 Net::FTP
Net::FTP is used to transfer files from remote hosts. Using Net::FTP, you
can write simple FTP clients that transfer files from remote servers based
on information passed on the command line or from hard-coded variables. Here
is an example of a client that connects to a remote FTP server and gets a
file from the server:

#!/usr/local/bin/perl -w

use Net::FTP;

$hostname = 'remotehost.com';
$username = 'anonymous';
$password = '[EMAIL PROTECTED]';

# Hardcode the directory and filename to get
$home = '/pub';
$filename = 'TESTFILE';

# Open the connection to the host
$ftp = Net::FTP-new($hostname); # construct object
$ftp-login($username, $password);   # log in

$ftp-cwd($home),\n;   # change directory
print $ftp-ls($home),\n;

# Now get the file and leave
$ftp-get($filename);
$ftp-quit;
FTP clients have also been integrated with most World Wide Web browsers,
using ftp:// in place of http://. When the URL points to a directory, the
browser displays a listing of the directory, where each filename is a link
to that file. When the URL points directly to a file, the remote file is
downloaded.

Here's an example that uses Net::FTP to list files from a remote FTP server
on a web page, with a link from each file to the URL of the file on the
remote site:

#!/usr/local/bin/perl -w

use Net::FTP;

$hostname = 'remotehost.com';   # ftp host
$username = 'anonymous';# username
$password = '[EMAIL PROTECTED]';  # password
$home = '/pub';

$ftp = Net::FTP-new($hostname);# Net::FTP constructor
$ftp-login($username, $password);  # log in w/username and password

$pwd = $ftp-pwd;   # get current directory

# Now, output HTML page.
print HTML;
Content-type: text/html
HTML

  HEAD
TITLEDownload Files/TITLE
  /HEAD
  BODY

  BCurrent working directory:/B $pwdBR
  Files to download: P
HTML

@entries = $ftp-ls($home);   # slurp all entries into an array
foreach (@entries) { # now, output links for all files in the ftp area
 # as links
print INPUT TYPE=hidden NAME=\files\ VALUE=\$_\\n;
print A HREF=\ftp://$hostname$_\;,
IMG SRC=\http://www/icons/f.gif\; border=0\n;
print  $_/ABR\n;
}
print HTML;
  /BODY
/HTML
HTML
$ftp-quit; # end FTP session
The Net::FTP module implements a subset (as shown earlier in this chapter)
of the FTP protocol as defined in RFC 959. In addition to providing the
methods shown below, the module inherits from Net::Cmd. Some of the Net::FTP
methods return an object derived from the dataconn class (which is in turn
derived from the IO::Socket::INET class), as noted in the entries for those
methods.

The following methods are defined by Net::FTP:

new
abort
appe
append
authorize
ascii
binary
byte
cdup
cwd
delete
dir
ebcdic
get
list
login
ls
mdtm
mkdir
nlst
pasv
pasv_wait
pasv_xfer
pasv_xfer_unique
port
put
put_unique
pwd
quit
quot
rename
retr
rmdir
size
stor
stou
supported
type
unique_name


- Original Message -
From: William Black [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Friday, September 27, 2002 3:23 PM
Subject: re: autoftp


 Hello All,

 Does anyone know if perl offers an autoftp module?  If they do what is it
 and how does it work.

 Cheers,

 William Black



 _
 Chat with friends online, try MSN Messenger: http://messenger.msn.com


 --
 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 can't open /etc/aliases.db file

2002-09-26 Thread Bruno Negrao - Perl List

Hi,
I'm triyng to open the /etc/aliases.db file for reading with the dbmopen
function - the result is that I can't open the file for reading, or
something like this. yes, I have permission because I'm root.

My script is:
#!/usr/bin/perl -w
use diagnostics;
dbmopen(%ALIAS,'/etc/aliases',undef) ||
die No aliases!: $!;
while (($key,$value) = each(%ALIAS)) {
chop($key,$value);
print $key $value\n;
}

the output error is:
###
Use of uninitialized value in dbmopen at ./zz line 3 (#1)

(W uninitialized) An undefined value was used as if it were already
defined.
  It was
interpreted as a  or a 0, but maybe it was a mistake.  To suppress
this
warning assign a defined value to your variables.

Use of uninitialized value in null operation at ./zz line 3 (#1)
Uncaught exception from user code:
No aliases!: Invalid argument at ./zz line 3.

Does someone could explain me why is it happening?
(i'm using perl 5.6.0 and Red Hal linux 7.2)

Thank you,
-
 -- Bruno Negrão -- Suporte
 -- Plugway Acesso Internet Ltda.



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




dbmopen doesn't work

2002-09-25 Thread Bruno Negrao

Hi all,
Could someone say to me why this program doesn't run? (it doesn't print the database 
values)

#!/usr/bin/perl -w
dbmopen(%a,testdb,0666) || die couldn't create/access the file $!;
$a = $b = 0;
until ($a  20){# create items in the testdb.db file
$a{key$a} = $b;
$a = $b++;
}
while ( ($key,$value) = each(%a) ) {
print $key $value\n;   # this is not printing anything!!
}

I'm using a RedHat 6.2. Perl 5.

thank you,
-
 -- Bruno Negrão -- Suporte
 -- Plugway Acesso Internet Ltda.
 -- (31)34812311