Re: Net::SSH::Perl

2003-09-04 Thread zentara
On Wed, 3 Sep 2003 12:54:07 +0800, [EMAIL PROTECTED] (Jaws) wrote:

Hi all,

I am currently using Net::SSH::Perl module to login in my remote machine.
Below is my code:

==
#!/usr/bin/perl

use Net::SSH::Perl;

$user=jaws;
$pass=password;
$host=111.222.333.444;

my $ssh = Net::SSH::Perl-new($host,'1,2');
$ssh-login($user, $pass);
$ssh-cmd(my_command);
==

the output of the last line requires me to input username and password. How
can do it using this module? I've tried to search in the manual of the
package but i didn't find one to answer my question and even in the web so i
decided to ask help from you.

#!/usr/bin/perl
use strict;
use warnings;
use Net::SSH::Perl;

my $user = zz;
my $password = ztest;
my @hosts = qw(localhost zentara.zentara.net);

foreach my $host (@hosts){
my $cmd = /usr/bin/uptime;
my $ssh = Net::SSH::Perl-new( $host, port = 22 ,debug = 1);
$ssh-login($user,$password);

my($out) = $ssh-cmd($cmd);
my ($time,$uptime) = (split /\s+/,$out)[1,3];
chop $uptime;
print $out\n;
print $host has been up $uptime\n;
}
 




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



Re: Storing encrypted data

2003-08-31 Thread zentara
On 30 Aug 2003 23:15:03 -0400, [EMAIL PROTECTED] (K Old) wrote:

Hello everyone,

I'm in need of storing a few pieces of text in a text file on my server
and want to keep it encrypted, but not permission restricted as Apache
will need to read it and my webserver runs as the nobody user.

I'm using the Business::OnlinePayment::AuthorizeNet module to process
transactions, and would like a secure way to store my transaction-key on
my server, rather than keeping it as plain text in my perl script.

It looks something like: N5GjgbQ32au8X3kf (16 characters A-Za-z0-9)

I've looked at several of the encryption modules and am looking for
suggestions of modules to use.  I have been looking at Crypt::Blowfish
and it seems to serve my purpose, but I have a few questions.

using this code from the Blowfish module page:

   my $key = pack(H16, 0123456789ABCDEF);  # min. 8 bytes
   my $cipher = new Crypt::Blowfish $key;
   my $ciphertext = $cipher-encrypt(plaintex);  # SEE NOTES 
   print unpack(H16, $ciphertext), \n;

If I were to store $ciphertext in a text file on my server and when I need it
run unpack using the $key, wouldn't someone who had the $key be able to decrypt
whatever the $ciphertext is?

Basically I need to have a perl script accessable from the web, yet keep anyone
on the server from from being able to view the $key.

Does any of this make sense?

Anyone have ideas?

Yeah, you are running into a common problem which people who run on
remote servers face. The people who have root on the server, will be
able to read your key.  Can you trust them, or their security? About all
you can do is try to obfuscate the password, so that it will take a
clever user to de-obfuscate it.  For the most part, all you really need
to do is be able to demonstrate that you were not negligent in letting
others see the cc data.  So use the blowfish to encrypt the data, then
work on a way of making a cracker jump thru about 6 hoops to get at
your $key.
Hopefully one day, we will all have fiber-optic lines into our homes,
and can run our own servers, and provide our own security, and be 
root ourselves.

Something like Acme::Bleach would be a first step toward hiding $key,
and there are other sneaky methods. Be creative, change module names,
so it's confusing. Use alot of layers.

I've liked this little script compiler
http://www.datsi.fi.upm.es/~frosal

It takes your perl code and encrypts it and makes it a c program.
It can be broken by a smart perl hacker, but it does hide your keys
from the casual observer. Use it to encrypt a script which outputs
the key when called. Do something sneaky, like only output the
correct key if you feed it certain things on the command line, which
change constantly. Be creative as you can be, maybe log each time
it is run, so you can detect hacking attempts, have it only work if run
from a certain directory, etc, etc.

Good luck.


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



Re: Managing Pictures with Perl

2003-08-30 Thread zentara
On Fri, 29 Aug 2003 18:19:23 -0300, [EMAIL PROTECTED] (Geraldo Milagre)
wrote:

Hi,

I would like to write a program to manage my pictures colection and 
generate statics html pages for view the pics. I would like to use Perl 
to do this, as a way to learning more about the language. What resources 
from Perl do you suggest I to use? What is the best library to handle 
pictures?

Well it would be a great learning experience for you to write such a
script, but if you want one that works well, and is ready-2-go, try iGal
http://www.stanford.edu/~epop/igal/



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



Re: Outputting the status while the processes are running

2003-08-27 Thread zentara
On Tue, 26 Aug 2003 23:35:52 +0530, [EMAIL PROTECTED] (T.S.Ravi
Shankar) wrote:

:  I would like to see the status after every 50 runs in a separate
file.  But the following code doesn't look like outputting any thing to
the statusfile,  when the processes are going on for different
combinations.  How can I achieve that ???  What mistakes I am committing
here ??


