Re: export constants from package
Drieux wrote: > > On Wednesday, Nov 19, 2003, at 06:38 US/Pacific, Haim Ashkenazi wrote: > >> Hi >> >> I'm writing a module to serve a script I'm writing and I was wondering >> if >> it's possible to add a constant to the @EXPORT array. I prefer not to >> use >> variables because these settings shouldn't be changed, but I want every >> script that uses this module to be able to access these constants. >> >> I read somewhere that you can declare your constants like this: >> *BLAH = \"blah blah"; >> and then export $BLAH. >> >> I tested it and it works, but I wanted to know if that's a good way of >> doing >> it, or there's a better one in terms of speed and memory usage. > > well first off do you mean > > use constant MY_CONSTANT => 82 ; # capitalizing them can help ID them. > > { cf. perldoc constant } > > which is how I put them into a production perl module. > > Then think in terms of whether you want to have them > always exported, eg @EXPORT, or can you 'bundle' them > in %EXPORT_TAGS eg: > > our %EXPORT_TAGS = ( 'all' => [ qw( ) ], > 'constants' => [ qw() ], > > ); > > This way if some of the constants natively cluster with > some of the functions, then you can think in terms of > and code the 'traditional' form of > > bail_out($thing,$poo,$err_num) > if( my_got_error($that_return) == MY_CONSTANT ); > > which while 'traumatizing' some of the "c-coders" could > be 'repositioned' for them as > > if( my_got_error($that_return) == MY_CONSTANT ) { > bail_out($thing,$poo,$err_num); > } > > Is that the sort of idea that you are looking at? > or would the 'accessor' method be more interesting? > > sub get_my_constant { MY_CONSTANT ; } > > so that you could have > > if ( $obj->my_got_error($that_return) == $obj->get_my_constant() ) { > bail_out($thing,$poo,$err_num); > } I was talking about the first example, but I think I've made a mistake... I tried to add the constant to to my @EXPORT (which was declared with "use constant ...") and I've got an error. I was probably too quick to assume it can't be done that way, instead of trying to figure out the error... I tried it again now and it works. so, thanks Bye -- Haim -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
export constants from package
Hi I'm writing a module to serve a script I'm writing and I was wondering if it's possible to add a constant to the @EXPORT array. I prefer not to use variables because these settings shouldn't be changed, but I want every script that uses this module to be able to access these constants. I read somewhere that you can declare your constants like this: *BLAH = \"blah blah"; and then export $BLAH. I tested it and it works, but I wanted to know if that's a good way of doing it, or there's a better one in terms of speed and memory usage. thanx -- Haim -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: 3 CGI questions
Jenda Krynicky wrote: > From: Haim Ashkenazi <[EMAIL PROTECTED]> >> 1. when I put "#!/usr/bin/perl -wT" at the beginning of the file, and >> running "perl -cw
3 CGI questions
Hi I'm writing some web scripts using CGI for (almost) the first time and I have some questions/problems (perl 5.6.1): 1. when I put "#!/usr/bin/perl -wT" at the beginning of the file, and running "perl -cw
RE: "stty -echo" replacement for windows
Tn wrote: > Suggest you install and use cygwin including its perl package. It > includes Term::Readkey and the other core packages. I just did a cygwin > installation on win2k yesterday and it went smoothly. Note that emacs > and midnight commander are the only default editors, but nano and vim > are selectable as options. thanx, but as I said on my previous reply, I need it to be on activestate perl (so I can use their "perlapp" application). thanx -- Haim > > -tristram > > -----Original Message- > From: Haim Ashkenazi [mailto:[EMAIL PROTECTED] > Sent: Monday, October 06, 2003 7:13 PM > To: [EMAIL PROTECTED] > Subject: Re: "stty -echo" replacement for windows > > > John W. Krahn wrote: >> perldoc -q password >> >> Found in /usr/lib/perl5/5.6.0/pod/perlfaq8.pod >>How do I ask the user for a password? >> >>(This question has nothing to do with the web. See a >>different FAQ for that.) >> >>There's an example of this in the crypt entry in the >>perlfunc manpage). First, you put the terminal into "no >>echo" mode, then just read the password normally. You may >>do this with an old-style ioctl() function, POSIX terminal >>control (see the POSIX manpage, and Chapter 7 of the >>Camel), or a call to the stty program, with varying >>degrees of portability. >> >>You can also do this for most systems using the >>Term::ReadKey module from CPAN, which is easier to use and >>in theory more portable. >> >>use Term::ReadKey; >> >>ReadMode('noecho'); >>$password = ReadLine(0); > thanx, I've seen this solution. the problem is that on activeperl (the > perl I will use in windows, because of the application they have that > generate a binary with interperter) they don't have Term::ReadKey as a > ppm, and we don't have a compiler for windows to try and compile it > ourselves. anyway someone told me that windows machines have an "echo > off/on" command so I will try to run it and see if it works. > > thanx > -- > Haim > > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: "stty -echo" replacement for windows
John W. Krahn wrote: > perldoc -q password > > Found in /usr/lib/perl5/5.6.0/pod/perlfaq8.pod >How do I ask the user for a password? > >(This question has nothing to do with the web. See a >different FAQ for that.) > >There's an example of this in the crypt entry in the >perlfunc manpage). First, you put the terminal into "no >echo" mode, then just read the password normally. You may >do this with an old-style ioctl() function, POSIX terminal >control (see the POSIX manpage, and Chapter 7 of the >Camel), or a call to the stty program, with varying >degrees of portability. > >You can also do this for most systems using the >Term::ReadKey module from CPAN, which is easier to use and >in theory more portable. > >use Term::ReadKey; > >ReadMode('noecho'); >$password = ReadLine(0); thanx, I've seen this solution. the problem is that on activeperl (the perl I will use in windows, because of the application they have that generate a binary with interperter) they don't have Term::ReadKey as a ppm, and we don't have a compiler for windows to try and compile it ourselves. anyway someone told me that windows machines have an "echo off/on" command so I will try to run it and see if it works. thanx -- Haim -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: "stty -echo" replacement for windows
Haim Ashkenazi wrote: > Hi > > I'm writing a script on windows that's intended to run on windows (well, I this is an error of-course. I'm writing it on linux :) > don't have windows at home so...), and I'm looking for something to > replace the "stty -echo" command on linux: > > print "Password: "; > system "stty -echo"; # disable echo > chomp (my $pass = ); > system "stty echo"; # enable echo > > any ideas? > > thanx > -- > Haim -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
"stty -echo" replacement for windows
Hi I'm writing a script on windows that's intended to run on windows (well, I don't have windows at home so...), and I'm looking for something to replace the "stty -echo" command on linux: print "Password: "; system "stty -echo"; # disable echo chomp (my $pass = ); system "stty echo"; # enable echo any ideas? thanx -- Haim -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: problem with Net::SSH::Perl using dsa key authentication
Tn wrote: > Hi, > > As far as I can tell you are doing it right according to the manpages. > However, I noticed that in > http://www.squarebox.co.uk/cgi-squarebox/manServer/usr/share/man/man3/Ne > t::SSH::Perl.3pm that $ssh->login() requires a password that you aren't > supplying: > > $ssh->login("user1", "pass1"); > > I believe this refers to the linux password. Perhaps if the password is > not supplied for an interactive login then you will be prompted for it. > But you could disable linux password authentication as an ssh option at > least as a possible workaround: > > PasswordAuthentication=no # to be added to my %params > > As I recall the default config of sshd/ssh forces password > authentication on top of publickey authentication as an extra security > measure. You might take a look at your sshd and ssh config files to see > how they are set and a combination of tweaking them and the options in > your script may fix the problem. > > The sshd/ssh setup that I prefer requires no password authentication if > publickey authentication works, however it will use password > authentication if publickey authentication does not work and I cut keys > with a null passphrase for easier automation of script execution and > interactive logins. > > The error message seems to refer to a ssh_agent setup. Ssh_agent is a > special daemon that caches private keys and their passphrases so that > you don't have to keep supplying the latter on the command line to start > new sessions. I've never bothered setting it up but using it should be > more secure than using keys with null passphrases. > > For reference: > > Instructions for ssh_agent configuration are at > http://www.redhat.com/docs/manuals/linux/RHL-9-Manual/custom-guide/s1-op > enssh-client-config.html#S3-OPENSSH-CONFIG-SSH-AGENT. > > Manpages for openssh are at http://www.openssh.org/manual.html > > Manpages for perl ssh modules are at > http://www.squarebox.co.uk/cgi-squarebox/manServer/usr/share/man/man3/ > > I don't have a setup now for testing ssh or I would. > > Please let me know what works when you find it. > > -tristram > [EMAIL PROTECTED] Hi I'm using ssh with only key authentication in most of my linux servers. the problem is not in the configuration (i think). I guess it's a matter of running ssh-agent from the perl interface (since I've entered the Net::SSH::Perl::Auth it ignores the one that's already running as the parent of my X session). thanx -- Haim -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: problem with Net::SSH::Perl using dsa key authentication
Wiggins D'Anconia wrote: >> my %params = { >> protocol => 2, >> interactive => 1, >> identity_files =>[EMAIL PROTECTED], >> }; > > Right here you are assigning a hash reference to a hash, which is > essentially setting a key using the reference location with a value as > undef. Then you pass the hash to the new constructor and it sees a > single value which is why you are getting there warning/error about > "Reference found where even sized list expected"... Switch the braces > in the above construct to parenthesis and it should work, or switch the > hash to a hash dereference below and the hash to a scalar above. well, this one did solve the even-sized list error/warning but not the "agent" method error. I think I must run some kind of ssh-agent before, but I have no idea how to implement this. (I actually have it running as the parent of my X, but since I've added the Net::SSH::Perl::Auth, it just ignores it. before I've added it, it accepted the linux ssh-agent as the authentication and didn't prompt me for a password). thanx -- Haim -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: problem with Net::SSH::Perl using dsa key authentication
Tn wrote: > Hi, > > As far as I can tell you are doing it right according to the manpages. > However, I noticed that in > http://www.squarebox.co.uk/cgi-squarebox/manServer/usr/share/man/man3/Ne > t::SSH::Perl.3pm that $ssh->login() requires a password that you aren't > supplying: > > $ssh->login("user1", "pass1"); > > I believe this refers to the linux password. Perhaps if the password is > not supplied for an interactive login then you will be prompted for it. > But you could disable linux password authentication as an ssh option at > least as a possible workaround: > > PasswordAuthentication=no # to be added to my %params > > As I recall the default config of sshd/ssh forces password > authentication on top of publickey authentication as an extra security > measure. You might take a look at your sshd and ssh config files to see > how they are set and a combination of tweaking them and the options in > your script may fix the problem. > > The sshd/ssh setup that I prefer requires no password authentication if > publickey authentication works, however it will use password > authentication if publickey authentication does not work and I cut keys > with a null passphrase for easier automation of script execution and > interactive logins. > > The error message seems to refer to a ssh_agent setup. Ssh_agent is a > special daemon that caches private keys and their passphrases so that > you don't have to keep supplying the latter on the command line to start > new sessions. I've never bothered setting it up but using it should be > more secure than using keys with null passphrases. > > For reference: > > Instructions for ssh_agent configuration are at > http://www.redhat.com/docs/manuals/linux/RHL-9-Manual/custom-guide/s1-op > enssh-client-config.html#S3-OPENSSH-CONFIG-SSH-AGENT. > > Manpages for openssh are at http://www.openssh.org/manual.html > > Manpages for perl ssh modules are at > http://www.squarebox.co.uk/cgi-squarebox/manServer/usr/share/man/man3/ > > I don't have a setup now for testing ssh or I would. > > Please let me know what works when you find it. > > -tristram > [EMAIL PROTECTED] Hi I'm using ssh with only key authentication in most of my linux servers. the problem is not in the configuration (i think). I guess it's a matter of running ssh-agent from the perl interface (since I've entered the Net::SSH::Perl::Auth it ignores the one that's already running as the parent of my X session). thanx -- Haim -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: problem with Net::SSH::Perl using dsa key authentication
Wiggins D'Anconia wrote: >> my %params = { >> protocol => 2, >> interactive => 1, >> identity_files => [EMAIL PROTECTED], >> }; > > Right here you are assigning a hash reference to a hash, which is > essentially setting a key using the reference location with a value as > undef. Then you pass the hash to the new constructor and it sees a > single value which is why you are getting there warning/error about > "Reference found where even sized list expected"... Switch the braces > in the above construct to parenthesis and it should work, or switch the > hash to a hash dereference below and the hash to a scalar above. well, this one did solve the even-sized list error/warning but not the "agent" method error. I think I must run some kind of ssh-agent before, but I have no idea how to implement this. (I actually have it running as the parent of my X, but since I've added the Net::SSH::Perl::Auth, it just ignores it. before I've added it, it accepted the linux ssh-agent as the authentication and didn't prompt me for a password). thanx -- Haim -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
problem with Net::SSH::Perl using dsa key authentication
Hi I'm trying to write a simple ssh login script using Net::SSH::Perl. with regular password It's working without a problem, but when I try to use dsa key (my usual dsa key) it doesn't work. here's the scritp: #!/usr/bin/perl -w use strict; use Net::SSH::Perl; use Net::SSH::Perl::Auth; my @ids = ("/home/haim/.ssh/identity"); my %params = { protocol => 2, interactive => 1, identity_files =>[EMAIL PROTECTED], }; my $login = Net::SSH::Perl->new("coltrane", %params); my $auth = Net::SSH::Perl::Auth->new('PublicKey', $login); $auth->authenticate; $login->login("haim"); $login->shell; When I run this script I get an error: Reference found where even-sized list expected at login.pl line 10. Can't call method "agent" on an undefined value at /usr/local/share perl/5.8.0/Net/SSH/Perl/Auth/PublicKey.pm line 39, line 1. I've looked into the Net::SSH::Perl::Agent manpage but I can't figure out how do I use it. can anyone please help? thanx -- Haim -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]