open(STATUS,statusfile)
foreach $set1 (@arr1) {
foreach $set2 (@arr2) {
..
..
foreach $set15 (@arr15) {
ENV{xxx} = $set1;
..
.
ENV{ccc} = $set15;
$counter++; # counter for the number of combinations
if (($counter % 50) ==0)  { genstatus; }
$pid = fork;
if($pid == 0) {
  exec(PROCESS);
}else{
  $pid1=wait;
}

sub genstatus {
$|=1;
 Print STATUS  \n $counter iterations over \n;
}

Maybe your output needs to be unbuffered?



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



Re: why this is not working ??

2003-08-27 Thread zentara
On Wed, 27 Aug 2003 11:18:26 +0530, [EMAIL PROTECTED] (T.S.Ravi
Shankar) wrote:

open(STATUS, status.txt);
for ($i=0; $i=98985;$i++) {
  system (process);
  if (($i%10)==0) 
{ print STATUS \n\n  $i iterations over !!*\n\n; }
  }
close(STATUS);

-

status.txt  remains empty when the processes are run  the whole file
is written only at the end of all iterations, which serves no purpose !!

Could you please help me out in solving this problem ??

Turn off buffering!.
Look at this script to demonstrate.
#
#!/usr/bin/perl
#without a newline, it won't print 
#until the buffer is 2k 

#$|=1;  # try it with and without this line :-) 

while (1){
print 'aa';
select(undef,undef,undef,.03);
}
###


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



Re: Secure Form Submission

2003-08-23 Thread zentara
On Fri, 22 Aug 2003 20:10:37 +, [EMAIL PROTECTED]
(Greenhalgh David) wrote:


Thanks for that. The MD5 is a one way hash, unfortunately. I need to be 
able to decrypt at the server side.

I agree about SSL, unfortunately my client's host (borrowed space on a 
non-commercial server) only has 2 IPs for SSL and both are filled until 
the system upgrade late this year. What I am looking for is a fill in 
solution that will allow  some form of secure transmission of personal 
information (not a password) until the SSL becomes available.

Well you could always use Perl scripts, and setup some socket
connections. You could just ask the client to download a small
script and run it, which do a safe transfer.
It could be done alot of ways. The downloaded perl script could be
run to encrypt a file with rc4, then the client could upload the
results.  The MD5 password method would give you a way to
exchange an initial password safely, then that password could be used
by both sides for the rc4 password.






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



Re: Secure Form Submission

2003-08-22 Thread zentara
On Fri, 22 Aug 2003 05:48:14 +, [EMAIL PROTECTED]
(Greenhalgh David) wrote:

Hi All,

I need to implement a form that is submitted securely. My client does 
not have access to SSL on his host. I was thinking in terms of a 
session cookie with a client side RC4 encrypt and a decrypt in the Perl 
script. Do peoople here consider that to be a secure scenario, or is 
there another method that you could recommend? The encryption needs to 
be reversible.

There is a method using javascript
http://sourceforge.net/projects/perl-md5-login/

It sends a timed out temporary key, which some javascript uses
to encrypt the post.

It's soo much better to use SSL.




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



Re: Premature end of script headers Linux with Fat32 filesystem

2003-08-18 Thread zentara
On Thu, 14 Aug 2003 16:16:23 -0500, [EMAIL PROTECTED] (Tim Brom)
wrote:

I dual-boot my computer and I have three partitions, an NTFS partition 
for Windows XP Pro, an ext3 filesystem for Linux (Red Hat Linux 9.0) and 
a Fat32 filesystem for my data (because FAT32 is the only filesystem 
both OS's play nicely with). I keep the data that I want shared stored 
on this FAT32 partition, including all the files for my websites. 
Whenever I try to access a script off of the FAT32 partition, I get a 
'Premature end of script headers' error message. I can copy the script 
verbatim onto the ext3 filesystem and it works fine, and it works fine 
on my web host's server. Does anyone know why I am getting this error 
message only when the file is coming from a FAT32 filesystem? Thanks.

It seems probable that it's a permissions problem. Maybe the fat32
partition isn't mounted to be executable by the web server. Most web
servers are run as nobody:nogroup  so your fat32 partition would need to
be mode 777.  How do you mount it?
In /etc/fstab you need to put a umask=000  for the mount point of the
fat32 partition.
/dev/hda7  /mnt/fat32vfatrw,noauto,user,umask=000,quiet


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



Re: Perl script to ssh to other machine.

2003-08-18 Thread zentara
On Sat, 16 Aug 2003 17:25:15 -0700 (PDT), [EMAIL PROTECTED] (Titu Kim)
wrote:

Hi,
   Thanks for your reply. My purpose is not only to
run uptime. I need to write a script to log into other
machines to grep the log file contents. Now, I log in
one by one and grep the log. I want to use the script
to log into all machine automatically to do this job.
Do you have any suggestion to do this?
#!/usr/bin/perl
use strict;
use warnings;
use Net::SSH::Perl;

my %hostdata= (
'localhost' = {
   user  = zz,
   password  = zfoo,
   cmdtorun  = ls -la,
  misc_data  = [],
},


   'zentara.zentara.net' = {
   user  = zz,
   password  = zbar,
   cmdtorun  = /usr/bin/uptime,
  misc_data  = [],
},


);

foreach my $host (keys %hostdata) {
my $ssh = Net::SSH::Perl-new($host, port = 22);   #, debug = 1 );
$ssh-login($hostdata{$host}{user},$hostdata{$host}{password} );

my ($out) = $ssh-cmd($hostdata{$host}{cmdtorun});
print $out\n;
}




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



Re: Why executable?

2003-08-14 Thread zentara
On Mon, 11 Aug 2003 11:33:40 +0300, [EMAIL PROTECTED] (Octavian Rasnita)
wrote:

Hi all,

Does anyone know why the perl scripts need to have the execute permission
under Unix?

I am asking this because I've seen that the PHP files don't need this
permission.

Couldn't perl just read a text file (doesn't matter if it has an execute
permission or not), interpret it and execute it just like PHP does with its
programs?

perl scripts can be done the same way

You can take any perl script, and remove the shebang line, chmod it to
644 , and run it like perl scriptname

The way PHP is setup, the PHP interpreter is executable and calls it's
readonly scripts.



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



Re: How to replace a long string in a text file?

2003-08-14 Thread zentara
On Tue, 12 Aug 2003 01:29:39 -0400 (EDT), [EMAIL PROTECTED]
(Perlwannabe) wrote:

Here is the little script that I am working with and, obviously, is not
working:

my $filefirst = c:/perl/myfile.txt;
open(FILE,$filefirst) || die Could not open file for reading!  $!;
open(TEMP,$filefirst.tmp) || die Could not open file for writing!  $!;

#are you using windows?
binmode FILE;   #need binmode under windows
binmode TEMP;

# I have used the . . . to show that the entire hex string is really there
my $hextostr = '\x54\x68\x69\x73 . . . \x79\x2E\x22';
while(FILE){
   $_ =~ s/$hextostr/placey/gi;
   print TEMP $_;
}


Perhaps I am attacking this problem wrong by using hex, but it seems
easier to use then text which has carriage returns, tabs, and spaces.

I hope this explains the situation.



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



Re: pid-memory usage - Any takers

2003-08-12 Thread zentara
On Fri, 8 Aug 2003 09:06:25 -0400, [EMAIL PROTECTED] (Stephen
Gilbert) wrote:

 -Original Message-
 From: Biju Ramachandran [mailto:[EMAIL PROTECTED]
 Subject: Re: pid-memory usage - Any takers
 Please, anybody...

 I just  want to know is there any way to find out the PID 
 ans how much a 
 process is using
 the physical and virtual memory, as it is show by the 
 Windows NT task 
 manager.

Well your Process id is $$, But I haven't any ideas on retieving the physical/virtual 
mem.

You ought to be looking at the Proc::ProcessTable module.
I don't know about your NT requirement, but the following
is a sample that works well under linux.

#!/usr/bin/perl -w
use strict;
use Proc::ProcessTable;

my $t = new Proc::ProcessTable();

foreach my $p (@{$t-table}){
print $p-pid, ,$p-cmndline, ,$p-size,\n;
}
__END__



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



Re: Closing window in Perl/Tk

2003-08-10 Thread zentara
On Fri, 08 Aug 2003 11:07:53 +0530, [EMAIL PROTECTED] (Sachin
Hegde) wrote:

Hi all,
I am writing an UI application inPerl/Tk. I have some functions which I am 
supposed to run before the application closes. How do I calll this function, 
say Funct(), when the user clicks on the close icon of the window?
Sachin

Something like this:
#!/usr/bin/perl
use warnings;
use strict;
use Tk;

my $mw = new MainWindow;
$mw-title(Close test);
$mw-geometry(400x250);

#prevents mw from closing
$mw-protocol('WM_DELETE_WINDOW' = sub { Funct(); exit;}   );

MainLoop;






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



Re: decoding MIME::base64

2003-08-09 Thread zentara
On Thu, 7 Aug 2003 23:39:02 +0200, [EMAIL PROTECTED] (Awards) wrote:

Hi,

maybe i'm using the wrong module, but that is why i'm here asking.
I have downloaded a message with an jpg attachment fine.
But what i want to learn is that we have in the attachment the ugly code.
So I'm on my windows system i have that code and want to change it back to a
picture.

Hi, this works fine under linux. I tried to use your $str but it
was bad. Maybe you need to use binmode in windows?

#!/usr/bin/perl -w
use strict;
use MIME::Base64;

my $str =
qq(/9j/4AAQSkZJRgABAQIASABIAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0a
HBwgJC4nICIsIxwcKDcpLDAxNDQ0Hyc5PTgyPC4zNDL/2wBDAQkJCQwLDBgNDRgyIRwhMjIyMjIy
MjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjL/wAARCAA8AEMDASIA
AhEBAxEB/8QAHgIDAQEAAAQFBwIDCAYB/8QAMBAAAQMCBQMCBQMF
AQIDBAARBQYSITEHUXETYSIyQUKBFTOhI1KRscH/xAAaAQEBAQADAQAAAQIDBQYE
/8QAIxEAAgEDAwQDAAECAwQREyExBRJBkVFSof/aAAwDAQACEQMRAD8Ap5brjgSF
uLUEgBIUomwACRb8ADwB2rCl5bymWgU8k2v2oiyPWGk/OP5oBiiilYkbEsanCJhsZ+S8r5Wo6CtR
97DegGqKZw3LWZpk6RDYwiY69GIS+0WiFNk8A34J+gPNaHW3GHVtPIU242opWhYsUkcgg8GgNa3E
Nga1AXr6CFC4NxUXKe9Z24+UbCm4CiWSD9DtQE07jmKvurdXiMrUo3Ol0pA8AbAew2FFR9FY0ofV
F7n8is9N2QexqPQstrCk8ipd1HqNKR3FQ6klKikixFbIS3qhcYuJ/tJ8V7LpFjWV8Pm4rh2aU6Yu
JMJZD11AJsoK0lSTqAJA3Haq9Ze0sutk7Ebb/WiEtpucwt9OppKwVp7i+9R8A6jVO/UcfmTGMBZm
YEsxnI6npBaccdZvpeSLG4sQAFEXCQeDVV9a1uzsyJxVjBZUGO6wht5x1KbLdBVc3SSPl0jm/wAN
WejGn3mmpGH4Yqdh7qApp2K+gK8FKym1uOT+K8x1CzNHiZUmQMSYaRMmJ0sRQ6HFJTt8a7CwII2t
fgb828pa9avalyoSgmm+E91++POV6OzqWlGNPKb29FA1KQkaI4J+43qOab9V1KO53qZAsABwK9Yd
YFFZBtZFwhVvFFTKGDGkpse49VPP3Cnaxct6ar8WNUELW+HEkT5bUSK0t191QQ22gXKiTYACtFWR
0LQ0vqnh/qtayG3Sg2uEq9NW/wDugLEyX0XzHBw0KxDM8jDC4NRiRPj0+VXtfwD5rxHVLpPiOUo/
64nE14nDccCHXHEkONqPGrc3B7966qqMzBgcPMuAy8HnhRjSkaVaDYixBBHuCAfxWFTgpOSW7K5N
rBxFAaGlTvJ48U7Tmasrzsi5qfwmbct31NPWsHWz8qh/33BFJ1shaLs7qHiTpmwoOMRoz/8AUbai
IfDQB3ukEnY882322tRUE9nTMDjzjjeKS46VqKvSYkOIQm+5skKsB7DaigPF0vMVpjH32pik8Q/b
R5oCPrq3ofktnL+UGsYebviOJoDhUoboa+1I87KPe47VyvHSFyWkngrAP+a71jR24kVmMynS0yhL
aE9kgWAoDbRRRQFc9ZsnR8zZJkzUpAn4W2qSy59SgC60n2IF/IHvXLkVZcjpJ5GxrrzqfNdgdM8f
fZ06zFLXxC+yyEH+FGuQIP7Fve9AW9Iw+JIfU7h+TJaoqrFsuy1sqO290FSrb3+p7+1FQKHXEoAW
UuqAtrW2gqPnaivld3BPGGcmkz//2Q==);

my $decoded = decode_base64($str);
open(F,$0.jpg) or warn $!;
binmode F;
print F $decoded;
close(F);
__END__



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



Re: Flock Test...

2003-08-01 Thread zentara
On Wed, 30 Jul 2003 02:14:45 +0500, [EMAIL PROTECTED] (Sara) wrote:

What could be the simplest test to check 'flock' working on your server or not?

except for writing to support team of host ::))

Thanks for any input.
Start the following script in 2 different terminals or xterms
simultaneously. The first one should hold the lock for 10 seconds,
then the second instance should take over. (If flock works).

#!/usr/bin/perl
use Fcntl ':flock'; # import LOCK_* constants
$|=1;

#run this twice and the second run will not run until first finishes

sub get_lock{
  open(SEM, $semaphore_file) || die Cannot create semaphore: $!;
  flock(SEM, LOCK_EX) || die Lock failed: $!;
}

sub release_lock{ close(SEM);}

$semaphore_file=flock-sub-semfile;
get_lock();

for(1..10){ 
 print got lock;
 sleep 1;
}
#Do something here

release_lock;
__END__



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



Re: Attach inline image in mail using MIME::Parser

2003-07-31 Thread zentara
On Tue, 29 Jul 2003 14:37:51 +0530, [EMAIL PROTECTED] (Ramprasad)
wrote:

Hello all,

   I am confused at using MIME::Parser and adding attachments
When I add an attachment thru MIME::Parser it is show as a seperate 
attachment on all clients
But When I add an inline image thru a mail client I can see it in the 
body of the mail


Can anyone tell me how to attach inline using MIME::Parser
Thanks
Ram

I don't know much about images with MIME::Parser, but if you
use MIME::Lite it's easy to send inline pictures. The trick is the
cid prefix, notice the ID field for the image, and in the html, the
image name is prefixed with cid:  Something similar is needed with
MIME::Parser.

#!/usr/bin/perl -w
# Send HTML document with inline images
use strict;
use MIME::Lite;

# Create a new MIME Lite object
my $msg = MIME::Lite-new(
   From='[EMAIL PROTECTED]',
   To  ='[EMAIL PROTECTED]',
   Subject ='Hi',
   Type='multipart/related');

# Add the body to your HTML message
$msg-attach(Type = 'text/html',
Data = qq{ BODY BGCOLOR=#FF
H2Hi/H2
P ALIGN=left
This is an HTML message.
/P
P ALIGN=left
A HREF=http://foo123.com/;Here's a link/A.
/P
P ALIGN=middle
IMG SRC=cid:2uni2.jpg;
/P
/BODY });

# Attach the image
$msg-attach(Type = 'image/jpg',
   Id   = '2uni2.jpg',
   Path = '2uni2.jpg');

# Send it
$msg-send();






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



Re: Thumb-nailing Pic's

2003-07-26 Thread zentara
On Fri, 25 Jul 2003 07:57:32 -0500, [EMAIL PROTECTED] (Ramon
Chavez) wrote:

Maybe I'm missing something here but, It can be done just using HTML, say...

$h= 250;
$w= 250;

print img src=\yourimage.jpg\ width=\$w\ height=\$h\\n;

Or maybe you're talking about something more complex and at this time in the
morning I can't figure out what is it... ;-)

A problem with your html method is that you still need to download
the original big file to display the thumbnail. One  purpose of
thumbnails is to speed up the download time, so you want real smaller
thumbnail files.





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



Re: apache/cgi/script/beguinner

2003-07-25 Thread zentara
On Fri, 25 Jul 2003 17:59:56 +1000, [EMAIL PROTECTED] (Unknown Sender)
wrote:

I am trying to run a perl cgi script for the first time... under linux 
redhat8. my apache works fine. localhost gives me the test page. I have 
this script (very usual)

#! /usr/bin/perl

#!/usr/local/bin/perl
# hello.pl - My first CGI program

print Content-Type: text/html\n\n;
# Note there is a newline between 
# this header and Data

# Simple HTML code follows

print html head\n;
print titleHello, world!/title;
print /head\n;
print body\n;
print h1Hello, world!/h1\n;
print /body /html\n;


Well the first line is wrong. #! /usr/bin/perl  has a space after
the ! , and also may not be where your perl is located.



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



Re: secure socket connection

2003-07-17 Thread zentara
On Thu, 17 Jul 2003 05:12:16 +, [EMAIL PROTECTED] (Mario Kulka)
wrote:

I'm trying to set up credit card processing and one of the first steps is to 
establish a secure socket connection - how can i do it? (My host does 
support it)

You are not clear which part of the credit card processing you are
talking about?

To take cc info from a customer:
Just run your cgi script on a secure server, ie https not http.
https://somehost.com/my.cgi

To connect to a bank's verification service:
use  LWP which handles ssl.  The best way to do this, is
setup a simple html form which can connect to your
service's test server. Get some test transactions going thru
html, and then take the html_form_fields and plug them into
LWP like shown below.

$card_no= z($card_no);  #decrypt card number, encrypted on hard drive
 my $ua = LWP::UserAgent-new(timeout=45); 
 my $req = POST
'https://zentara.zentara.net/~zentara/cgi-bin/store/respgen.pl', 
  [IOC_merchant_id = '4301330018817403', 
  IOC_order_total_amount = $grand_total, 
  IOC_merchant_shopper_id = 'susehost', 
#  IOC_merchant_order_id = $order_id, 
  IOC_merchant_order_id = $unique_id, 
  ecom_billto_postal_street_line1 = $street1, 
  ecom_billto_postal_postalcode = $zip, 
  ecom_billto_postal_countrycode = $country, 
  ecom_billto_online_email = $email, 
  ecom_payment_card_name = $first $last, 
  ecom_payment_card_number = $card_no, 
  ecom_payment_card_expdate_month = $exp_mon, 
  ecom_payment_card_expdate_year = $exp_yr, 
  url = 'https://192.168.0.1/~zentara/cgi-bin/shop/boacc.pl', 
 ]; 

The url is the url that you want the results returned to, typically it
will be true or false and maybe a reason or error code.





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



Re: help me out please ..

2003-07-17 Thread zentara
On 17 Jul 2003 08:23:54 -, [EMAIL PROTECTED] (Vemulakonda
Uday Bhaskar) wrote:

i am tring to tranfer files between two linux systems through 
sftop

i have installed the following modules :

1. Download Net::FTP and Install
2. Download Net::SFTP .

and the error displayed after running the perl file with the above 
code is :

Request for subsystem 'sftp' failed on channel '1' at
/usr/lib/perl5/site_perl/5.6.0/Net/SFTP.pm line 66.

please help in this regard.

i have sent a mail earlier with the same problem , but i got reply 
fort sending the original code. the code above is the original 
code .

please help me rectify my problem

I told you this before, can you connect with the sftp program itself?
sftp  -v yourhost.com

Not all hosts are setup properly to accept sftp, especially those
running ssh1.

Until you can make that connection, you are wasting your time trying to
connect with perl.

When you do connect with perl, use the debug feature, and post the
output of your connection.

$sftp = Net::SFTP-new(myhost.com,
user=zz,
password=zfoo,
debug = 1,
);



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



Re: silly question

2003-07-10 Thread zentara
On 09 Jul 2003 09:09:34 -0700, [EMAIL PROTECTED] (John Tarn) wrote:

i am still a novice in perl so forgive me for this simple question.
what is socket programming? what do sockets do? is there a site 
that can explain them to me? thanks

From a really simple viewpoint, I compare sockets to the concept
of extensions on the old phone system. When you used to call
a pbx system, they would ask, what extension do you want to connect to?

A tcp networked computer is similar, it has an IP address (the number),
then it has 64000+ extensions(called ports). You can assign programs
to listen to their assigned ports and do stuff when packets (calls)
come in.  A whole standard has emerged as to what programs are
supposeded to listen to what port numbers.  http is 80  . https is
443 ..smtp is 25..pop3 is 110..ftp is 21

If you are using linux, look at the file /etc/services. You will see all
the ports and what is defined for them.  Also check out /etc/inetd.conf
or /etc/xinetd.conf.  Ports are so important, that some general purpose
port daemons have been written, to make port programming easier.
They are called inetd and xinetd.  They handle alot of the socket
details, and you can write socket programs to use them, or be
independent.

Now computer ports are much more complicated than what I described
above. There are tcp and udp protocols for each port, and  the simplest
way to describe sockets is a filehandle to a port.

Just like you open a filehandle to read and write to a file, you open a
socket to read and write to a port.  Socket programming allows programs
to open ports to talk to one another, sometimes the programs can be on
the same machine, where sockets are a convenient way to do inter-process
communication.  Sometimes the programs are on different machines, where
it is networking, over the internet for example.




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



Re: installation sftp : perl:complete

2003-07-08 Thread zentara
On 8 Jul 2003 11:06:51 -, [EMAIL PROTECTED] (Vemulakonda
Uday Bhaskar) wrote:

i have a code in perl which uses sftp between linux systems.

and i have installed sftp-0.9.9

but it is givibg error saying that
Requestion for subsystem 'sftp' failed on channel'1' at 
/usr/lib/perl15/site_perl/5.6.0/Net.SFTP.pn at line 66

and when i go thru the path above and see the 66th line of 
SFTP.pm
it is like this

please tell me wqhats going wrong and why the error is coming
how to rectify it.

Can you manually sftp to the server without using Perl?
The ssh installation on the server must support sftp connections.



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



Re: Command line interface for http://www.m-w.com.

2003-07-08 Thread zentara
On Mon, 7 Jul 2003 21:19:19 -0400, [EMAIL PROTECTED] (Zeus Odin)
wrote:

I have written an interface for m-w.com. I found some scripts on the web but
nothing really robust. Please have a look, make comments, request
functionality, make suggestions, make changes, or anything else you feel
useful. If I have enough time, I will make this fully object-oriented.

I welcome all comments.

Nice script..into my ~/bin.   :-)


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



Re: help : file transfer

2003-07-04 Thread zentara
On 4 Jul 2003 03:38:50 -, [EMAIL PROTECTED] (Vemulakonda
Uday Bhaskar) wrote:

i have got a code for file transger between two linux systems 
through ssh
here is the code

You should use Net::Sftp or Net::Scp to transfer files.

I see what you are trying to do. You probably should try to
open an editor, and save the file on the remote machine.
You probably need to Base64 or mime encode the file before
transferring too.  Why try to do this the hard way?use Net::Sftp.

Have you attempted to do this manually yet?  You should always see
if you can do it manually first.
start a ssh session
open an editor on the remote machine
paste in your base64 encode file
save the file on the remote machine
decode it on the remote machine







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



Re: processing image with perl???

2003-07-01 Thread zentara
On Mon, 30 Jun 2003 22:46:10 -0700 (PDT), [EMAIL PROTECTED] (Ling F.
Zhang) wrote:

This might not exactly be a perl problem...because the
solution might involve other things...

I have an album I would like to put on line, so I am
writting cgi script in perl to do it (because I can
conveniently use the HTML::template module) but I need
a way of determining the resolution of the image...how
do I do that? is there module that would work?


use Image::Size;

# get the image size, and print it out
my ($width, $height) = imgsize(image.jpg);
print The image is $width by $height;




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



Re: Always on Top.. TK

2003-06-28 Thread zentara
On Sat, 28 Jun 2003 08:47:33 +1200, [EMAIL PROTECTED] (Voodoo Raja)
wrote:

Hi all..

Just a quick one..

Is it possible to force my TK application to on top of all the windows that 
are present on the screen.. or rather set the window to be always visible 


use $mw -overrideredirect(1);

###
#!/usr/bin/perl
use Tk;
$mw = tkinit;
$t = $mw-Toplevel;  
$t-withdraw;
$t-Label(-text = Testing...)-pack;
$t-Button(
   -text = Withdraw,
   -command = sub {$t-withdraw},
)-pack;
$t -overrideredirect(1); #to top on all virtual desktops
$mw-Button(
   -text = 'Test',
   -command = sub {
   $_-deiconify, $_-raise for $t;
   },
)-pack;
MainLoop; 
#




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



Re: help:Perl ssh file tranfer

2003-06-26 Thread zentara
On 26 Jun 2003 10:14:22 -, [EMAIL PROTECTED] (Vemulakonda
Uday Bhaskar) wrote:

sir

please help me with the code which does the following :

transfer of files from one system through another system which are 
both working on linux through ssh

as iam in need of it urgently, exepecting a working codee

ssh won't transfer files, you need scp or sftp

#!/usr/bin/perl -w
use strict;
use Net::SFTP;

my $sftp = undef;

eval{
  $sftp = Net::SFTP-new(localhost, 
user=zz,
password=ztest,
);
};
if ($@) { print Sftp connection failed:\n  [EMAIL PROTECTED]; }

if (! $sftp) {
  print I can't connect!\n;
}else{
  print SUCCESS!\n;
}

$sftp-get(foo, bar);
$sftp-put(bar, baz);
__END__



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



Re: installing modules

2003-06-23 Thread zentara
On Mon, 23 Jun 2003 03:40:03 +, [EMAIL PROTECTED] (Mario Kulka)
wrote:

Could anyone give me step by tep instructions on how to install a perl 
module (MD5) on my host server. How come they don't have it installed? Isn't 
popular enough?

Sorry if I sent the same message for the second time, but the prvious one 
doesn't came through on my list.

There are 2 different MD5 modules available: one has a compiled
component, and one is pure perl.

You probably want the pure perl version, Digest-Perl-MD5-1.5.
On most servers, users don't get access to a c compiler, so you
won't be able to compile the preferred and faster MD5 module.

So this is what you do.
1. Get the pure perl MD5 module Digest-Perl-MD5-1.5 from http://cpan.org
2. Since it is pure perl, all you should need to do is install it on
your local machine, then upload the MD5.pm to your homedir on the
server, and put it  somewhere like /home/yourname/perl5lib/MD5.pm
3. Then in your .bashrc put a line 
 export PERL5LIB='/home/yourname/perl5lib'

Now you can say use MD5.pm at the top of your scripts.

There are other ways to do it, but that is the simplest.
You can upload the whole tgz package to your homedir,
and actually install it in your homedir, you just specify your
install path to be /home/yourname as explained in the install docs.





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



Re: Accessing C/C++ Dlls using perl

2003-06-20 Thread zentara
On Thu, 19 Jun 2003 23:24:04 +0200, [EMAIL PROTECTED]
(Tassilo Von Parseval) wrote:

And finally the same in XS. It's not the slightest bit harder than with
Inline::C. The only difference with the XS code below is that I changed
the return values in that the functions now return false when something
goes wrong and true otherwise.

Thanks Tassilo, a good example, now XS seems less intimidating.



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



Re: Can LWP::Simple tranfer image urls?

2003-06-20 Thread zentara
On Fri, 20 Jun 2003 09:09:21 EDT, [EMAIL PROTECTED] wrote:

Do I need to change the http header for transfering image urls?  I get errors 
when I transfer a jpg:
picture cannot be displayed because it contains errors.

It works well for me on linux.
This is one of my favorite scripts by Merlyn. :-)

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

$|++;

use LWP::Simple;

my @models = qw(amy aurelie daniela elsa fernanda
heidi josie lujan michelle molly noemie shakara
shirley veronica yamila);

for my $model (@models) {
for my $id (1..9) {
my $url = sprintf
http://sportsillustrated.cnn.com/features/2001/swimsuit/gallery/%s/%s_%d_lg.jpg,$model,
$model, $id;
my $file = $model-$id.jpg;
print $url = $file: ;
print +mirror($url, $file), \n;
}
}
__END__


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



Re: Accessing C/C++ Dlls using perl

2003-06-19 Thread zentara
On Thu, 19 Jun 2003 01:37:09 -0700 (PDT), [EMAIL PROTECTED] (Ben Crane)
wrote:

Beau,

Thanx, I hunting the info down now, seems quite
complex. I'm wondering whether it might not be better
to have a crack at this in C? Have you found perlXS to
be difficult to implement?

Inline::C and Swig  are easier to do than XS. I hav'nt been able
to get Swig to work with 5.8 though.  

Here is a simple program to mess with the cdrom tray.
USING Swig:
Run these commands in succession:

swig -perl5 cdrom.i gcc -fpic -c cdrom.c cdrom_wrap.c 
  -Dbool=char -I/usr/lib/perl5/5.6.0/i586-linux/CORE
gcc -shared cdrom_wrap.o cdrom.o -o Cdrom.so

then in the script
use Cdrom;


USING Inline::C:

#!/usr/bin/perl -w
use warnings;
use Inline C;
use strict;

my $cd = '/dev/cdrom';

cdlock($cd,0); #unlocks cdrom
cdeject($cd);  #ejects cdrom
cdclose($cd);  #closes cdrom
cdlock($cd,1); #locks cdrom 

exit;
__END__
__C__
#include stdio.h
#include sys/ioctl.h
#include linux/cdrom.h
#include fcntl.h
#include unistd.h
#include stdlib.h

#define CDROM /dev/cdrom 
/* In all functions 'device' means name of CD-ROM device,
* for example /dev/cdrom
*/

/* Close CD-ROM tray */
int cdclose(char *device)
{
int fd = open(device, O_RDONLY|O_NONBLOCK);
if (fd == -1)
return -1;
if (ioctl(fd, CDROMCLOSETRAY) == -1)
return -1;
close(fd);
return 0;
}

/* Eject CD-ROM tray */
int cdeject(char *device)
{
int fd = open(device, O_RDONLY|O_NONBLOCK);
if (fd == -1)
return -1;
if (ioctl(fd, CDROMEJECT) == -1)
return -1;
close(fd);
return 0;
}

/* Lock (if lock==1) or unlock (if lock==0) CD-ROM tray */
int cdlock(char *device, int lock)
{
int fd;
fd = open(device, O_RDONLY|O_NONBLOCK);
if (fd == -1)
return -1;
if (ioctl(fd, CDROM_LOCKDOOR, lock) == -1)
return -1;
close(fd);
return 0;
}


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



Re: Adding user to the system by using Perl?

2003-06-14 Thread zentara
On Sat, 14 Jun 2003 01:27:42 -0300, [EMAIL PROTECTED] (Josimar
Nunes De Oliveira) wrote:

I get an error at line:
system(/usr/sbin/chpasswd $user:$password)==0 or die Error: $?;
and I changed it to:
system(echo $user:$password | /usr/sbin/chpasswd)==0 or die Error:
$?;
in such way it works fine.

Any comment?

If you are just changing passwords, why not use a linux module?
Linux-usermod  from http://cpan.org



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



Re: Perl-Tk Menuframe (maybe OT)

2003-06-12 Thread zentara
On Thu, 12 Jun 2003 08:44:42 +0200, [EMAIL PROTECTED] (Jaschar Otto)
wrote:

hi,
i know there is a perl tk mailinglist but i don't want to
do all this subscribe stuff atm so i ask here since you
all helped me a lot already (thanks a lot again) :-)
No need for subscribing to a maillist.
There is a newssever for this maillinglist and for the
Tk maillinglist.
For Tk:  
comp.lang.perl.tk   from your favorite newsfeed

For perl.beginners:
perl.beginnersfromnntp.perl.org

Sorry can't help with your french menu.




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



Re: Tk/Perl and the Browser

2003-06-05 Thread zentara
On Thu, 5 Jun 2003 12:39:02 +0200 , [EMAIL PROTECTED] (Khalid Naji)
wrote:

Hi,

Is there any way to display a Tk/Perl application unter the browser?

Thank you
KN

Yes it's called the perlplus plugin

http://www.Lehigh.EDU/~sol0/ptk/ppl/ppl.html

It can be tricky to setup properly, but here is a copy of a recent
post on comp.lang.perl.tk

#33
From [EMAIL PROTECTED] Mon Mar 18 15:29:55 2002
Jim Turner [EMAIL PROTECTED] wrote:
   Has anyone successfully gotten the Apache webserver set up to 
 serve Perl Plus Plugin (Perl/Tk) programs (application/x-perlplus)?  
 I have added the mime-type information (I think correctly), and 
 always get server-error.  The log shows:

 Premature end of script headers. 

   If you have, please tell me what you changed in your Apache config 
 files and or your Perl/Tk (.ppl) script(s).

 Thanks,

 Jim

Solved my own problems!  Security=60 errors caused by
permissions on 
the plugin .so file and directories leading to it (browser could not 
execute the plugin)!  In Apache, added:

application/x-perlplus  ppl

to apache-mime.types; and:

AddType application/x-perlplus .ppl

to commonhttpd.conf.  In browser, modified newly-created helper app
for 
perlplus to use plugin's default description, etc.

Also, had to move .ppl files to my document-root -- they won't work in
the 
CGI path?!?!?.  

Seems to work now in both Mozilla  Netscape!

Jim





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



Re: tr///

2003-06-05 Thread zentara
On Wed, 04 Jun 2003 10:55:40 +1000, [EMAIL PROTECTED] (Paul
Morris) wrote:

I found this at:

http://www.suse.com/us/private/support/howto/secprog/secprog8.html

...but am having difficulty working it out, because it doesn't seem to 
do what I think it should (and I may be the problem!).

To quote:

The best solution is to select a filter for Perl, just like for shell, 
which only accepts authorized characters.

unless($userinput =~ tr/[EMAIL PROTECTED]//)
{
 print Nice try, pal!\n;
 exit(1);
}

While playing around with this, I noticed that tr won't
convert to nothing. Maybe that should be a space?
Or probably they meant s instead of tr?

Anyways, I came up with this to do what they intended?
##
#!/usr/bin/perl
use strict;

foreach my $inputString (DATA){
  chomp $inputString;
  print $inputString- ;
  $inputString =~ s/[EMAIL PROTECTED]//g;  
print $inputString- ;
 if((length $inputString) == 0){print GOOD\n}else{print BAD\n}
}  
__DATA__
!#$%^**()
[EMAIL PROTECTED]
#gh#$HJ99
Abc99dEgg
#

As far as tr goes, substitute this line in the above script,
and run it translating to //  versus / /.  It refuses to translate to
//.

$inputString =~ tr/[EMAIL PROTECTED]//;  #won't work
$inputString =~ tr/[EMAIL PROTECTED]/ /;  #works









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



Re: Regular expressions

2003-06-05 Thread zentara
On Tue, 3 Jun 2003 22:38:47 -0700 (PDT), [EMAIL PROTECTED]
(Saurabh Singhvi) wrote:

well i was trying to understand the regular
expressions in perl when i came across STDIN i
tried my best but i havent been able to get the
slightest idea on how the input thing works. The
editor i use is DzSoft. And it shows something like
get and something else below like script something
with blank space. 

Any  hopes 4 me?? :-(
Well i hope for me anyways ;)
Help please
Thanks in advamce :)

All programs have 3 default input-output filehandles,
they are STDIN, STDOUT, and STDERR. For Standard
Input, Standard Output, and Standard Error.

They default to: 
STDIN - keyboard input
STDOUT - your screen
STDERR - your screen

They are used so often, that alot of short-cuts have
evolved, so you don't always have to write them out.

Run this and watch what it does.

#!/usr/bin/perl
while(){print}

without the shortcuts, it would look like this:
while(STDIN){print STDOUT}




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



Re: Little nonsense script stats script

2003-06-04 Thread zentara
On Tue, 03 Jun 2003 10:37:12 +0200, [EMAIL PROTECTED] (Jaschar Otto)
wrote:

I'm always an very curious guy and i just because of that i made a little
script that analyises my scripts, extracts the subs, counts lines,
mys, uses, subs, etc... maybe some of you are as courious as i am
but too lazy to do that for yourself, so i want to share it with the
perl community.

totally uncommented, unsupported and without any warranty ;-)
it's just a little program with few functions but maybe you want to
add some. If you make changes or want to suggest something,
mail the changed code/suggestion to me, plz :-)

usage :
perl scriptname.pl ScriptToAnalyse.pl

You might want to add some tidyness stats.
This was just posted up today.

http://perlmonks.org/index.pl?node_id=262550

It kind of fits in with the spirit of your script.


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



Re: Calling a perl script from another perl script

2003-06-03 Thread zentara
On Mon, 2 Jun 2003 14:21:37 +0100 (WEST), [EMAIL PROTECTED] (João
luís bonina) wrote:

Well, I've tried the system function, but it isn't executing the script
which is located in the same directory...

I'm using it this way :
   system('sendfile.pl ons4jlb');

If you havn't found an answer yet, it looks to me like
you have an error with single quotes around 'sendfile.pl ons4jlb'

It should be like this:
system('sendfile.pl' , 'ons4jlb')  the (command , @args)




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



Re: Calling a perl script from another perl script

2003-06-03 Thread zentara
On Mon, 2 Jun 2003 15:25:03 -0400, [EMAIL PROTECTED] (Paul Kraus)
wrote:

List correct me if I am wrong but you can use single quotes here because
your not using any variables. You are passing exactly what you see. In
fact this is the preferred way to write strings that do not contain
variables or special characters. Correct?

Well the system command has the syntax
system($cmd, @args)
so if you use single quotes, system will look for a file named
'sendfile.pl ons4jlb'   a filename with a space in it. I doubt if that
is his intention.



-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of
zentara
Sent: Monday, June 02, 2003 3:20 PM
To: [EMAIL PROTECTED]
Subject: Re: Calling a perl script from another perl script


On Mon, 2 Jun 2003 14:21:37 +0100 (WEST), [EMAIL PROTECTED] (João
luís bonina) wrote:

Well, I've tried the system function, but it isn't executing the script

which is located in the same directory...

I'm using it this way :
  system('sendfile.pl ons4jlb');

If you havn't found an answer yet, it looks to me like
you have an error with single quotes around 'sendfile.pl ons4jlb'

It should be like this:
system('sendfile.pl' , 'ons4jlb')  the (command , @args)


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



converting arrayname to string or vice-versa

2003-06-02 Thread zentara
Hi,
This one is puzzling me. 
I know it's in the faq, to not use variables for variable naming,
but I find it odd that I can't get a stringified form of a variable
name, maybe from the symbol table? Or from the B line of modules?

Say I have an array like:

@somename = (1,2,3,4,5);

and I want to write that array to a file, but I
want the file named automatically by just
dropping the @ off of the @somename.
How would you go about doing it? Plus,
I would like to be using strict.

Also the reverse: take a filename like somename
and load it to an array @somename just by some
concantation like @{'somename'}.

The @{'somename'} seems to work, but not with strict.

It seems like it should be easy, but it's not.



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



Re: Looking for form mail attachment script.

2003-05-31 Thread zentara
On Wed, 28 May 2003 02:57:47 -0700, [EMAIL PROTECTED] (Sara) wrote:

I am looking for a pre-written CGI Form script, which is capable of sending mails 
with attachment from my desktop etc.
I have seen an example of this script sometimes back in the group.
Any ideas?

I think you need to be a little more specific. If it's cgi, and you want
to send mail with attachments from your desktop, that seems to indicate
you are running a server somewhere, and you want to upload files
to the server from your desktop, and mail them out from the server.
Somehow, I don't think this is what you want, but maybeso be
more specific.

There are alot of scripts to send mail attachments from your desktop
without using cgi forms. If you do need to do it with cgi, you have 
a few separate problems to deal with:
-- create the form

Done in 1 step:
-- get mail text message and address
-- upload the file

-- send the uploaded file from the server to the address

Sounds like a spam setup to me.



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



Re: Too little memory

2003-05-30 Thread zentara
On Thu, 29 May 2003 10:47:26 -0500, [EMAIL PROTECTED] (Camilo
Gonzalez) wrote:

I need to read in from a temp file that is about 10 megs big in 1.5 meg 
increments and write results to a database. I can't slurp up the whole 
temp file because I'm only allowed 2 megs of memory. I was hoping to 
read in only 1.5 megs per pass of the file but the read seems to be 
slurping up the whole thing. Do I need sysread?

(this type of question belongs in perl.beginners)

while (sysread FILE, my $data, $chunksize){ . };

An alternative to using sysread would be to use Tie::File, and only
bring a limited number of lines into play at a time.

use Tie::File;
my @content;
tie (@content, 'Tie::File', $file)
   or die Error: couldn't tie $file: $!\n;
#  and treat the filecontent like an array, e.g.
print scalar(@content);
# .
untie (@content);



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



Re: Need more memory

2003-05-30 Thread zentara
On Fri, 30 May 2003 00:42:07 -0500, [EMAIL PROTECTED] (Camilo
Gonzalez) wrote:

Help,

How do I flush out the memory so I can start with a fresh allotment?

This is not a cgi question, it should be posted to perl.beginners.
Perl will take care of the memory for you, it does not relinquish
memory once it has it, but it reuses it for other variables. The only
way to clear memory with Perl is to kill the script and restart it.


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



Re: Need your help regarding CGI

2003-05-28 Thread zentara
On Tue, 27 May 2003 22:21:55 -0700 (PDT), [EMAIL PROTECTED]
(Soumyadeep Nandi) wrote:

I am running a CGI script in which I am running a
system command. The scripts is as follows:

`/var/www/cgi-bin/emboss/water
/var/www/cgi-bin/emboss/water1.seq
/var/www/cgi-bin/emboss/water2.seq -gapopen 10
-gapextend 5 -outfile
/var/www/cgi-bin/emboss/water.out`;

Above I am using the system command to run the program
water which should write the output into file
water.out, which is not writing anything to this
file.

I will hazard a guess that it's because you are using backticks
instead of system.
The backticks method captures the stdout to a variable, like:
$output = `ls`;

So you are not capturing any output above.
Maybe try to run it as a system command.

my $programtorun  =  'ls';
my @parameters=  qw/. ../;
my @cmdline   =  ( $programtorun, @parameters );
system (@cmdline);

It can be a bit tricky getting all the parameters to your system command
to be quoted properly, try a little experimentation.
For example:
system ('water', 'water1.seq', 'water2.seq', '-outfile water.out')
may not work, while changing the outfile to
system ('water', 'water1.seq', 'water2.seq', '-outfile', 'water.out')
will. Experiment if you have trouble.

Putting the parameters in an @array = qw()  style can sometimes ease
this part of it. Just watch the quoting. Sometimes you need double
quotes if using a variable.














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



Re: Problems with URL parameters.

2003-05-28 Thread zentara
On Wed, 28 May 2003 01:00:51 -0500, [EMAIL PROTECTED] (Nicholas Davey)
wrote:

The problem I am having is this: When I pass a parameter via a URL, my
script isnt picking it up, and my if statement is working.

Here is the basic idea behind my script (all PERL standards are followed on
my host. The only things I cant do it fork and accept incomming
connections.):

http://www.blah.com/cgi-bin/index.cgi?login=yes (DONT go here, example only)

#!/usr/bin/perl

[ output HTML headers and top of page here ]

Always show all your code, so we don't have to guess.

if (login eq 'yes') {
[ output login form here ]

Have you extracted the $ENV{'QUERY_STRING'} in the missing
code from above, otherwise how does 'login' get the 'yes' value?
Also, 'login' is not a variable, $login is what you want.

}

[ output bottom of page here ]

Show us the whole code, and cut'n'paste it in, don't just type
in some flowchart.




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



Re: Good Perl cgi book?

2003-03-19 Thread zentara
On Mon, 17 Mar 2003 17:30:44 -0500, [EMAIL PROTECTED] (Bob X) wrote:

What is the best book for a beginner to get started with on Perl and CGI?

I would reccomend the Perl CD Bookshelf, 6 books in 1 on cd.
It is nice because you can search it for little examples of code
when you need it. Get version 3 if you can afford it, but you
can't go wrong with v2 for the price. ($6.00)

(watch wordwrap)

http://half.ebay.com/search/search.jsp?nthTime=1product=booksquery=Perl+CD+Bookshelfx=0y=0




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



Re: Saving STDERR into a variable

2003-03-19 Thread zentara
On 18 Mar 2003 23:48:25 -, [EMAIL PROTECTED] (Steve Grazzini) wrote:

James Kipp [EMAIL PROTECTED] wrote:
 Navid M. [EMAIL PROTECTED] writes:
 
 I was wondering if it's possible to save the error of
 a DOS command from the error stream into a variable.
 
 you could try the old 21 trick  
 $out = `$cmd 21`;
 
 or use system() and read the docs for capturing error codes:

Assuming IPC::Open3 works on Windows [I believe that it does]
you could also do:

  sub readpipes {
require IPC::Open3;
my $pid = IPC::Open3::open3(my ($in, $out, $err), @_);

There is a nice module to make ipc even easier than IPC::Open3,
called Proc::Reliable

#!/usr/bin/perl
use Proc::Reliable;

$myproc = Proc::Reliable-new();

($out, $err, $status, $msg) = $myproc-run(ls);

print STDOUT- $out\n;
print STDERR-$err\n;
print EXIT STATUS- $status\n;
print MSG- $msg\n;



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



Re: delete pattern from text file

2003-03-18 Thread zentara
On Mon, 17 Mar 2003 12:30:02 -0500, [EMAIL PROTECTED]
(Andrew Hughes) wrote:

submit the file gets read into memory.  If I open the file as open
(DELETEFILE,  . etc., the list gets overwritten entirely with nothing.

If I open the file as open (DELETEFILE,  . etc, the info gets stored into
memory because I can print it out using print @emailfile which gives me the
entire file.  Then, when I try to print back to the file, it is the entire

The first thing I always do is change the syntax to it's simplest
known-to-work style and then work from there. I would try
taking the concantation out of the open statement to eliminate
that possibility. Like:


sub deleteFromSubscribeList {
my $outfile = $mailingListPath . $mailingListName;
open (DELETEFILE,  . $mailingListPath . $mailingListName) or die cannot
open file for appending: $!; 
open (DELETEFILE,  $outfile) or die $!;

flock (DELETEFILE, 2) or die cannot lock file exclusively: $!;

my @emailfile = DELETEFILE;  #


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



Re: indexing books with Perl

2003-03-18 Thread zentara
On Mon, 17 Mar 2003 12:41:19 -0500, [EMAIL PROTECTED] (Matthew
Stapleton) wrote:

I am new to this list and perl.  I am wanting to find or perhaps write a
script which will index religious works such as the apocrypha or the
dhammapada.  These texts usually take the form of:

Book Chapter:Verse
Passage

Does anyone know of such a script? And, if there is not already such a
script, is perl an appropriate language to write such a script in?  

There is the perlfect search engine. It's easy for a beginner to
setup, and will output pages of html, with clickable links to the 
results. Do a google search for Perlfect.
It has a couple of drawbacks. One, you need a web server of somesort
to run it, but I've successfully set it up using the monkey httpd daemon
(find it on http://freshmeat.net).  The second drawback is that it only 
indexes files with extensions, like .txt,.pl, or .txt. You can modify
the script to do plain filenames, but you need to know what you are
doing.
If you need help setting it up, I would be happy to help you thru email,
if you are using linux. (I don't touch windows anymore).

If you don't want to use a server-style search engine, there is a nice
search package called swish++ (find it on http://freshmeat.net).
It is a little harder for a beginner to setup, but it will search by
itself, and output plain txt or XML documents. Swish is c++, and is very
fast; but I like the ease of searching with Perlfect and a web-browser.











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



Re: anonymous hash clarification

2003-03-16 Thread zentara
On Sat, 15 Mar 2003 10:50:54 -0600, [EMAIL PROTECTED] (David
Gilden) wrote:

 # Is the code below -- better or correct?
 
 foreach my $bag (@bags){
 $bags_ordered{$bag} = $bag unless exists $bags_ordered{$bag} 
 }

You can also try:

$bags_ordered{$bag} = $bags_ordered{$bag} || $bags;
#or
$bags_ordered{$bag} ||= $bags;





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



Re: Compiling Perl?

2003-03-15 Thread zentara
On Fri, 14 Mar 2003 10:47:52 -0500, [EMAIL PROTECTED] (Brian
Jefferies) wrote:

   Is there a general consensus regarding compiling perl into binary
executable?


I love perl, but I don't understand the sense in re-compiling the same cgi
script (for example) 10,000 times a day.

I have read and tested perlcc -b and found no performance improvement over
running the .pl.

Get the fastcgi module. It works on almost any script. It compiles the
script once, and keeps a copy in memory. You can set different
configurations for different scripts(like how many spare copies to
keep). Some can be fastcgi, and others not. Some can be dynamic(fresh
cgi for each call) or static(reuse same cgi, with problems of variables
overlapping).

It's alot easier to use than mod_perl.

If you need a similar function, but not cgi, try the PersistentPerl
module. It does similar things, but on plain perl scripts run locally.



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



Re: ASN1.pm

2003-03-13 Thread zentara
On Wed, 12 Mar 2003 12:02:52 -0500, [EMAIL PROTECTED] (Susan
Aurand) wrote:

I am getting an error can't locate ASN1.pm, I have tracked that down to - I need
Convert-BER-1.25.tar.gz.  I have downloaded the file. I cannot find the documents on 
this download,
where to unzip and load, etc...  Does anybody know.
Thanks - Susan

You must be using windows.  A tar.gz file is like a zip file on windows.
You can get untar programs that run on windows, but I don't think
that will help you any to run it on a windows version of Perl.  You
should see if you can get the Convert-BER package for the particular
version of Perl for windows that you have.

If you need a free untar program, go search for untar or tar on
www.nonags.com



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



Re: ASN1.pm

2003-03-13 Thread zentara
On Wed, 12 Mar 2003 12:02:52 -0500, [EMAIL PROTECTED] (Susan
Aurand) wrote:

I am getting an error can't locate ASN1.pm, I have tracked that down to - I need
Convert-BER-1.25.tar.gz.  I have downloaded the file. I cannot find the documents on 
this download,
where to unzip and load, etc...  Does anybody know.
Thanks - Susan

You must be using windows.  A tar.gz file is like a zip file on windows.
You can get untar programs that run on windows, but I don't think
that will help you any to run it on a windows version of Perl.  You
should see if you can get the Convert-BER package for the particular
version of Perl for windows that you have.

If you need a free untar program, go search for untar or tar on
www.nonags.com



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



Re: How to Access Serial Port in Perl

2003-03-11 Thread zentara
On Mon, 10 Mar 2003 13:31:47 -0800, [EMAIL PROTECTED] (David
Cheng) wrote:

Hi all,

How to open, initialize, read and write to a serial port in Perl? Any advice helps, 
thanks.

Get the Device-SerialPort module from http://cpan.org

It has plenty of demos.


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



Re: perl program control -- wvdial

2003-03-05 Thread zentara
On 04 Mar 2003 22:58:20 -0700, [EMAIL PROTECTED] (Jdavis) wrote:

Hello,
  I am writing a script to help a user turn a modem
on and off and adjust the routing tables on a 
Linux box. I am trying to call wvdial to do the dialing,
but it does not give control back to my script. I call
it like so

if( $choice == 1){
   `wvdial`;
   print connected;
}

I also have tried..

if( $choice == 1){
   `wvdial`;
}

but nothing after `wvdial` gets ran.
could someone offer me some advice...please :) ?

Backticks and system will run the program until  
it finishes, then return control to the calling program.
Exec will run the program, but never return control.
What you want to do is fork and exec


if($pid = fork() == 0)
{
  exec(wvdial);
}

# this is all executed in the parent 
#... 
kill $pid;   #to terminate wvdial 

You can check whether the connection is
good by checking the file /var/run/ppp0.ip




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



Re: CGI.pm strange results

2003-03-04 Thread zentara
On Mon, 3 Mar 2003 16:07:26 -0500, [EMAIL PROTECTED] (Todd Wade) wrote:


Zentara [EMAIL PROTECTED] wrote in message

 You might want to try assigning a variable name to param(quantity)
 first, before you set up the table. I don't know why, but sometimes
 the scripts don't like it any other way. I've run into this type of
 thing before, and just take the easy way out, and assign a variable.

This is not true at all.

Well what ever the reason is, it has worked that way sometimes for me.
When you start deeply nesting and quoting in tables and here documents,
Perl will sometimes fail to interpolate unless you force the value into
a variable.  I guess I havn't learned the trick yet.

If you look at the html source, there are multiple input fields are named
quanity. You need a way of indexing your quanity fields so you know which
value of the array to fetch while looping through the selected items.

Yeah, I realized that while thinking about it later. Another solution is
to put an separate order button along each item, or he can rename
the quantity parameter to quantity-furry, quantity-stripped, etc,etc.


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



Re: running perl under xinetd on linux

2003-03-04 Thread zentara
On Mon, 03 Mar 2003 09:59:01 -0700, [EMAIL PROTECTED] wrote:

Is there an issue running perl under linux xinetd where xinetd is
listening for connections on a UDP port and then forking the following
perl code.  When I do this, the perl code does not see any input on
STDIN.  How does one get at the data received on the socket
by xinetd?

while (STDIN) {
  $input = $_;
  syslog('info', Read : $input) ;
}

I see 2 possible problems, 1 is the /etc/xinetd.conf setup,
and the other is buffering.  

I have your example running by doing the following:

In /etc/xinetd.conf:
##3
# test scripts, choose an unused port
# name the service something
# add protocol,port, and server

service xtest
{
socket_type = stream
protocol= tcp
port= 8085
flags   = REUSE
wait= no
instances   = UNLIMITED
user= root
server  = /usr/local/bin/xtest
}
#

/usr/local/bin/xtest   (chmod 755)
##
#!/usr/bin/perl
use Sys::Syslog;

syslog('info', Started: time()) ;

select (STDOUT);$|++;
print Start typing\r\n;

select (STDIN);$|++;
while (STDIN) {
  $input = $_;
  syslog('info', Read : $input) ;
 }
###

Then telnet 127.0.0.1 8085;   you need to hit the telnet escape
^]   then type quit to exit.





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



Re: Max Len for string in perl???

2003-03-04 Thread zentara
On Tue, 4 Mar 2003 11:51:22 -, [EMAIL PROTECTED] (Rob Dixon)
wrote:

Luinrandir Hernsen wrote:
 Hallo
 What is the maximum number of charecters in a string?
 $A=123456789

It's hower big a number a 'size_t' value can hold under the
C compiler that built your Perl. This is usually an 'unsigned int'
which, if it is 32 bits int, has a limit of just over 4 billion.
Whether you have enough RAM for that is another
question :-)
Cheers,
Rob

Just for fun I ran 

#!/usr/bin/perl
$str = A x 50;
while(1){
$str .= $str;
}

I watched it with top. It grew until it's memory usage was 965 M,
and was swapping, then it died with Out of Memory.  I'm guessing
as the 965 M tried to concantate the last time, it hit the 2 gig file
size limit?  Since everything in linux is a file, I'm guessing when your
memory usage hits 2 gig, you stop?






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



Re: CGI.pm strange results

2003-03-03 Thread zentara
On Sun,  2 Mar 2003 10:50:39 -0600, [EMAIL PROTECTED] (David
Gilden) wrote:

Hello,

I am not understanding why I am getting strange data from the my CGI. 
Please point out what I have done wrong.
Thanks
Dave Gilden

See the result at, you have to 'order' on item to see the problem.
http://www.coraconnection.com/paul_s/pages/catalog.html

I looked at it and clicked on order, and it does what the code says.
With the exception of the quantity is zero.

I'm using the latest mozilla, it shows 1 row of a table, with a picture
of the item first, then it's description, the quantity (which isn't
right), then the escaped $Price

You might want to try assigning a variable name to param(quantity)
first, before you set up the table. I don't know why, but sometimes
the scripts don't like it any other way. I've run into this type of
thing before, and just take the easy way out, and assign a variable.

$quantity= param(quantity)
print  td, $quantity, /tdtd\$Price goes here/td\n;

Otherwise, give more explanation of what your problem is.




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



Re: Perl/CGI with FRAMES

2003-03-02 Thread zentara
On Sat, 1 Mar 2003 10:49:55 -0800, [EMAIL PROTECTED] (Maureen E
Fischer) wrote:

I have recently finished an online database system using perl/cgi.  It
has been suggested that it would lend itself to using HTML frames.
I have a main menu that could always be shown and what is selected from it
would refresh another frame.  I have never used this before but what I see
is identiflying what goes into the frame by using SRC= a file name.  This
worked fine for the heading which is a gif file logo, but the data is
accumulated using multiple database reads and collected into tables.
I am using a perl here statement to output this data.  So is there a simple
way to do this?  Do I have to write my HTML to an intermediate file and then
refer to that using the SRC attribute?

No you don't have to write an intermediate file, but it can get tricky.
The best thing you can do is setup a little example page to experiment
with, get the idea down, then add more complexity to adapt to your
problem.  Basically you need to get the idea of printing your links in a
manner which print to the appropriate frame target. Say you have 4
frames,top,left,main,and bottom.  You can have a menu in the left frame,
and the results in the main frame. But when you print results to main,
the target of the links in main, should be self. Or when you click a
link in the left menu, that updates the left menu, the target should be
self; but links that return results to the main frame, need the target
= frame.  I'm sure once you get past that hurdle, you will have an easy
time.  You also need to update frames occaisionally, which alter all
the links. 

Here is just a snippet to show you what the perl would look like
to generate some html for frames. This will generate a search menu
in the left(menu) frame, it's called from the left, and returns the html
links to the left.  But when search results links are returned from the
search, (code not shown) the links created point to target=main, since I
want the results to go to the main frame.

You can even make the target a variable, like target=$target , it all
depends on how ingenious you want to get.

If you want to see my first attempt at this, go to 
http://zentara.net/store/admin.html  and play around.
The password is z-store
Try the Inventory Management, and look how the links get
setup.

You can download the script if you want to look at it.
It is not the best, but it will show you the idea.
http://zentara.net/downloads/perlshop-z.zip


You might want to setup your browser to use your chosen
colors to see the frames better, because I have them background=
black to hide the frame boundaries.


sub displaysrchmenu{
printPRINT_END;
bfont color=#00SEARCH INVOICES MENU:/font/bbrhr
Enter your start and end dates in the format bmmdd/bbr
Start defaults to 01012002br
End defaults to current datebrhr
centerbor/b/center
Enter a name to search for, or bothbrhr
You must fill in at least 1 fieldbrhr
form method=post target=_self
$secure_server_address$cgi_directory/admin.cgi
input type=hidden name=PASSWORD value=$input{PASSWORD}
tabletrtd align=leftStart: /td
td align=leftinput type=text size=18 name=DSTART/td
/trtrtd align=leftEnd: /td
td align=leftinput type=text size=18 name=DEND/td/tr
/trtrtd align=leftName Search: /td
td align=leftinput type=text size=18 name=SNAME/td/tr
input type=hidden name=ACTION value='SEARCH INVOICES'
input type=hidden name=INVACTION value='DO SEARCH'
input type=submit value='Get Them'/td/tr/table/form
form method=post target=_top
$secure_server_address$cgi_directory/admin.cgi
input type=hidden name=PASSWORD value=$input{PASSWORD}
input type=hidden name=ACTION value=EXIT
input type=submit align=left value=Exit/form
PRINT_END
exit;
}


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



Re: General ftp question

2003-03-02 Thread zentara
On Sat, 1 Mar 2003 16:59:38 -0800, [EMAIL PROTECTED] (Ebaad Ahmed)
wrote:

Hello All,
I have just installed SuSe on my computer, I can ftp to any ftpsite from
this but cannot ftp into the machine. How can I make this possibe. Any
help will be really appreciated.

The suse-linux-e mailling list is the best place to answer this.
You can go to http://suse.com and subscribe to the list, they
are a very helpful group.

It's not hard. You have 2 types of ftp, user and anonymous.

You need to 
1. install a ftp daemon, and the ftpdir rpm (which sets up the
anonymous directories.

2. start the ftpd

3. Setup your firewall to accept connections for the ftp port.



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



Re: General ftp question

2003-03-02 Thread zentara
On Sat, 1 Mar 2003 16:59:38 -0800, [EMAIL PROTECTED] (Ebaad Ahmed)
wrote:

Hello All,
I have just installed SuSe on my computer, I can ftp to any ftpsite from
this but cannot ftp into the machine. How can I make this possibe. Any
help will be really appreciated.

The suse-linux-e mailling list is the best place to answer this.
You can go to http://suse.com and subscribe to the list, they
are a very helpful group.

It's not hard. You have 2 types of ftp, user and anonymous.

You need to 
1. install a ftp daemon, and the ftpdir rpm (which sets up the
anonymous directories.

2. start the ftpd

3. Setup your firewall to accept connections for the ftp port.



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



Re: Crypt::Blowfish errors on line 56

2003-03-01 Thread zentara
On Fri, 28 Feb 2003 16:15:27 -0600, [EMAIL PROTECTED] (Tyler Longren)
wrote:

I found that if I change $data to 12345678, it works.  How can I encrypt a
string that has more than 8 characters?

 When I run this code, I recieve this error:
 input must be 8 bytes long at
 /usr/lib/perl5/site_perl/i386-linux/Crypt/Blowfish.pm line 56.

Try this:

#this sub makes all data blocksize of 8 bytes. 
sub get8 {
my $data = shift;
  return \0 x ( 8 - length($data)%8 ) . $data;
  }







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



Re: checking if its a real number

2003-02-27 Thread zentara
On Wed, 26 Feb 2003 16:30:56 -0800, [EMAIL PROTECTED] (T. Murlidharan Nair)
wrote:

I have a cgi that  need to accept only  numeric values. ie +ve or -ve 
real numbers.
Is there a quick and easy way to check this. I was trying using a reg exp
if(/^[-0-9][\.0-9]*/) {
 do something
}

but this breaks when the number is say --75.4  It still accepts if it 
has two - signs.

$_ = 4.01;

if (/\D/){ print has nondigits\n }
if (/^\d+$/) { print is a whole number\n }
if (/^-?\d+$/)   { print is an integer\n }
if (/^[+-]?\d+$/){ print is a +/- integer\n }
if (/^-?\d+\.?\d*$/) { print is a real number\n }
if (/^-?(?:\d+(?:\.\d*)?|\.\d+)$/) { print is a decimal number\n }
if (/^([+-]?)(?=\d|\.\d)\d*(\.\d*)?([Ee]([+-]?\d+))?$/)
{ print a C float\n }
°
Also check out the Regex::Common module, it has number-type detection.



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



Re: How do embed javascript

2003-02-27 Thread zentara
On Wed, 26 Feb 2003 19:00:18 -0800, [EMAIL PROTECTED] (Tom McKellips) wrote:

Hi,

How do I embed a java script inside a perl cgi? In my perl code I have a 

Watch wordwrap :-)   This javascript will give you the option
to view another cgi in a popup window.  The printenv script is
at the bottom.


#!/usr/bin/perl

$url='http://zentara.zentara.net/~zentara/cgi-bin/printenv';
printEOH;
Content-type: text/html

htmlbody
EOH

printEOT;
script type=text/javascript
  function showPopup() {
  var win;
  win =
window.open($url,poputWindow,width=400,height=400,status=no,resizable=yes,scrollbars=yes);
}
/script

a href=javascript:showPopup()Show Results in Popup Window/a
brbr
a href=javascript:window.close();Close/abr
brorbrbr
forminput type=button value=Close
onclick=javascript:window.close();/form
brbr
a href=javascript:history.go(-1)Back to Previous Page/a

/body/html
EOT

__END__
--


#!/usr/bin/perl
##
##  printenv -- demo CGI program which just prints its environment
##
print Content-type: text/plain\n\n;

foreach $var (sort(keys(%ENV))) {
$val = $ENV{$var};
$val =~ s|\n|\\n|g;
$val =~ s||\\|g;
print ${var}=\${val}\\n;
}
__END__




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



Re: How do you 'read' from a Tk widget ?

2003-02-25 Thread zentara
On Fri, 21 Feb 2003 14:14:08 +0200, [EMAIL PROTECTED] (Yargo) wrote:

Hi all,
I have this little script that asks the user for UserName  password.

I can't figure out where do I get the input.
e.g. :
UserName = yargo
Password = q1w2e3

Here's an example:

#!/usr/bin/perl
use Tk;

my $MainWindow = MainWindow-new;
$MainWindow-title(Password Entry);

$MainWindow - Label(-justify = 'left',
 -text = Name: )
-pack(-side = 'left',
   -anchor = 'n');

my $entry = $MainWindow - Entry(-selectborderwidth = 10)
-pack(-side = 'top',
   -anchor = 'n');

###

$MainWindow - Label(-justify = 'left',
 -text = Password: )
 -pack(-side = 'left',
 -anchor = 'w');


my $entry1 = $MainWindow - Entry(-selectborderwidth = 10,
  -show = *)
-pack(-side = 'left',
  -anchor = 'e');


##
$MainWindow - Button(-text = SUBMIT,
 -command = \somesub)
 -pack(-side = 'bottom',-anchor = 's');


$entry-bind('Return',[\somesub]);
$entry-focus;
MainLoop;

sub somesub {
$name = $entry - get;
$password = $entry1-get;
print name -$name\n;
print password -$password\n;
$MainWindow - destroy;
}





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



Re: Multi threading in perl

2003-02-25 Thread zentara
On Mon, 24 Feb 2003 10:45:44 -0800 (PST), [EMAIL PROTECTED] (Madhu
Reddy) wrote:

Hi,
   does anybody have sample perl script  multi
threaded program 

Here are a couple of simple examples.
When you run them, open an xterm an watch top
while they run.
###
#!/usr/bin/perl
use threads;
my @kiddies;

foreach(1..10)
{
print $$ starting loop $_;

push @kiddies, threads-new(\sub1);

print $$ exiting loop $_\n;
}

sub sub1
{
print \tchild , threads-tid(),  created ok\n;
sleep(int(rand(10)));
print \tchild, threads-tid() ,  done, outta here\n;
}

foreach (@kiddies){ $_-join(); }




#!/usr/bin/perl
#threads share same memory stack
#each thread has it's own pid and stack pointer
#threads can access other threads variables
use threads;
use threads::shared;
use strict;
my $wait = 500;
my @up: shared;
my $th;
my @childs;
my $child;
my @down: shared;

my @list = qw (5 10 15 20 25 30 35 40 45 50 55 60);

foreach (@list) {
push @childs, threads-create( do_my_thing, $_ );
}

foreach $child (@childs) {
   $child-join();
 }

print @up,\n;
print @down,\n;

sub do_my_thing {
my $val = shift;
push @up,$val started;
sleep $val; #sleep various lengths in thread
push @down, $val down\n;
}

###





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



Re: Help need in GUI

2003-02-25 Thread zentara
On Tue, 25 Feb 2003 10:30:32 +0530, [EMAIL PROTECTED] (Anand
Ramakrishna) wrote:

  I work on Solaris and I have perl installed. Do I have to install Perl Tk 
 separately. 
I got this sample program from the web and I tried to run it in my machine. I get 
this error when I do it.
Can't locate object method new via package MainWindow at ./gui_test.pl line 3
I dont understand what's happening. Please help me in this regard.


You must install Tk, it's a separate module. Plus
the program needs a MainLoop statement.

#!/usr/local/bin/perl
use Tk;
my $vu_win = MainWindow-new();
$vu_win-configure(-title='Verify User',-background='blue');
$vu_win-geometry('+100+300');
MainLoop;

$vu_win-destroy;


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



Re: crypt() unix function, what about windows cryption? .htpasswd file

2003-02-15 Thread zentara
On Fri, 14 Feb 2003 11:17:48 -0800 (PST), [EMAIL PROTECTED] (Patricia
Hinman) wrote:

I don't want to hide the main source code.  Only
encrypt the password on the client side.  I could do
that with  a js program.  Then my pl file could unwind
the script.  This is to keep people from viewing the
password in transit.  It would be like the unix salt
system.  I could put a key txt file in their protected
directory that my perl file would read to unwind the
js encrypted password.

There is an author who has been working on this for
awhile. Check out this:
http://perl-md5-login.sourceforge.net/


It sends a temporary key which is good for 30 seconds,
then javascript encodes your password and sends it.

It isn't perfect, but it sounds like what you are after.




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




Re: crypt() unix function, what about windows cryption? .htpasswd file

2003-02-14 Thread zentara
On Thu, 13 Feb 2003 20:57:05 -0800 (PST), [EMAIL PROTECTED] (Patricia
Hinman) wrote:

OOPS mistake corrected
 I did stumble across a method call to a cryption() 
---wrong  crypt() is the method  --

I have just discovered it is a unix function.  It
doesn't decrypt. One must always crypt user input then
check for equality.
if (crypt ($guess, $pass) eq $pass) {
   # guess is correct
   }

I guess that means I can't use it on my Win98 box.  I
was really hoping for a platform independant method.

I can't really say I understand the exact nature of your problem.
You may be running into a problem with crypt and crypt-md5.
Most linux systems will auto detect the crypt used by the $1,
which indicates a md5 hash.

Here is some examples to try and demonstrate crypt.

#!/usr/bin/perl
use Crypt::PasswdMD5;

#The secret to getting crypt to work correctly is in providing 
#a salt starting with '$1$' and having 8 characters 
#(instead of the normal 2 used for DES-crypt). 
#There are similar conventions for using other crypt variants 
#(e.g. '$2$' for SHA-crypt).
my $passwd = 'whoopdeedoo';
my $salt = '$1$qwertyuz';
print md5crypt salt= $salt \n;
print -\n;
my $crypted = unix_md5_crypt $passwd, $salt;
print $crypted\n;

my $crypted = crypt $passwd, $salt; #crypt works as well
print $crypted\n;
print crypt ($passwd, $salt), \n;

##
print #\n;
print des crypt salt= xy \n;
my $passwd = 'whoopdedoo';
my $salt = 'xy';
print -\n;
my $crypted = crypt $passwd, $salt;
print $crypted\n;
print crypt ($passwd, $salt), \n;

#Note that the MD5-based crypt() is not the same as 
#obtaining the hash of your password with Digest::MD5 or similar. 
#The algorythm used internally by the MD5-based crypt() uses a 
#number of transformations in which the MD5 algorythm is used, 
#but is very different.

#Crypt::PasswdMD5 implements this algorythm in Perl, 
#allowing you to reproduce the result of said crypt() functions 
#in non-*nix systems or systems without a compatible crypt() 
#implementation.





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




Re: Pipe Help

2003-02-10 Thread zentara
On Sun, 9 Feb 2003 19:23:16 +0100, [EMAIL PROTECTED] (Anthony) wrote:

Hi,

But like i said on my second post i wanted to learn how to receive message
from pipe.

OK, here are two simple scripts which should show you the idea.
One is a reader and one is a writer.  Always start and stop the
reader first, or you may get some blocking on perl56; but perl58
seems to work good either way on my machine. I don't know why
there is a difference.

So start 2 xterms side by side, have both scripts in the same
directory, then start the reader, then start the writer, and watch them
go. Hit control-c to stop them, stop the reader first.

Run them different ways, try to figure out why the scripts
hang if you manage to hang them.

Then look at how hard the code is to use for anything else than this
simple example. Then you will see why the modules in IPC
are mentioned as the way to go.

Don't keep asking for more help on this, because most of the
programmers never use 2 pipes for IPC.

~~~
#!/usr/bin/perl56
#this is the named-pipe reader
#start the reader first, since it makes the pipes
#the trick is to close the pipe after each write, so
#the scripts don't hang.
use warnings;
use strict;
use POSIX 'mkfifo';

$|=1;
mkfifo( 'b2a', 0666 ) unless -p 'b2a';
mkfifo( 'a2b', 0666 ) unless -p 'a2b';

while(1){
open(INB, b2a)  or die $!;
my $rv = read(INB, my $buffer, 4096) or die Couldn't read from INB :
$!\n;
  # $rv is the number of bytes read,
  # $buffer holds the data read

print STDOUT $buffer;

(my $num)= $buffer =~ /^(\d+).*/;

open(OUTA, a2b)  or die $!;
select OUTA; $|=1;
print OUTA You sent $num\n;
close OUTA;
}
~

#!/usr/bin/perl56
#this is the writer
use strict;
use warnings;
use POSIX 'mkfifo';

$|=1;
mkfifo( 'b2a', 0666 ) unless -p 'b2a';
mkfifo( 'a2b', 0666 ) unless -p 'a2b';

my $count=0;
while(1){
my $input = $count : another bit of data;
open(OUTB, b2a) or die $!;
print OUTB $input\n;
close OUTB;

open(INA, a2b) or die $!;
my $rv = read(INA, my $buffer, 4096) or die Couldn't read from HANDLE :
$!\n;
# $rv is the number of bytes read,
# $buffer holds the data read

print STDOUT $buffer;

sleep(1);
$count++;
}



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




Re: slurp in file

2003-02-10 Thread zentara
On Sun, 9 Feb 2003 11:45:56 -0600, [EMAIL PROTECTED] (Ktb) wrote:

Is there any function that places perl code from a file into a program
as if it was just part of the program file itself?

Something like:

file
**
Hello World.
**

program
$file = slurp('file');
print $file\n:

Well the advice given by others is correct, but just to
answer the slurp part of your question.

#Return the file contents as a scalar value 
sub slurp {
  my $OP ;
  open FS, $_[0] or die Can't open $_[0]:$!;
 {local $/ = undef; #file as 1 big string instead of line by line 
  $OP = FS;
  }
   close FS or die Can't close $_[0]:$!;
return $OP ;
}






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




Re: How to alarm under 1 second?

2003-02-10 Thread zentara
On Mon, 10 Feb 2003 12:41:57 +0100, [EMAIL PROTECTED] (Angerstein)
wrote:

If I need an alarm signal alarm(), in less than 1 second what can I do?

Interestingly enough, this just showed up on perlmonks this morning.

http://www.perlmonks.org/index.pl?node_id=23402

Simultaneous alarms under 1 sec



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




Re: Pipe Help

2003-02-09 Thread zentara
On Sun, 9 Feb 2003 11:02:52 +0100, [EMAIL PROTECTED] (Anthony) wrote:

Hi,

for the while loop i figure out before your answers, anyhow, my question was
should i send the whole array or not?
also is it possible to retrieve the data from the pipe or not?

If you don't want to use a module like IPC::Open2,
then you need 2 pipes, 1 to send the array, and
1 to return the sorted array.

After your sort script is finished, have it write it to
another pipe back to the original script.

You will have to keep the original script going, while
the sort script does it's work, so you will have to
work out a loop of some kind, to check for the 
return array through the second pipe.

It all can be done. But you will find that the IPC series
of modules take care of all the details for you.


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




Re: How do I include a bmp or gif file in my TK code

2003-02-05 Thread zentara
On Tue, 4 Feb 2003 15:46:31 -0500, [EMAIL PROTECTED] wrote:


Hello,

I have some code using TK.  I used perlapp to compile my code, but the
external images will not compile into the exe file.
How can I include them in the compiler or how can I embed the image within
my perl code ?

$img = $top-Photo(-file = ('smfig44.bmp'));

I don't have an example handy, but you could use
MIME::Base64 to encode the photos into printable text,
then put them into a variable or a __DATA__ section.

There is a nice module called Inline::Files which might
assist you.


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




Re: How do I include a bmp or gif file in my TK code

2003-02-05 Thread zentara
On Wed, 05 Feb 2003 08:28:43 -0500, [EMAIL PROTECTED] (Zentara)
wrote:

I have some code using TK.  I used perlapp to compile my code, but the
external images will not compile into the exe file.
How can I include them in the compiler or how can I embed the image within
my perl code ?

$img = $top-Photo(-file = ('smfig44.bmp'));

I don't have an example handy, but you could use
MIME::Base64 to encode the photos into printable text,
then put them into a variable or a __DATA__ section.

There is a nice module called Inline::Files which might
assist you.

Well here I made a little example to show you what I mean.
I used jpg. I hope the line conversions and wordwrap don't
mess up the picture of tux. :-)

#!/usr/bin/perl -w
use strict;
use Tk;
use Tk::JPEG;
use MIME::Base64;

#this method works as easy as it does, because
#Tk needs it's images to be base64 encoded anyways,

#use this to encode
#open (FH, tux.jpg) or die $!;
#my $photo = do {local $/; FH};
#my $content = encode_base64($photo) or die $!; 
#print $content;

#don't forget to '' quote
my $photo =
'/9j/4AAQSkZJRgABAQIASABIAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0a
HBwgJC4nICIsIxwcKDcpLDAxNDQ0Hyc5PTgyPC4zNDL/2wBDAQkJCQwLDBgNDRgyIRwhMjIyMjIy
MjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjL/wAARCAA8AEMDASIA
AhEBAxEB/8QAHgIDAQEAAAQFBwIDCAYB/8QAMBAAAQMCBQMCBQMF
AQIDBAARBQYSITEHUXETYSIyQUKBFTOhI1KRscH/xAAaAQEBAQADAQAAAQIDBQYE
/8QAIxEAAgEDAwQDAAECAwQREyExBRJBkVFSof/aAAwDAQACEQMRAD8Ap5brjgSF
uLUEgBIUomwACRb8ADwB2rCl5bymWgU8k2v2oiyPWGk/OP5oBiiilYkbEsanCJhsZ+S8r5Wo6CtR
97DegGqKZw3LWZpk6RDYwiY69GIS+0WiFNk8A34J+gPNaHW3GHVtPIU242opWhYsUkcgg8GgNa3E
Nga1AXr6CFC4NxUXKe9Z24+UbCm4CiWSD9DtQE07jmKvurdXiMrUo3Ol0pA8AbAew2FFR9FY0ofV
F7n8is9N2QexqPQstrCk8ipd1HqNKR3FQ6klKikixFbIS3qhcYuJ/tJ8V7LpFjWV8Pm4rh2aU6Yu
JMJZD11AJsoK0lSTqAJA3Haq9Ze0sutk7Ebb/WiEtpucwt9OppKwVp7i+9R8A6jVO/UcfmTGMBZm
YEsxnI6npBaccdZvpeSLG4sQAFEXCQeDVV9a1uzsyJxVjBZUGO6wht5x1KbLdBVc3SSPl0jm/wAN
WejGn3mmpGH4Yqdh7qApp2K+gK8FKym1uOT+K8x1CzNHiZUmQMSYaRMmJ0sRQ6HFJTt8a7CwII2t
fgb828pa9avalyoSgmm+E91++POV6OzqWlGNPKb29FA1KQkaI4J+43qOab9V1KO53qZAsABwK9Yd
YFFZBtZFwhVvFFTKGDGkpse49VPP3Cnaxct6ar8WNUELW+HEkT5bUSK0t191QQ22gXKiTYACtFWR
0LQ0vqnh/qtayG3Sg2uEq9NW/wDugLEyX0XzHBw0KxDM8jDC4NRiRPj0+VXtfwD5rxHVLpPiOUo/
64nE14nDccCHXHEkONqPGrc3B7966qqMzBgcPMuAy8HnhRjSkaVaDYixBBHuCAfxWFTgpOSW7K5N
rBxFAaGlTvJ48U7Tmasrzsi5qfwmbct31NPWsHWz8qh/33BFJ1shaLs7qHiTpmwoOMRoz/8AUbai
IfDQB3ukEnY882322tRUE9nTMDjzjjeKS46VqKvSYkOIQm+5skKsB7DaigPF0vMVpjH32pik8Q/b
R5oCPrq3ofktnL+UGsYebviOJoDhUoboa+1I87KPe47VyvHSFyWkngrAP+a71jR24kVmMynS0yhL
aE9kgWAoDbRRRQFc9ZsnR8zZJkzUpAn4W2qSy59SgC60n2IF/IHvXLkVZcjpJ5GxrrzqfNdgdM8f
fZ06zFLXxC+yyEH+FGuQIP7Fve9AW9Iw+JIfU7h+TJaoqrFsuy1sqO290FSrb3+p7+1FQKHXEoAW
UuqAtrW2gqPnaivld3BPGGcmkz//2Q==';

my $mw  = MainWindow-new();
my $image = $mw-Photo(-data = $photo);
$mw-Label(-image = $image)-pack(-expand = 1, -fill = 'both');
$mw-Button(-text = 'Quit', -command = [destroy = $mw])-pack;
MainLoop;



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




Re: Thread enabled?

2003-02-04 Thread zentara
On Tue, 4 Feb 2003 09:40:25 +0100, [EMAIL PROTECTED] (Angerstein) wrote:

Hi,

how can I check if my perl is thread enabled?

I ´m using 5.6.1.

Which Modul to use and where to find?
(if not cpan)

use threads or use Thread? Which is which?
This is from perl5.8's perlthrtut:

(By the way, look at the module forks-0.02 for a drop
in replacement to enable threads in older perls)

NOTE: this tutorial describes the new Perl threading
   flavour introduced in Perl 5.6.0 called interpreter
   threads, or ithreads for short.  In this model each thread
   runs in its own Perl interpreter, and any data sharing
   between threads must be explicit.

   There is another older Perl threading flavour called the
   5.005 model, unsurprisingly for 5.005 versions of Perl.
   The old model is known to have problems, deprecated, and
   will probably be removed around release 5.10. You are
   strongly encouraged to migrate any existing 5.005 threads
   code to the new model as soon as possible.

   You can see which (or neither) threading flavour you have
   by running perl -V and looking at the Platform sec­
   tion.  If you have useithreads=define you have ithreads,
   if you have use5005threads=define you have 5.005
   threads.  If you have neither, you don't have any thread
   support built in.  If you have both, you are in trouble.

   The user-level interface to the 5.005 threads was via the
   Threads class, while ithreads uses the threads class. Note
   the change in case.



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




Re: Online Resources

2003-02-04 Thread zentara
On Tue, 4 Feb 2003 01:58:28 -, [EMAIL PROTECTED] (Anthoni) wrote:

Hi there,

Can anyone point me to some good resources for learning perl?
I have the book Javascript, CGI and Perl, but want some online material as
well

Go to http://perlmonks.org and look thru their tutorial section.


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




threads and pids

2003-02-02 Thread zentara
Hi,
I just got interested in 5.8 threads. I have a simple question
about the first basic example in perlthrtut.

My basic question is how to track the pids, and why does the
following program create 4 pids instead of 3? I would expect
3, one for the parent, and one for each of 2 threads. 

So run the following program and watch it with top c. 4 pids
are generated. What is that extra pid for?

Also does anyone know how to get the individual threads pids?
I can get the tid, but can't seem to find the pid, except the parents.

#!/usr/bin/perl
use threads;

print I'm the parent pid- $$\n;
$thr = threads-new(\sub1);
$thr1 = threads-new(\sub1);
sleep 25;

sub sub1{
$myobject = threads-self;
$mytid= $myobject-tid;
print In the thread $myobject $mytid \n;
sleep 20;
}




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




Re: importing data from first program

2003-01-29 Thread zentara
On Tue, 28 Jan 2003 20:19:57 -0600, [EMAIL PROTECTED] (J. Alejandro
Ceballos Z.) wrote:

I have 2 perl programs

The first one is using strict, are two variables have a value, but in a 
procedure it calls a second program, and I want to load the value of the 
previous variables, but I can't. See example

You should use our to declare the variables.

#!/usr/bin/perl
#  program1.pl 
use strict;
our ($a,$b);
require (program2.pl);
proc1;
sub proc1 {print $a $b\n}
proc2;



#!/usr/bin/perl
# program2.pl
our($a,$b)=(1,2);
sub proc2 {print $a+$b,\n}





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




Re: Can't locate MLDBM.pm ...

2003-01-28 Thread zentara
On Sun, 26 Jan 2003 16:56:50 -0500, [EMAIL PROTECTED] (Ed Sickafus) wrote:

Since loading MLDBM-2.01, non-root, on an Apache
   Cobalt Linux release 5.0 (Pacifica)
   Kernel 2.2.16C27_III on an i586  running Perl 5.005_03
a few weeks ago, I've experienced inconsistent difficulties with   use MLDBM
and   use Storable.
Storable was in place before MLDBM-2.01 was loaded.

does not compile:  Can't locate MLDBM.pm in @INC
even though 3 copies of MLDBM.pm exist.

So, I removed/reinstalled  Storable-2.05 non-root. Installation failed. The
log follows below.

 Makefile.PL produced:
   Warning: prerequisite Test::More 0.41 not found at (eval 1) line 220.
   '' is not a known MakeMaker parameter name.

 make had no warnings.

 make test produced: t/downgrade.Can't locate Test/More.pm in @INC
(and more, see below)

CHUG, chug, phfft!  :-(
Ed

So you can't install Test::More? Then Storable again? Then MLDBM again?

If this is on a remote server, on which you don't have root access, you
are probably knocking your head against a wall.  Some of these modules
need to use the c compiler to make themselves. If you do have the right
to use the compiler, install all the modules to your home directory, and
change your @INC so that your module is found first. You have to make
sure that when @INC is searched, it finds your homemade version.

Maybe you could ask the sysadmin to install the packages properly??
That would save you some trouble.





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




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

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

Hi All,

I created a cgi perl script, its an account creation script, means you 
can add an account to a linux system.

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

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

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

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

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




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




Re: My, our, local

2003-01-22 Thread zentara
On Tue, 21 Jan 2003 11:06:55 -0500, [EMAIL PROTECTED] (Paul Kraus)
wrote:

Great article. Cleared up all of my confusion. However it did not touch
on our. Anyone care to explain what its used for. 

For a practical example:
The only time I ever needed to use our is when I use
the require script method as a means of importing
some configuration variables.

Say I have a bunch of scripts which all share the
same configuration variables. I create a single
script my_config with all the variables defined in
it.
Like this:

#my_config
$customer_directory = 'customers';
$server_address = 'zentara.zentara.net/~zentara'; #basename only
$secure_server_address  = 'https://zentara.zentara.net/~zentara';
$cgi_directory = '/cgi-bin/store'; #relative to html docs dir
$imagedir= '/home/zentara/public_html/store/images';
###


Then in all the other scripts I do this:
##
our($customer_directory,$server_address,$secure_server_address,
   $cgi_directory,$imagedir);

require ./my_config;
#

  



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




Re: baffling script behavior- root loses files

2003-01-17 Thread zentara
On Thu, 16 Jan 2003 22:34:53 +0100, [EMAIL PROTECTED] (Jenda Krynicky)
wrote:

 are missing, seemingly random:

Ahh the usual mistake.

The readdir() returns just the file and subdirectory names, not 
complete paths.

Therefore if you opendir() some other directory than '.' you have to 
prepend that directory to the filenames before you do the tests.
Otherwise you are looking at the files in the current directory.

Try
   foreach (@files){push @movem,$_ if -f $homedir/$_}

Thanks guys. It makes sense now. I guess I should have taken a clue
from the fact that it worked until I switched directories. 
I guess I was thrown off by the fact that I did get some output, but
not the full output. I guess this is one of those areas where Perl
will do something unpredictable?



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




baffling script behavior- root loses files

2003-01-16 Thread zentara
Hi,
I'm just stumped by this one. It all started when I was trying to work
out a backup method of backing up all subdirs of /home/user as
individual tarballs. So I wanted to copy everything from the user's
top level directory to a temporary backup directory. This included
all hidden file, hidden directories, and plain files in /home/user.

Well, I did some testing as myself, and all seemed to be going well,
then I moved the script to /, and see what happens when root
ran it. Things went wrong, root runs the same file from /, and it
misses plain files like /home/user/sig.

I made a little test case to demonstrate the problem.
The following script is run by root in /home/user:
/home/zentara/backup-homex
---
#!/usr/bin/perl -w

@users=('/home/zentara');

#put all user-root hidden files and hidden dirs into 1 temp dir
#this makes it easier to backup second level subdirs
foreach $homedir(@users){
opendir DIR, $homedir or warn Cannot readdir $homedir:$!\n;
@files = grep !/^\.\.?$/, readdir DIR;
foreach (@files){push @movem,$_ if -f}
foreach (@files){push @movem,$_ if ($_ =~ m!^[.]!)}
print @movem\n;
print ##\n;
}
exit;


When the above script is run as user or as root in /home/zentara
the output is good:

x z z1 zz sig sig1 sig2 sigs wxyz .Xmodmap sig.perl .bashrc .fvwm2rc
.bash_history backup-homex .Xdefaults .Xauthority .profile .Xresources
dontfeedtrolls .xinitrc wxyz-root .kc .le .mc .qt .ddd .kde .pan .pfm
.ssh .netscape .designer .babygimp .gftp .gimv .fvwm .java .kde2 .sane
.skel .ssh2 .vifm .wine .xmms .Xmodmap .tkalbum .bashrc .gnome2_private
.tkphone .dosemu .mozilla .gconfd .gnome2 .gphoto .gqview .glabels
.gkrellm .fvwm2rc .acrobat .gnucash .gimp-1.2 .pgaccess .regexp
.ptknotes .nautilus .bash_history .mhwaveedit .glameswap .autozen
.kalyptus .antiword .Xdefaults .gnome-desktop .Xauthority .profile
.jpi_cache .gnome_private .Xresources .xinitrc .pornview .adobe .cedit
.dillo .gconf .foxrc .gnome .gnupg .gtklp .links .tkfax .sweep
.cddbslave .roadmap .rolodex .sylpheed .TinyCA .emacs.d .wine.bak
##

-
when the above script is run by root from /, the output misses some
plain files, notably sig, but many are missing, seemingly random:

wxyz backup-homex .kc .le .mc .qt .ddd .kde .pan .pfm .ssh .netscape
.designer .babygimp .gftp .gimv .fvwm .java .kde2 .sane .skel .ssh2
.vifm .wine .xmms .Xmodmap .tkalbum .bashrc .gnome2_private .tkphone
.dosemu .mozilla .gconfd .gnome2 .gphoto .gqview .glabels .gkrellm
.fvwm2rc .acrobat .gnucash .gimp-1.2 .pgaccess .regexp .ptknotes
.nautilus .bash_history .mhwaveedit .glameswap .autozen .kalyptus
.antiword .Xdefaults .gnome-desktop .Xauthority .profile .jpi_cache
.gnome_private .Xresources .xinitrc .pornview .adobe .cedit .dillo
.gconf .foxrc .gnome .gnupg .gtklp .links .tkfax .sweep .cddbslave
.roadmap .rolodex .sylpheed .TinyCA .emacs.d .wine.bak
##


Can someone shed some light on why this happens? It has
something to do with running it from /.

Thanks.



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




Re: newbie need help

2003-01-15 Thread zentara
On Wed, 15 Jan 2003 15:54:02 +0800, [EMAIL PROTECTED] (Glynn
S. Condez) wrote:

i have a web form that users can input a username and password and check if
the username is valid by parsing or extracting the contents of a file, here
the web form html:

I'm not sure what you are trying to do with just the username,
don't you want to check the password too?

#!/usr/bin/perl
use CGI qw(param);

$username = param('username');
$password = param('password');

$file= /home/user/public_html/file.txt;
print Content-type: text/plain\n\n;
open (F1,$file);
foreach (F1) {
chomp;
($field1,$field2,$field3,$field4,$field5,$field6) = split /\s/, $_;

if ($username =~ /\b$field2\b/) {
if (($username =~ /\b$field2\b/)and ($password =~ /\b$field3\b/)) {
print OK\n;
print $username and $password\n;

}else{
print oops try again\n;
  }
}
close(F1);


and this is the content of the file.txt:
snip
user: user1 password my.domain.com mech:PLAIN

user: user2 realm: my.domain.com mech:PLAIN
user: user3 realm: my.domain.com mech:PLAIN
user: user4 realm: my.domain.com mech:PLAIN
---snip---

my problem with this script is, it doesnt display if the
username is valid or not but valid usernames display
OK, $username and $password.

whats the problem with the else statement? kindly correct my
script.

TIA
glen
--- Glynn ---


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




Re: CSV File Creation

2003-01-15 Thread zentara
On Wed, 15 Jan 2003 08:46:04 +1100, [EMAIL PROTECTED]
(Colin Johnstone) wrote:

Is a CSV a comma delimited list. If so when creating a CSV how does one cope with 
fields that have commas in them. 

An address filed for example could be written suite 2, lvl 3.

Do you write the field names out with quotes around them?

Flak-jacket on!

A simple way around this is to use something like chr(1) for your
separator, instead of a comma. Then your only problem is to
filter all fields to exclude chr(1). chr(1) is non-printable, so when
you look at your csv files, you will see a funny symbol in place of
it. On my system, it's a diamond.

Just run all new data thru this regex:
$fielddata =~ s/chr(1)//g;
and that prevents a hacker from messing up your data.

I've been chastised before for mentioning this, because it is 
non-standard; but it works for me, and is simple.



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




Re: [Fwd: Re: perl vs tcl?]

2003-01-14 Thread zentara
On Mon, 13 Jan 2003 11:15:11 -0600, [EMAIL PROTECTED] (Sean Rowe) wrote:

I'm trying to argue my somewhat biased opinion that perl is better than 
tcl.Any experts out there 
that actually know why perl is/isn't better than tcl?

I would say modules and cpan, and it's very easy to
get help online.



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




Re: tailing a text file

2003-01-08 Thread zentara
On Tue, 7 Jan 2003 04:23:22 -0800 (PST), [EMAIL PROTECTED]
(Admin-Stress) wrote:

Hi,

Anyone have the fastest and efficien way to tail a text file ?

suppose I have a text file example.txt and I want to print the last X lines.


Well there are alot of ifs to consider. How big the file is will
determine if you want to use a method which loads each line into an
array, usually you want to avoid that.

I'm guessing that the fastest and most efficient method is to
grab a chunk off the end of the file, then read that. But this assumes
you have some sort of average line length to use to compute the
chunk size. 

#!/usr/bin/perl -w
# usage tailz  filename  
use strict;

my $filename = shift or die Usage: $0 file \n;
# Open the file in read mode
open FILE, $filename or die Couldn't open $filename: $!;

# Rewind from the end of the file 
seek FILE,0, 2;  #go to EOF
seek FILE,-2048,2; #get last 2k bytes

$/=undef;
my $tail = FILE;
print $tail\n;
exit;


If you absolutely need x number of lines instead of x number of
bytes, you can modify the above to load the chunk into an array and
print the last x lines of the array.  Some people have tried to count
the number of \n characters back from the end of the file, but I bet
just putting the chunk in an array is faster.

Here is a method which will give you the last x lines, but the catch
is you must assume an average line length to compute how big a chunk
to grab off.
###
#!/usr/bin/perl -w
# example for files with max line lengths  400, but it's adjustable
# usage tailz  filename  numberoflines
use strict;

die Usage: $0 file numlines\n unless @ARGV == 2;
my ($filename, $numlines) = @ARGV;

my $chunk = 400 * $numlines; #assume a = 400 char line(generous)

# Open the file in read mode
open FILE, $filename or die Couldn't open $filename: $!;
my $filesize = -s FILE;
if($chunk = $filesize){$chunk = $filesize}
seek FILE,-$chunk,2; #get last chunk of bytes

my @tail = FILE;
if($numlines = $#tail +1){$numlines = $#tail +1}
splice @tail, 0, @tail - $numlines;

print @tail\n;
exit;
##























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




Re: byte count

2003-01-05 Thread zentara
On Sat, 04 Jan 2003 17:32:22 -0500, [EMAIL PROTECTED] (Mark Goland)
wrote:

no, I want to use one of Crypt modules which expacts to be passed strings of
n*16 bytes. How do I go about genereting such blocks ??



#this sub makes all data blocksize of 16 bytes.
sub get16 {
my $data = shift;
print data=$data\n;
  return \0 x ( 16 - length($data)%16 ) . $data;
  }
  
exit;

#You can also use this to get data that is in a multiple of 16 bytes:
# this requires $username  16 bytes and prefix packs with spaces
#sprintf '%16s', $username;
#or you can xor it
# $filecrypted = $cipher-encrypt($file^(\0x16));

#To strip any padding after decryption:
#my $plaintext = $cipher-decrypt($secret_stuff);
#   $plaintext =~ s/^\0+//;  
# remove leading null bytes, use \s (not \0) for spaces
  

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




Re: More advanced list

2003-01-05 Thread zentara
On Sun, 5 Jan 2003 00:43:07 +0100, [EMAIL PROTECTED] (Jerry Rocteur)
wrote:

Hi,

I'm looking for a Perl list a bit more advanced that this one, you 
know, not beginners questions..

I love this list and I'm learning a lot from it but I'm wondering if 
there is another list with less hello world or Visual basic is better 
than Perl type comments, preferably NO WINDOWS but I guess 
unfortunately that is impossible ??

Any ideas ???

Go to http://perlmonks.org  

Become a monk, and go thru the newest nodes everyday.
The high monks there are the best, and you can always
count on them for deep insight into Perl.




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




Re: Crypting

2003-01-04 Thread zentara
On Sat, 04 Jan 2003 01:15:40 -0500, [EMAIL PROTECTED] (Mark Goland)
wrote:


Does anyone know a good place to start on encryption socket streams ??

use Net::EasyTCP;

It has built-in encryption.





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




Re: taint question

2003-01-03 Thread zentara
On Thu, 2 Jan 2003 23:36:04 -0600, [EMAIL PROTECTED] (Reactor)
wrote:

I am fairly new to perl, so this is probably looks like a silly question:
I am trying to write text to a file as specified by the query string
environment variable.  Since the file names are all numbers, I'm using a
regex to strip anything other than a digit from the variable, and assign the
new value to a variable.  I've R-ed a few different FM's for the way to do
this, and it says to use the regex memory value, which isn't tainted.  When
I try this using my current regex it leaves the $1 variable undefined.  Code
snipet:


@temp = split(/=/, $ENV{'QUERY_STRING'});
$temp[0] =~ s/([^0-9])//g;
$filename = $1;


I made a sort of mini-debug function that prints out each variable.  It
prints the unprocessed query string after spliting and the value of $temp[0]
after processing (which is all numbers) correctly, but the variable
$filename doesn't have a value...  Not sure where I went wrong with this...
Unless the $1 is null because the matched pattern is deleted... or does the $1 hold 
the return value?

Well you definitely are thinking the right way as far as using
the taint mode. 
Your problem is a common one with regexes, make sure you are
matching or $1 will be undefined. Usually they do something like:

if($temp[0] =~ s/([^0-9])//g){$filename = $1}
else warn no match\n;


Try some more debugging, I'm sure the regex isn't doing what you
think it supposed to be doing. Try printing $temp[0] before and
after the regex. It might be as simple as
$temp[0] =~ s/([^0-9])/$1/g;

Otherwise, post some sample data, and the regex experts can
help you make the proper match.



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




Re: Membership Database

2002-12-30 Thread zentara
On Sun, 29 Dec 2002 15:33:38 -0500, [EMAIL PROTECTED] (Lewis
Kirk) wrote:

Anybody know of a simple cgi program for managing a membership 
database (flatfile or other)? Features should include allowing 
members to edit certain info with a username password login. Ability 
to display only certain fields in an html page. Searchable on 
multiple fields. Easily customizable. Thanks!

dbman is free to use for non-profits or personal use,
shareware for profit use.
It's easy, and works well.

http://www.gossamer-threads.com/scripts/dbman/


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




Re: Best SMS module?

2002-12-28 Thread zentara
On Thu, 26 Dec 2002 18:51:47 -, [EMAIL PROTECTED] (Dan) wrote:

What's the best (and easiest to use) SMS module available? Any ideas?

All help appreciated.

Look at sendSMS.pl
at
http://caspian.dotconf.net/menu/Software/


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




Re: Hooking a perl script to xinetd

2002-12-28 Thread zentara
On Fri, 27 Dec 2002 12:17:36 -0600, [EMAIL PROTECTED] (Michael
Weber) wrote:

I have a script that listens on a port for a connection, receives some
data over that connection, and writes it to a file.

This works, but it takes up CPU cycles, RAM etc. when it waits.  I am
trying to get the script to use xinetd instead.  That way the tcp daemon
will launch it when needed and let it die when it's done.

What I get when xinetd runs it,however, is bind: Address already in
use.

Here's the script.  (Fervent readers of Ellie Quigley will recognize it
right off as a modified copy of Example 18.21.

I'm just hazarding a quess here, but I just saw a similar discussion
about inetd. The gist was that when you use inetd (or maybe in your case
xinetd), the program just needs to read and write to STDIN and STDOUT.
xinetd takes care of the socket.


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




Re: CGI scripts permissions

2002-12-27 Thread zentara
On Wed, 25 Dec 2002 19:39:58 +, [EMAIL PROTECTED] (Philip
Pawley) wrote:

I'm a newbie, so the below is a question: Is this problem of cgi permissions 
different when you are just running a perl script from a virtual include - as I am?

Reading this thread, I did some tests and changed my script's permissions to 500 and 
it still works fine. (I first did it just for a test script of course)! 

I am just an ordinary user (in my own group) on the web server. How is this possible?

You probably have suexec running on the webserver. mode 500 means that
the user can read and execute the script.  Normally the httpd daemon
will be nobody/nogroup, or something similarly underprivileged.
With suexec, you are letting the httpd daemon run as user/users.

I said that it has it's drawbacks. That's why if you do use it for
something important, make a separate user just to run that cgi script.

Here is a little test script to run:
First run it and see what you get, then go and rename
/usr/sbin/suexec to suexec.bak and restart apache. Then
see what you get.

###
#!/bin/sh
echo Content-type: text/plain
echo 
echo Username=`whoami`
###






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




Re: CGI scripts permissions

2002-12-25 Thread zentara
On Wed, 25 Dec 2002 05:34:04 +0200, [EMAIL PROTECTED] (Octavian Rasnita)
wrote:

Yes I know these, but ... it seems there is no solution.

1. The web server is not in the same group with me, and if it will be made
to stay in the same group with me, the other users that have web pages on
that server will need to be added to that group.

2. I saw that I need to give read permission also for a script to work, not
only execute permissions.

The only solution would be to run the Apache server with my user, but I
don't know how to do that.
How is this possible?

Apache has the suexec program to do this. If suexec is in the
path when apache starts up, then the httpd will run as 
user when in the user's home directory. This has advantages
and disadvantages, but it is easily done.
Normally apache will run as wwwrun/nogroup or nobody/nogroup,
with suexec, apache will run as user/users when in users public_html.
You can then run scripts at mode 700.

It usually is best to set aside a dedicated user just for some
cgi-program.


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




Re: IF statments

2002-12-23 Thread zentara
On Mon, 23 Dec 2002 01:33:58 -0600, [EMAIL PROTECTED] (David
Gilden) wrote:

I would like to be able to test for either of the two secret words
but it seems to fail,  what am I missing?

#!/usr/bin/perl 
use CGI qw/:standard/;
use CGI::Carp qw(fatalsToBrowser);
use strict;

my $qs = $ENV{'QUERY_STRING'};

my $secret_word  = 'one';
my $secret_word_guest  = 'two';

if (($qs ne $secret_word_guest) or ($qs ne $secret_word)) {
print Bad password; 
exit;
} 

Hi, I think your problem is that you are using
my $qs = $ENV{'QUERY_STRING'};  
and you are expecting it to match, it dosn't.

The $ENV{'QUERY_STRING'} actually looks something like
somewordsomeotherword  
or it may look like
someword=thissomeword=that

So 
if (($qs ne $secret_word_guest) or ($qs ne $secret_word)) {
print Bad password; 

should always say Bad Password

You might be able to get away with using a regex instead of ne
if (($qs !~ $secret_word_guest) or ($qs !~ $secret_word)) {
print Bad password; 

But you are better off using the params given to you by
CGI.pm

if ( param('secret_word) ne $secret_word) or
  ( param('secret_word_guest) ne $secret_word_guest))
{print 'Bad Password'}

You might want to improve that logic, I'm not sure if it does
what you really intend. Like maybe:

if ( param('secret_word) eq $secret_word) or
  ( param('secret_word_guest) eq $secret_word_guest))
{print 'Good Password'}
else {print 'Bad Password'}











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




Re: IF statments -- part 2

2002-12-23 Thread zentara
On Mon, 23 Dec 2002 02:10:17 -0600, [EMAIL PROTECTED] (David
Gilden) wrote:

This is not working either

# Goal, to check against two different passwords.

#!/usr/bin/perl 
my $qs = 'c';
my $secret_word  = 'a';
my $secret_word_guest  = 'b';

if ($qs !~ /$secret_word_guest|$secret_word/) {
print fail\n; 
} else { print go, ok\n;}

... more code...


What should happen is that if $secret_word OR $secret_word_guest does not Match $qs 
Then it should print 'Fail'.

Please see if you can explain  why this in not working,

It works exactly as you wrote it.

You are telling it if c does not match a or b print fail.

Try putting $qs = 'a'   it works fine.
Logic will get you twisted into a pretzel. :-)


Maybe you want
print fail\n unless ($qs =~ /$secret_word_guest|$secret_word/);





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




  1   2   3   4   >