Richard Fernandez

2013-06-17 Thread Richard Fernandez
wer
http://estetikburuncerrahisi.com/mr/lybibl/cddhmsewykrj/ubpejcbsumykym.php
Richard Fernandez


RE: Sometimes Net::SSH2 can't read() from channel?

2008-04-10 Thread RICHARD FERNANDEZ
 

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of zentara
 Sent: Thursday, April 10, 2008 9:31 AM
 To: beginners@perl.org
 Subject: Re: Sometimes Net::SSH2 can't read() from channel?
 
 On Wed, 9 Apr 2008 17:20:06 -0400, [EMAIL PROTECTED] (RICHARD
 FERNANDEZ) wrote:
 
 Hi folks,
  
 I have a test script ( mostly ripped from a posting I found on a CPAN
 forum) which uses Net::SSH2 to run a `who' command on a 
 remote server.
 The script works fine for most servers, but I have a few 
 boxes where, 
 despite being able to login, I get no output.
 Anyone have any ideas why this might be happening?
  
 Try setting: 
 
 $chan-blocking(0);
 
 my $chan = $ssh2-channel();
 
 zentara
 

Thank you, zentara. It seems this is what was needed.

richf

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Sometimes Net::SSH2 can't read() from channel?

2008-04-09 Thread RICHARD FERNANDEZ
Hi folks,
 
I have a test script ( mostly ripped from a posting I found on a CPAN
forum) which uses Net::SSH2 to run a `who' command on a remote server.
The script works fine for most servers, but I have a few boxes where,
despite being able to login, I get no output. 
Anyone have any ideas why this might be happening?
 
TIA
 
richf
 
#!/usr/local/bin/perl
use warnings;
use strict;
use Net::SSH2;
use Getopt::Std;
 
our($opt_s, $opt_p);
getopts('p:s:');
 
my $passwd = $opt_p ? $opt_p : usage();
my $server = $opt_s ? $opt_s : usage();
 
print Connecting to $server...\n;
 
my $ssh2 = Net::SSH2-new();
$ssh2-debug(1);
$ssh2-connect($server) or die Can't connect to $server\n;
 
if( $ssh2-auth_password('root', $passwd)) {
my $chan = $ssh2-channel();
my $returnval = $chan-exec('who') or die Couldn't exec
'who'\n;
 
my($len, $buff);
while($len = $chan-read($buff, 1024)) {
print $buff;
}
$chan-close;
}
else {
print Invalid username or password $!\n;
}
 
 
sub usage {
die usage: $0 -s server -p passwd\n;
}

 
[EMAIL PROTECTED]:/home/richf/bin] ./mytest.pl -s server1 -p passwd
Connecting to server1...
libssh2_channel_open_ex(ss-session, pv_channel_type, len_channel_type,
window_size, packet_size, 0L , 0 ) - 0x89bb0600
Net::SSH2::Channel::read(size = 1024, ext = 0)
- read 44 bytes
- read 0 bytes
- read 44 total
root tty1 Mar  9 10:55 
Net::SSH2::Channel::read(size = 1024, ext = 0)
- read 0 bytes
- read 0 total
Net::SSH2::Channel::DESTROY
Net::SSH2::DESTROY object 0x867c4c80
[EMAIL PROTECTED]:/home/richf/bin] 
[EMAIL PROTECTED]:/home/richf/bin] 
[EMAIL PROTECTED]:/home/richf/bin] ./mytest.pl -s server2  -p passwd
Connecting to server2...
libssh2_channel_open_ex(ss-session, pv_channel_type, len_channel_type,
window_size, packet_size, 0L , 0 ) - 0x8241e600
Net::SSH2::Channel::read(size = 1024, ext = 0)
- read 0 bytes
- read 0 total
Net::SSH2::Channel::DESTROY
Net::SSH2::DESTROY object 0x81245b40



Net::SSH::Perl won't set SSH options?

2008-04-02 Thread RICHARD FERNANDEZ
Hi folks,
 
I have a test script that remotely runs a command via SSH. The problem
is that I get prompted to accept a host key if it's missing from my
known_hosts file.
The ssh option StrictHostKeyChecking if set to 'no' is supposed to
accept a missing host key. I've tested this and it works from a command
line, but 
I can't get the following code to do the same. (I don't think the
ConnectTimeout works correctly either, FYI).
 
Can anyone see what I'm doing wrong?
 
Thanks!
 
richf
 
#!/usr/local/bin/perl 
use warnings;
use strict;
use Net::SSH::Perl;
 
my %config = (
server  = 'server',
passwords   = [qw(foo bar)],
command= 'who',
user= 'root',
);
 
my $output = collect_data_over_ssh(\%config);
print \n\n, @$output, \n\n;
 
sub collect_data_over_ssh {
my $config = shift;
 
my $server  = $config-{server};
my $passwords   = $config-{passwords}; # array ref
my $command = $config-{command};
my $user= $config-{user};
 
my @output;
my $stdout;
my $stderr;
my $exit;
 
my %options = (
debug = 1,
options = [
ConnectTimeout 3,
StrictHostKeyChecking no,
],
);
 
 
PASSWD:
for my $pass (@$passwords) {
 
my $ssh = Net::SSH::Perl-new($server, %options) or warn
Can't connect via SSH $!\n;
 
eval {
$ssh-login($user, $pass);
};
next PASSWD if ($@);
 
($stdout, $stderr, $exit) = $ssh-cmd($command);
 
if ($stdout) {
@output = $stdout;
}
else {
@output = $stderr;
}
last PASSWD;
}
return [EMAIL PROTECTED];
}



Trouble with CPAN login

2008-03-06 Thread RICHARD FERNANDEZ
Hi folks,
 
I'm trying to access a local CPAN mirror over FTP and am unable to
connect.
 
cpan reload index
CPAN: Storable loaded ok
Going to read /.cpan/Metadata
  Database was generated on Tue, 26 Feb 2008 05:31:07 GMT
CPAN: LWP::UserAgent loaded ok
Fetching with LWP:
  ftp://cpan.arrow.com/CPAN/authors/01mailrc.txt.gz
LWP failed with code[401] message[Login incorrect.]
Fetching with Net::FTP:
  ftp://cpan.arrow.com/CPAN/authors/01mailrc.txt.gz
Couldn't login on cpan.arrow.com at /usr/local/lib/perl5/5.8.0/CPAN.pm
line 2178.
Fetching with LWP:
  http://cpan.arrow.com/CPAN/authors/01mailrc.txt.gz
^CCaught SIGINT

 
The http call fails because we don't have port 80 open (I might be able
to fix that later), but ftp works fine from a command line. It looks to
me like it's trying to login as anonymous even though I have
configured username and password through the CPAN shell.
 
Does anyone know if there's a way around this other than hacking CPAN.pm
which I wouldn't be crazy about doing?
TIA
 
richf


RE: Trouble with CPAN login

2008-03-06 Thread RICHARD FERNANDEZ
 
-Original Message-
From: Rodrick Brown [mailto:[EMAIL PROTECTED] 

looks like local user error are you sure the credentials your supplying
are correct?



Hi Rodrick,

The credentials I've configured in CPAN match the ones in my .netrc file
which allows me to login successfully from a command line. In addition I
took a look at CPAN.pm (the line referenced in the error was 2178):

 2177unless ( $ftp-login(anonymous,$Config::Config{'cf_email'})
){
  2178  warn Couldn't login on $host;
  2179  return;
  2180}

Looks to me like anonymous is hard coded in there...unless I'm missing
something?

Is anyone else successfully using a username/password to log into cpan?

Thanks.

richf


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




RE: IO::Compress::Gzip creates empty file

2008-02-01 Thread RICHARD FERNANDEZ
 If you've just written the file, have you closed the 
 filehandle and checked the return value?
 
 Paul Johnson - [EMAIL PROTECTED]
 http://www.pjcj.net



Well, I've just learned a valuable lesson (or two), which is, after all,
what I'm on this list for :)

Just prior to the code I've already posted I have this:

snip
# @unixfile was created earlier
open $unixfile, '', $company.$ext or die Can't open
$company.$ext for dos2unix process\n;
for (@unixfile) {
   s#\r\n#\n#;# Replace CRLF with LF
   print $unixfile $_;  # Write the edited version back to
the file
}
# End dos2unix #

* This close fixed the problem *
close $unixfile or warn Unable to close
$company.$ext\n;

rename $company.$ext, $company.$ext.$date;

print Creating gzip'd archive\n;

gzip $company.$ext.$date= $company.$ext.$date.gz,
  BinModeIn   = 1 or do {
 warn Failed to gzip file: $company.$ext.$date:
$GzipError\n;
 next DOTDONE;
};
/snip

I was relying on Perl closing files for me, but in this particular case,
I hadn't thought it through
well enough.

Many thanks to all for helping me get a handle on this!

richf
 

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




IO::Compress::Gzip creates empty file

2008-01-31 Thread RICHARD FERNANDEZ
Hi Folks,

I have the following code:

snip
use IO::Compress::Gzip qw(gzip   $GzipError);

...then...

gzip $company.$ext.$date = $company.$ext.$date.gz,
  BinModeIn= 1 or do {
 warn Failed to gzip file: $company.$ext.$date:
$GzipError\n;
 next DOTDONE;
};
/snip

The file $company.$ext.$date is created in the immediately preceding
step and definitely contains data, but the resulting compressed file is
empty, and the warn statement is not executed.

I've extracted and wrapped this code to create a little test program
which works fine, that is, the resulting compressed file contains the
data I expect.

Does anyone know what could possibly be going wrong? Same code, 2
different programs. One works the other does not.
I'm baffled.

Any help is appreciated.

richf


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




RE: IO::Compress::Gzip creates empty file

2008-01-31 Thread RICHARD FERNANDEZ

 Hi Tom, thanks for the reply.

   my $old_name = $company.$ext.$date;
   my $new_name = $old_name.gz;
   warn File '$old_name' is empty if -z $old_name;
   warn File '$old_name' isn't really a file unless -f _;
   unlink $new_name;  # whether it's there or not
   gzip $old_name = $new_name,
 BinModeIn = 1
   or do {
 warn Failed to gzip file: '$old_name': $GzipError;
 next DOTDONE;
   };
   warn File '$new_name' not created as expected
 unless -f $new_name and -s _;
 

I made the changes you suggested and re-ran it. The program just comes
back to a prompt. No warnings, no nothing, and still no data in the
gzip'd file!

Your code, though, prompts a question on syntax. In 2 places you specify
an underscore without a '$' in front of it. This is the first time I've
seen this. Running 'perl -c' says the syntax is clean, but I couldn't
find any reference to that usage in perlsyn. Is the '$' implied because
of the context?

Can you please explain or point me to the doc? Thanks.

  Are you using both 'strict' and 'warnings'?
 

I am using both 'strict' and 'warnings'. Doesn't everyone ;)

Thanks again.

richf

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




RE: IO::Compress::Gzip creates empty file

2008-01-31 Thread RICHARD FERNANDEZ
 No warnings? H Are you sure your program actually ran 
 the new code? That should have generated at least one 
 warning. Is there any chance you've redirected or closed the 
 STDERR filehandle? You can always add a line like this during 
 development, if you need to be sure the new code is being 
 reached and that warnings are showing up:
 
   warn Yes; execution does reach this point;


Strange, I agree. 

Immediately before your test code I have a line that reads:

print Creating gzip'd archive\n;

and after the job runs, I definitely end up with a .gz file, just an
empty one.

I hate to do it, but I guess I'll have to shell out. Can't spend any
more time on this, unless anyone
else has any more ideas? 

Thanks for looking at it, though. I appreciate it.

richf

 

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




RE: Creating an encrypted zipfile on Unix for Windows users

2008-01-11 Thread RICHARD FERNANDEZ
Create a Zip archive instead man zip for more information 

  -e Encrypt  the  contents of the zip archive using a
password which
  is entered on the terminal in response to a
prompt  (this  will
  not  be  echoed;  if  standard error is not a tty,
zip will exit 
  with an error).  The password prompt is  repeated
to  save  the
  user from typing errors.




-- 
Rodrick R. Brown
http://www.rodrickbrown.com
http://www.rodrickbrown.com  
 
 
 
Thanks Rodrick!
 
Yeah, I saw this after I mailed the group. It's probably
the way I will end up going, but I sure would like to have a Perl
solution instead.
If I use /usr/bin/zip, I'll still have to shell out.
OTOH, I need to wrap this up...
 
Thanks for your reply.
 
richf



Creating an encrypted zipfile on Unix for Windows users

2008-01-10 Thread RICHARD FERNANDEZ
Hi folks,

I'm writing a script that basically creates a bunch of files, packages
them up (tar/gz), and mails them out.
I can handle all of that, but before I mail them I also have to password
protect the archive like pkzip does.
I really don't want to shell out to pkzip if I can avoid it.

I checked CPAN, of course, but Archive::Zip which seemed the likely
candidate doesn't do encryption.
Crypt::OpenPGP or similar is also no good since I can't (much as I'ld
like to) use public key.

I didn't see any others that do what I need, which is create a WinZip
compatible encrypted archive which is easily opened by a Windows user
with the password which I would provide separately.

Any advice/docs/hints would be much appreciated.

Thank You!

richf

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




RE: :FTP troubles with passive

2007-11-20 Thread RICHARD FERNANDEZ
 

 -Original Message-
 From: Andrew Curry [mailto:[EMAIL PROTECTED] 
 
 Passive - If set to a non-zero value then all data transfers 
 will be done using passive mode. If set to zero then data 
 transfers will be done using active mode.

Sheesh. I must've read that line 50 times but never that way.

If I say:

 my $ftp = Net::FTP - new($server, Passive = 0)...

it does indeed use active mode.

Sometimes you just need another pair of eyes :)

Thanks!

richf

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




RE: chomp operator

2007-10-30 Thread RICHARD FERNANDEZ
 Hi,
 

Hello,

 so where does the chomp operator plays its role, can some one 
 explain me here with a sample of code.
 
 Thanks and Regards
 
 Kaushal
 

One place where chomp() comes in handy is when you're reading from a
file.
Usually a line read from a file will have a newline at the end.

The terminating new line may get in the way of your processing, here's a
contrived example:

my $foo = 'some text to append to line\n';
open my $TESTFILE, '', '/some/test/file') or die;
while ( defined (my $line = TESTFILE) ) {

# $line contains 'Some arbitrary text \n'
print $line, $foo;
}

Without a 'chomp $line' the program will print:
Some arbitrary text 
some text to append to line

Instead of:
Some arbitrary text some text to append to line

as was probably intended.

HTH

richf

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




RE: Net::SFTP

2007-10-24 Thread RICHARD FERNANDEZ
 -Original Message-
 From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of 
 Jeff Pang
 Sent: Wednesday, October 24, 2007 8:22 AM
 To: Octavian Rasnita
 Cc: beginners perl
 Subject: Re: Net::SFTP
 
 I have seen many guys on this list mentioned Net::SSH install 
 problems.
 Maybe you can force to install it without `make test` steps?

I've always had to force it because of this problem and it's always
worked.
Just my 2 cents :)

richf

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Changing CPAN config before initial config?

2007-09-26 Thread RICHARD FERNANDEZ
Hi folks,

I have a lot of boxes which are behind firewalls. Fortunately, I have a
local CPAN mirror that I install modules from.
The problem is that often when I run the CPAN shell (# perl -MCPAN
-eshell) I am asked the question: Are you ready for manual
configuration?. After I answer yes at some point it tries to grab the
MIRRORED.BY file from ftp.perl.org. This process takes quite a while
since it tries many things to reach the outside world. Finally it quits
and I can tell it where my CPAN mirror is.

Is there any way to configure the urllist with my mirror before doing
the manual config? I read perldoc CPAN but didn't see any way to do
this.

Thanks.

richf

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




RE: Changing CPAN config before initial config?

2007-09-26 Thread RICHARD FERNANDEZ
 

 -Original Message-
 From: Srinivas [mailto:[EMAIL PROTECTED] 
 Sent: Wednesday, September 26, 2007 12:42 PM
 To: RICHARD FERNANDEZ
 Cc: Beginners List
 Subject: Re: Changing CPAN config before initial config?
 
 Hi Richard,
 
 There will be a config.pm file in the cpan module directory, 
 you can change the url list to point it to your local mirrors.
 
 Thank You,
 
 -srini


Ahh. Thank you Srini.

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




RE: Build module on one box and move to another box?

2007-06-28 Thread RICHARD FERNANDEZ
 
 Can this be done? Can I compile a module on one box and 
 somehow install the code on another?
 Might this be as simple as copying over the contents of the 
 directories in @INC?

As it turns out, this was fairly easy to do.

I followed the advice from Chas Owens who suggested that I build them
manually on another box and stop before the make install.
There were no pre-reqs that needed to be installed, so I guess I got
lucky there.

I tar'd up the build directories, moved them over, did another make
test just to feel good about it, then the 
make install. Further tests with our code went well.

Thanks Chas, and to all who responded!

richf

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




RE: CPAN shell (LWP, Net::FTP) won't authenticate properly

2007-06-26 Thread RICHARD FERNANDEZ
 

 -Original Message-
 From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
  I'm using a URL of the form ftp://MyCpanMirror/u02/CPAN/
 
 Is your mirror server running Apache or some http server?  I 
 have an internal mirror that I connect to via http and it 
 works like a charm.
 

Hi David,

Yes that box has Apache running on it, and that's the direction I'll be
going in today.
Still, I'd like to figure out the FTP thing if only just for
completeness :)

Thanks!

richf

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Build module on one box and move to another box?

2007-06-26 Thread RICHARD FERNANDEZ
Hi folks,

Having worked around my CPAN mirror problems by abandoning the FTP URL
and going with an HTTP connection instead (Thanks for the suggestion
David :), I'm now faced with the fact that the box I'm on does not have
a compiler installed. They want me to install various modules (DBI.pm
and others) without installing a compiler...

Can this be done? Can I compile a module on one box and somehow install
the code on another?
Might this be as simple as copying over the contents of the directories
in @INC?

Thanks for the feedback!

richf

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




RE: Build module on one box and move to another box?

2007-06-26 Thread RICHARD FERNANDEZ
 Can this be done? Can I compile a module on one box and 
 somehow install the code on another?
 Might this be as simple as copying over the contents of the 
 directories in @INC?
 

Thanks Tom and Chas for the responses.

It sounds like this is do-able, but not w/o some pain. Their desire to
have this done quickly (surprise!) might determine whether or not I get
a compiler ;)

If I do successfully make the attempt, I'll post my results.

Thanks for the help!

richf

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




CPAN shell (LWP, Net::FTP) won't authenticate properly

2007-06-25 Thread RICHARD FERNANDEZ
Hi folks,

I'm trying to use the CPAN shell to install some modules from our
internal CPAN mirror.
I'm using a URL of the form ftp://MyCpanMirror/u02/CPAN/ , and I have a
valid .netrc configured with a user and password for the mirror box.

At first I was able to query/install modules easily, but then I did an
install Bundle::CPAN, and now I can't log into my CPAN mirror. To be
specific, LWP and Net::FTP are attempting to use an anonymous login,
which is not allowed, instead of trying to log in via the user
information contained in .netrc.

I've read the docs for CPAN, LWP::UserAgent, and Net::FTP, but I don't
see how to change this behavior. I was under the impression that if a
.netrc was available, Net::FTP at least, would use it for
authentication.

Here is a snip of the CPAN shell output:

cpan[1] install DBD::Oracle
CPAN: Storable loaded ok (v2.08)
Going to read /iu36/s01/.cpan/Metadata
  Database was generated on Fri, 22 Jun 2007 05:07:41 GMT
CPAN: LWP::UserAgent loaded ok (v2.003)
CPAN: Time::HiRes loaded ok (v1.52)
Fetching with LWP:
  ftp://MyCpanMirror/u02/CPAN/authors/01mailrc.txt.gz
LWP failed with code[404] message[Can't chdir to u02]
Fetching with Net::FTP:
  ftp://MyCpanMirror/u02/CPAN/authors/01mailrc.txt.gz
  Couldn't login on MyCpanMirror: User anonymous unknown.
Fetching with Net::FTP
  ftp://MyCpanMirror/u02/CPAN/authors/01mailrc.txt.gz.gz
  Couldn't login on MyCpanMirror: User anonymous unknown.
Fetching with LWP:
  http://www.perl.org/CPAN/authors/01mailrc.txt.gz

(I don't have access to the outside from this box)

What am I missing?

Thanks for the help!

richf


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




RE: CPAN shell (LWP, Net::FTP) won't authenticate properly

2007-06-25 Thread RICHARD FERNANDEZ
 
One other thing. I am able to successfully login to the mirror box using
command line FTP and netrc for authentication.

richf

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




RE: CPAN shell (LWP, Net::FTP) won't authenticate properly

2007-06-25 Thread RICHARD FERNANDEZ
Hi Tom,

Thanks for the response. 

 It's undocumented, but maybe try this:
 
   BEGIN { $CPAN::DEBUG = 512; } # FTP?
 

Not sure where to plug in this BEGIN {}...



   perl -MNet::Netrc -lwe 'print join  , 
 Net::Netrc-lookup(MyCpanMirror)-lpa'


It looks like Net::Netrc is working:
# perl -MNet::Netrc -lwe 'print join( ,
Net::Netrc-lookup(MyCpanMirror)-lpa)'
Use of uninitialized value in join or string at -e line 1.
cpan XpasswdX 

I've also tested Net::FTP separately, and it works as advertised with
.netrc.
 
 If you're still able to use the ftp command to manually log 
 in to your mirror, you should be able to configure CPAN to 
 use that, as a workaround. I say you should, but I don't know 
 how tenaciously it may try to use Net::FTP (or whatever is 
 broken) instead.
 

As it turns out, if I wait patiently for all the LWP/Net::FTP timeouts,
eventually CPAN resorts to /usr/bin/ftp which does read my .netrc. My
modules do eventually get installed but not w/o several admonitions that
using /usr/bin/ftp may cause ...problems that are hard to diagnose

I'm not sure where else to go with this. It looks like I can eventually
get what I need installed, but not without a long bumpy ride first.

Thanks for the feedback.

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Advice wanted on ssh port forwarding

2007-05-09 Thread RICHARD FERNANDEZ
Hi folks,

I've been asked to write a job that sets up an SSH tunnel (ssh -L) which
forwards connections to a box on our client's internal network. Through
this tunnel I need to make a second SFTP connection for data transfer.

I've been looking at Net::SSH, but I haven't quite figured out how to
use it to set up the initial tunnel, or even if it's possible with this
module. Before I invest too much time, I thought I should find out if
anyone else has already invented this particular wheel :)

So...

Has anyone else done this? What modules should I be looking at?
Any tidbits or advice to put me on the right path would be appreciated.

Thanks!

richf

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




help accessing NDBM database files

2007-02-21 Thread RICHARD FERNANDEZ
Hi folks,

I'm working on a script in which I want to access NDBM files directly.
I'm using the unix aliases file(s) for testing, but I intend to use this
code for other projects as well.

I have the following files: aliases, aliases.dir, and aliases.pag.
According to the man page for aliases, these are ndbm files maintained
by newaliases.

I want to write something to query/update the database files (the .dir
and .pag files?) directly, but I need a push in the right direction.

What I've done so far is just modify the code in the perldoc for
NDBM_File as a test, but it doesn't work. I am at a loss for how to
begin. Any suggestions would be appreciated.

Thanks.

Here's my

CODE
#!/usr/bin/perl
use warnings;
use strict;
use NDBM_File;
use Fcntl;


my %ALIAS;

tie(%ALIAS, 'NDBM_File', './aliases', O_RDWR|O_CREAT, 0644) or
   die Couldn't tie NDBM file : $!; aborting;

print My alias = , $ALIAS{rfernandez}, \n;

untie %ALIAS;

/CODE

This produces this output:
Use of uninitialized value in print at ./mytest1.pl line 13.
My alias = 

and creates a file called aliases.db

Thanks!

richf

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




RE: help accessing NDBM database files

2007-02-21 Thread RICHARD FERNANDEZ
 That man page might be lying to you. If you have a pair of 
 .dir/.pag files, those are probably a DBM file, not NDBM. 
 Have you tried DB_File?
 
 Hope this helps!
 
 --Tom Phoenix
 Stonehenge Perl Training
 

I substitued DB_File for NDBM_File and changed the code appropriately,
but I'm still only able to create/access files with a '.db' extension.
Still no luck accessing my original '.dir' and '.pag' files.

I'm wondering if I should be looking at using DBD::DBM instead. Don't
know much about database access (yet!)...

Anyone have any thoughts on this?

Thanks!

richf

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




RE: help accessing NDBM database files

2007-02-21 Thread RICHARD FERNANDEZ
 Probably rfernandez is not a valid key in the database file. Try this:
 
  tie my %db, 'NDBM_File', 'aliases', O_RDWR, 0644;
 
  while (my ($key, $value) = each %db) {
  print $key = $value\n;
  }
 
  untie %db;
 
 On my system, this code works with a custom aliases database 
 file I created in Perl (aliases.dir and aliases.pag). 
 However, I used simple numbers for the values, but a true 
 aliases file probably uses binary-packed values.
 
 
 HTH

Thanks Mumia. I had already tried this w/o success.

I removed the O_CREAT switch (per your sample) and started to see No
such file or directory when clearly the file was sitting right there. I
also tried providing the path (./aliases). Same error.

Then it occurred to me that maybe I should try the test code on the
production box which runs Solaris and perl 5.8.2. My dev box is OBSD
and runs perl 5.8.6.

The test code runs perfectly on the Solaris box! I have no idea what's
going on under the covers. Maybe someone can shed some light on this?

Anyway at least now I know I'm not barking up the wrong tree :)

Oh, and BTW it turns out that the aliases file does not use
binary-packed values as you suggest. It looks to be straight alias =
address(es) pairs as I expected before the subject came up.

Thanks to all!

richf

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




RE: Getopt::Std producing unexpected results

2006-12-19 Thread RICHARD FERNANDEZ
 

 Getopt::Std only works with single hyphen switches, the only 
 exceptions being '--', '--help' and '--version'.
 
 perldoc Getopt::Std
 
 
 Getopt::Std also processes swithes in clusters so -abcd 
 filename is the same as -a -b -c -d filename.
 
 
 With your command line:
 
 ./mytest.pl -h localhost -l file --volgroups foo bar
 
 First the '-h' switch is processed and 'localhost' is 
 assigned to $opt_h.
 Next the '-l' switch is processed and 'file' is assigned to 
 $opt_l.  Next the cluster '--volgroups' is processed as the 
 switches '--', '-v', '-o' and '-l'
 and since '-l' takes a value the remaining string 'groups' is 
 assigned to $opt_l overwriting the previous value in $opt_l.
 
 
 
 
 John
 --


Ahhh I see.

Thanks for the clarification, John!

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Getopt::Std producing unexpected results

2006-12-18 Thread RICHARD FERNANDEZ
Hi Folks,

I've written a little mytest.pl using Getopt::Std:

script
#!/usr/bin/perl
use warnings;
use strict;
use Getopt::Std;

getopt('hl');
our ($opt_h, $opt_l);

my $hostname = $opt_h ? $opt_h : undef;
my $file = $opt_l ? $opt_l : undef;
my @volgroups   = @ARGV;


print hostname = $hostname\n;
print file = $file\n;
print volgroups = , join(\t, @volgroups), \n;

/script

When I run this, I get the following output:

$ ./mytest.pl -h localhost -l file foo bar
hostname = localhost
file = file
volgroups = foo bar

This is what I expect. If I then add --volgroups before the foo,
I get this:

$ ./mytest.pl -h localhost -l file --volgroups foo bar
hostname = localhost
file = groups
volgroups = foo bar

I would have expected the second output to be the same as the first.
Specifically, I can't see why file now equals groups.

The man page says that:
To allow programs to process arguments that look like
 switches, but aren't, both functions will stop processing
 switches when they see the argument --.  The -- will
 be removed from @ARGV.

Interestingly enough, if I say --volgroup instead of --volgroups, then
the output says file = group instead of file = groups!

Can anyone shed some light?
Thanks!

richf





--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Can't get Sudo.pm to run my command but it works from a prompt

2006-10-05 Thread RICHARD FERNANDEZ
Hi folks,

I have the following in a CGI script:

code
   my $replace = Sudo-new(
   {
  sudo = $sudo,
  debug = 3,
  username = 'root',
  program = '/bin/cp',
  #program_args = '-f
/tmp/alias_maint/aliases.new /etc/mail/aliases',
  program_args = '-f
/tmp/alias_maint/aliases.new /etc/mail/aliases.richf',
   }
  );

   my $replace_rc = $replace-sudo_run;

   if (exists $replace_rc-{error}) {
  warn ERROR: , $replace_rc-{error}, \n;
   }
   if (exists $replace_rc-{stdout}) {
  warn STDOUT: , $replace_rc-{stdout}, \n;
   }
   if (exists $replace_rc-{stderr}) {
  warn STDERR: , $replace_rc-{stderr}, \n;
   }
   if (exists $replace_rc-{rc}) {
  warn RC: , $replace_rc-{rc}, \n;
   }
.
.
.
/code

When this code gets run (via webpage) I get the following in the
error_log:

snip
 output:  
 result: 256

STDOUT: 
STDERR: 
We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these two things:

   #1) Respect the privacy of others.
   #2) Think before you type.

Password:

RC: 
/snip

In other words, it seems to be asking for a password. However when I run
this from a regular prompt as the webserver user, it works fine.

I have a check for the UID in the script, and it's the right one. I also
have NOPASSWD set in sudoers.

Any help is appreciated.
Thanks!

richf




--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




RE: Can't get Sudo.pm to run my command but it works from a prompt

2006-10-05 Thread RICHARD FERNANDEZ
 Did you edit the sudoers file using visudo -f file

Yes.

 Show us the sudoers file using cat -etu file.

# cat -etu /usr/local/etc/sudoers  /tmp/sudoers.richf
# less /tmp/sudoers.richf
# sudoers file.
#
# This file MUST be edited with the 'visudo' command as root.
snip

# User privilege specification
root ALL=ALL
webuser  ALL = (ALL) NOPASSWD: ALL


 Has this user ever successfully logged in?

Yes, the user is set up w/o a login shell, but in the course of testing
I've given him login access. Doesn't make a difference.

 
 derek
 

Thanks derek.



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




RE: Can't get Sudo.pm to run my command but it works from a prompt

2006-10-05 Thread RICHARD FERNANDEZ
 if the user has never signed in and the admin never ran 
 passwd user passwd -f user and then that user never went into 
 make his/her password permenant then yes it would matter b/c 
 the passwd is not set.
 


I've gone in and set a passwd for the user. Then I actually logged in as
the user for grins.
Still no good. And, BTW, I'm restarting the webserver after every change
to the user to make sure the environment is what I think it is.

If a missing passwd was the issue, it should not have worked from the
command line either, or am I missing something?

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




RE: Can't get Sudo.pm to run my command but it works from a prompt

2006-10-05 Thread RICHARD FERNANDEZ
 

From: Mumia W. [mailto:[EMAIL PROTECTED] 

 Does the webserver have the proper permissions to invoke that sudo
entry?

AFAIK, yes. I don't think it would be asking for a password if it
couldn't run the binary. It just doesn't seem to be pulling the right
entry (webuser) out of the sudoers file, even though it's running as
webuser. I don't know what else I should be checking...

As a test, I temporarily replaced the call to Sudo.pm with a
system(/usr/local/bin/sudo...) and it failed the same way. Hmmm. Works
from the command line. Doesn't work from cgi-bin.

Looks like this may not, strictly speaking, be a Perl question any more,
but can anyone point me in the right direction?
I can definitely run things out of cgi-bin, otherwise I wouldn't have
gotten this far.

Thanks again!
richf 

--
To unsubscribe, e-mail: [EMAIL PROTECTED] For additional
commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
http://learn.perl.org/first-response



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




RE: Can't get Sudo.pm to run my command but it works from a prompt

2006-10-05 Thread RICHARD FERNANDEZ
 

-Original Message-
From: Igor Sutton [mailto:[EMAIL PROTECTED] 
Sent: Thursday, October 05, 2006 8:17 PM
To: RICHARD FERNANDEZ
Cc: Beginners List
Subject: Re: Can't get Sudo.pm to run my command but it works from a
prompt

 Looks like this may not, strictly speaking, be a Perl question any 
 more, but can anyone point me in the right direction?
 I can definitely run things out of cgi-bin, otherwise I wouldn't have 
 gotten this far.

 Most times, apache uses nobody or www user. Check if the user apache
uses is mentioned in sudoers file.

The user listed in httpd.conf is webuser, the same user I have listed
in sudoers.


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




RE: Can't get Sudo.pm to run my command but it works from a prompt

2006-10-05 Thread RICHARD FERNANDEZ
From: Mumia W. [mailto:[EMAIL PROTECTED] 

 Go into sudoers and replace the name of the binary with the name of a
 script that echoes the real and effective user and group ids.

Thanks Mumia, and thanks to all who responded.

As it turns out, I was able to resolve the problem by replacing
'/bin/cp' with '/bin/mv'. Didn't think of it sooner, unfortunately. I'm
not sure why mv works and cp doesn't, especially since in my testing I
wasn't crossing filesystems. Everything I did was in /tmp.

Still, the problem has been resolved, yay!
Thanks again!!!

richf




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




RE: How do I populate a form field based on the value entered in adifferent field

2006-09-23 Thread RICHARD FERNANDEZ
 

-Original Message-
From: Shawn Hinchy [mailto:[EMAIL PROTECTED] 

Would you mind sharing the answer?  I would assume it would have to be
some sort of Javascript, am I wrong?

Thanks,

Shawn

Shawn Michael Hinchy
[EMAIL PROTECTED]


Nope, no Javascript. I could have used JS, but I was looking for a
server side solution, due to having to replace values in a textfield
with values gotten from a database in my real project.

I'm embarrassed to admit that it all boiled down to having a statement
out of order.
Here's the final code, which will replace the name 'richf' with the name
'John' in the textbox:

#!/usr/bin/perl -w
# This script is based on the example at the top of the CGI pod --richf;

use strict;
use CGI;

my $html = CGI - new();

my $name = $html-param('name') || '';
$name = 'John' if ($name =~ /richf/i); 
$html-param(-name = 'name', -value = $name);

print $html-header,  
  $html-start_html('A Simple Example'),  
  $html-h1('A Simple Example'),  
  $html-start_form,  

  What's your name?,

  $html-textfield(-name  = 'name', -value = $name),   

  $html-p,  
  What's the combination?,
  $html-p,  
  $html-checkbox_group(-name='words',
   -values=['eenie','meenie','minie','moe'],
   -defaults=['eenie','minie']),
  $html-p,  
  What's your favorite color?,
  $html-popup_menu(-name='color',
-values=['red','green','blue','chartreuse']),  
  $html-p,  
  $html-submit,  
  $html-end_form,  
  $html-hr;  


print $html - end_html;



HTH

richf

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




CGI: How do I populate a form field based on the value entered in a different field

2006-09-23 Thread RICHARD FERNANDEZ
Hi folks,
 
I'm trying to create an HTML form that will refresh itself based on user
input. In the POD for CGI it says that you can set the value of a named
parameter by using something like:
 
$query-param(-name='foo', -value='the value');
 
But it doesn't say (or at least I didn't see) anything about how to
redisplay the form with the new value in the textbox (or a different
textbox for that matter).
 
The sample script at the top of the doco (perldoc CGI) creates a blank
form that takes some input, a name, a combination, and a color and
displays the user input in the bottom half of the page.
 
I would like to edit the value entered into the name textbox and
display my edited value in the same, or possibly a different textbox.
I've tried a bunch of things including the call to param() above,
without success.
 
For example, if the user types Wilma into the textbox, the script
should populate the target textbox with my edited value, say, Betty.
 
As always, Thanks in Advance  for any help!
 
richf


RE: CGI: How do I populate a form field based on the value entered in a different field

2006-09-23 Thread RICHARD FERNANDEZ
 $query-param(-name='foo', -value='the value');


Make that line  $query-param(-name='foo', -value=$the_value);

Then somwhere at the start where you get the variables;

my $name = $query-param('name')||'';

if ($name =~/mary/i){ $the_value = Howdy Mary }



How you do it depends on your workflow/logic



Owen



Thanks for your response, but I still don't get it. I type my name into
the box and click 
Submit, but it doesn't change!

Could you please clarify?

Here's my code:

#!/usr/bin/perl -w
# This script is the example at the top of the CGI pod --richf;
use strict;
use CGI;

my $html = new CGI;

my $new_value;
my $name = $html - param('name') or '';
if ($name =~ /richf/i) {
   $new_value = 'John';
}

print $html - header,
  $html - start_html('A Simple Example'),
  $html - h1('A Simple Example'),
  $html - start_form,

  What's your name?,
  $html - textfield(-name  = 'name'),

  $html - p,
  What's the combination?,
  $html - p,
  $html -   checkbox_group(-name='words',
   -values=['eenie','meenie','minie','moe'],
   -defaults=['eenie','minie']),
  $html - p,
  What's your favorite color?,
  $html - popup_menu(-name='color',
-values=['red','green','blue','chartreuse']),
  $html - p,
  $html - submit,
  $html - end_form,
  $html - hr;



$html - param(-name = 'name', -value = $new_value);
print $html - end_html;

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




RE: CGI: How do I populate a form field based on the value entered in a different field

2006-09-23 Thread RICHARD FERNANDEZ

Did you test it? It is my impression that CGI.pm works this way
normally:

snip

if (param) {

 # Replace the parameter.
 my $temp = param('name');
 if ($nmap{$temp}) {
 # param('name',$nmap{$temp}); # This also works.
 param(-name = 'name', -value = $nmap{$temp});
 }

   print
   Your name is ,em(param('name')),p,
   The keywords are: ,em(join(, ,param('words'))),p,
   Your favorite color is ,em(param('color')),.\n;
}
print end_html;


Thanks for your response, Mumia. 

This is very similar to the example in the doc, and it does work, but
what I'm (still) trying to do is replace the name that is typed into the
textfield, not print it outside of the form.

Thanks to all who've responded, so far. I'm still playing with it, but
haven't cracked it yet... I hate getting hung up on something simple.
(maybe what I need is sleep at this point :) 

richf


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




RE: CGI: How do I populate a form field based on the value entered in a different field

2006-09-23 Thread RICHARD FERNANDEZ
Ding! Ding! Ding! I finally got it!!! 

Not sure why this had me so stumped...

In any case, thanks to all that responded. I appreciate all the help.

richf

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




doing an mget with Net::FTP

2006-08-21 Thread RICHARD FERNANDEZ
Hi folks,

I have a directory full of filenames that contain spaces (a la Windows).
Is there an easy way to do an mget with Net::FTP, or do I need to parse
the output of $ftp-dir?

The doco for Net::FTP doesn't mention mget...

TIA!

richf

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Can't figure out why File::Path::rmtree says Operation not permitted

2006-07-18 Thread RICHARD FERNANDEZ
Hi folks,

I have a script that calls rmtree. The operation works; my directory and
its contents are removed.
However, I get this error:

Can't make directory /u01/mydocs/mytest001 read+writeable: Operation not
permitted at /u02/home/myacct_rem.pl line 41

If the directory has been deleted, why then is rmtree trying to make it
read/writeable??!

The permissions on the directories are as follows:

drwxrwxr-x3 nobody   nobody   4096 Jul 18 13:35 /u01/mydocs

drwxr-xr-x2 nobody   nobody   4096 Jan  1  2006
/u01/mydocs/mytest001

I'm not running as user nobody, but I'm in group nobody.

I know this must be easy to fix...

Thanks for any insights!

richf


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




RE: Can't figure out why File::Path::rmtree says Operation not permitted

2006-07-18 Thread RICHARD FERNANDEZ
  I'm not running as user nobody, but I'm in group nobody.
 
 Then you shouldn't be able to change permission bits on user 
 nobody's files and directories; they're not yours. Perhaps 
 you should ask user nobody to rmtree? Or if the files are 
 supposed to be yours, maybe you just need to fix the ownership.
 
 Hope this helps!
 
 --Tom Phoenix
 Stonehenge Perl Training
 

Thanks for your help, Tom.

I'll look into changing the file ownerships, but at least now I know why
rmtree complains.

richf

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




RE: Crypt::GPG won't decrypt file...rewrote it to use system, but only partially works

2006-06-30 Thread RICHARD FERNANDEZ
I re-wrote the decryption routine to use system instead of Crypt::GPG,
and came across another puzzle:

my @gpg_command = (/usr/bin/gpg --decrypt $encrypted 
$decrypted 2 /dev/null);
system(@gpg_command) == 0 or warn system @gpg_command failed:
$!;

works. It decrypts my file successfully. But if I break up the arguments
like it says in the doco, like so:

my @gpg_command = (/usr/bin/gpg, --decrypt, $encrypted, ,
$decrypted, 2 /dev/null);
system(@gpg_command) == 0 or warn system @gpg_command failed:
$!;

it does not work. Instead I get a usage error.


Could someone please explain where I've gone wrong? I would like to use
Crypt::GPG instead of system, but I have to get this finished.
Thanks!

richf

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




RE: Crypt::GPG won't decrypt file...rewrote it to use system, but only partially works

2006-06-30 Thread RICHARD FERNANDEZ
 I would suggest giving GnuPG::Interface a go because it 
 handled calling out to 'gpg' most correctly. Meaning it 
 uses the status-fd, logger-fd options properly which is the 
 preferred way to call gpg in an automated fashion.
 
 Good luck,
 
 http://danconia.org
 

Thank you! I will give it a shot.

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Crypt::GPG won't decrypt file

2006-06-29 Thread RICHARD FERNANDEZ
Hi folks,

I have the following function:

sub lbx_decrypt {

   my $encrypted = shift or die No file passed in to lbx_decrypt for
decryption?\n;
   my $decrypted = substr $encrypted, 4;
   $decrypted   .= '.zip';

   my $gpg = new Crypt::GPG;
   $gpg - gpgbin('/usr/bin/gpg');

   open CIPHERTXT, $encrypted or die Can't open file: $encrypted:
$!\n;
   my @ciphertxt = CIPHERTXT;

   # The decrypted file is a zip file which we will unpack later
   my($cleartxt, $signature) = $gpg - decrypt([EMAIL PROTECTED]); # or die
Can't decrypt $encrypted: $!\n;

   open CLEARTXT, , $decrypted or die Can't open decrypted file for
writing: $decrypted\n;
   print CLEARTXT $cleartxt or die Can't write decrypted file: $!\n;
   close CLEARTXT;

   return $decrypted;
}

There's not much to it. It seems like it should work, but when I run it,
I get this error:

Use of uninitialized value in print at ./rewrite.pl line 240,
CIPHERTXT line 38.

Strangely, this same function works in another program, minus the zip
stuff at the top.

I'm at a loss as to how to figure this out. Any help would be greatly
appreciated.
Thanks!

richf

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




parsing a CSV file with more fields than column names

2006-06-08 Thread RICHARD FERNANDEZ
Hello All,

I'm just trying to get some ideas for the best way to approach this...

I have a CSV file whose first line is a header. According to this header
there should be 17 values per line. Unfortunately this is not the case.
It seems that the first 16 header values match up with the first 16
values in each line, but for the 17th header item, there may be 1 or
more comma separated values associated with it! Here is a sample line
with header:

Num,Env Num,Envelope,Transaction,Lockbox,Date,Time,Batch,Batch
Item,Check,Check Amount,ABA/RT,Account Num,Check Num,Check
Image,Envelope Image,Page Images

1,1,G-999,G-999,SFC-99,2006/06/01,11:00,999,9,9,$.99,999
99,,99,9,9,23,24,25,26,27 


As you can see the 17th value is 23, but really there are 5 values
associated with Page Images, 23-27.

I've been playing with Tie::Handle::CSV, but I don't see a way to have
it pick up more that one value per hash key. What I need is a way to
specify all remaining values a la split, perhaps with an array ref.

Maybe Tie::Handle::CSV isn't the best choice? 

Any thoughts are appreciated.

TIA

richf

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




RE: parsing a CSV file with more fields than column names

2006-06-08 Thread RICHARD FERNANDEZ
 Hello Rich

Hi, Chris, thanks for your response


 
 See docs for perlfunc, specifically split.
 
 Especially, the form for split
 'split /PATTERN/,EXPR,LIMIT'
 
 By setting the limit, you will be able to solve the problem.
 
 Chris
 

The thing is I can't be sure that there will never be embedded commas in
the data (well maybe I can with this particular set of data, not sure),
so split (as discussed in the Cookbook) isn't the way to go. This is why
I was looking to use a specialized module for the job. Also, I need to
be able to address several of the fields specifically, to change their
values, so I like the idea of using a hash which is done for me with
something like Tie::Handle::CSV.

What I've come up with is this:

code
#!/usr/bin/perl -w
use strict;
use Tie::Handle::CSV;

my $file = shift or die You forgot to provide the name of a CSV
file\n;
my $csv_fh = Tie::Handle::CSV-new(file = $file, header = 0);

my %csv_headers = (
   0 = 'Num',
   1 = 'Env Num',
   2 = 'Envelope', 
   3 = 'Transaction',
   4 = 'Lockbox',
   5 = 'Date',
   6 = 'Time', 
   7 = 'Batch',
   8 = 'Batch Item',
   9 = 'Check',
   10 = 'Check Amount', 
   11 = 'ABA/RT',
   12 = 'Account Num',
   13 = 'Check Num',
   14 = 'Check Image', 
   15 = 'Envelope Image',
   16 = 'Page Images'  
);   


my %csv_hash;
while (my $csv_line = $csv_fh) {
   next if ($.  4 );

   for my $index (0..15) {
  $csv_hash{ $csv_headers{$index} } = $csv_line - [$index];
   }

   # The values that remain in @{$csv_line} are all associated with
Page Images, so
   # we need to build an array to pass as a hash value...
   $csv_hash{'Page Images'} = [];
   for my $index (16..$#{$csv_line}) {
  push @{ $csv_hash{'Page Images'} }, $csv_line - [$index];
   }

   for (sort keys %csv_hash) {
  if ( !ref $csv_hash{$_}  ) { # If the value is not a (array) ref
 print $_,  = , $csv_hash{$_}, \n;
  } else {
 print $_,  = \n;

 for ( @{ $csv_hash{$_} } ) {
print \n\t, $_;
 }
 print \n\n;
  }
   }
   print \n\n\n;
   print '*' x 20, \n;
}

/code

Which does what I want, but it seems like there should be an easier
way...

richf


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




RE: parsing a CSV file with more fields than column names

2006-06-08 Thread RICHARD FERNANDEZ
 Are you SURE that there might be commas in the other fields?
 I would hope that whoever made this file you're parsing would 
 have thought of this if they ever intended to later use the data.

Good point. But I have no way of verifying that.

These CSV files are provided to me by an outside source. I don't know if
I'll be able to pin anyone down on the comma issue. And I've already
gotten bad answers to other technical questions...

My thinking was to code for the worse case, which is where the data
might contain embedded commas. This way, I don't have to worry about it.

My concern is with field #17 (the last item in the header). But the
detail lines may contain 17 items. Assuming that there are never
embedded commas in the data, everything in the detail from field 17 on
should be considered as one group. But again, I can't make that
assumption. One embedded comma earlier in the data will throw off the
logic.

richf

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Help with untainting data from Net::SSH while running with -T

2006-05-05 Thread RICHARD FERNANDEZ
Hi folks,

I have the following code which is part of a script running with -T on a
webserver:

code
#$user, $host, and $command are hard-coded further up in the script;
sshopen2([EMAIL PROTECTED], *READER, *WRITER, $command) or die Can't run
command on my_box: $!\n;

while (READER) {
  chomp;

  if (  /Account:(myacct\d{3})/  ) {
 $acct = $1;
  } elsif (  /Password:(\d{8})/ ) {
 $passwd = $1;
  } else {
 warn Received invalid data from SSH call\n;
  }
}
close READER;
/code

When I run the script w/o the -T, it runs fine, without a peep. When I
add the -T, I get the following in the error.log:

Insecure dependency in exec while running with -T switch at
/usr/local/perl-5.8.7/lib/5.8.7/IPC/Open3.pm line 244.

According to perlsec, a way to untaint data is by referencing
subpatterns from a regular expression, which I thought I was doing.

Can anyone shed some light on this?

as always, TIA!

richf 

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




RE: rm -rf in perl

2006-04-25 Thread RICHARD FERNANDEZ

Is there a definative way to recreate the gnu `rm -rf` in perl?

I've seen a couple of modules that seem to implement something, and a
bunch of variations using File::Find,  but it just seems overly
complicated.Since it's important I understand exactly what it's
going to do (it's removing data here!) I'm hesitant to put any of them
in use.

And I guess the related question is, should I just shell out for this?
Performance and portability aren't a concern here...


Brian


You could use rmtree.

perldoc File::Path

HTH

richf 

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Crypt::GPG produces an empty cleartext file

2006-04-06 Thread RICHARD FERNANDEZ
Hi Folks,

I have a job that takes in an encrypted file and decrypts it using
Crypt::GPG.

code
 for my $encrypted_file (@files) {
 
 open(CIPHERTXT, $encrypted_file) or croak Can't open
encrypted_file: $encrypted_file\n;
 my @ciphertxt = CIPHERTXT;

 my($cleartxt, $signature) = $gpg - decrypt([EMAIL PROTECTED]); 

 # File names must have a .extension on them if they're
encrypted
 # we will strip off the last dot and everything after it to
name the 
 # clear text file
 my $filename = (split /\.\w+$/, $encrypted_file)[0]; 

 open(CLEARTXT, , $filename) or croak Can't write to
$filename: $!\n;
 print CLEARTXT $cleartxt or croak Can't print cleartext:
$!\n;
 close CLEARTXT or croak Can't close CLEARTXT?\n;

 push @processed_files, $filename or croak Can't create list of
decrypted files!\n;
}
/code

Mostly, this works as I expect, but once in a blue moon we get a
ciphertext that produces a 0 byte cleartext file when run
through the above code. When I decrypt the file manually (gpg --decrypt
filename  clear.txt ) I get a good (readable) cleartext file.

Anyone have any ideas about how to fix this?
Any help is appreciated!

richf

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




RE: Crypt::GPG produces an empty cleartext file

2006-04-06 Thread RICHARD FERNANDEZ
What version of Crypt:GPG are u using?

Derek Bellner Smith
Unix Systems Engineer
Cardinal Health Dublin, Ohio
614-757-5000 Main
614-757-8075 Direct
614-652-4336 Fax
[EMAIL PROTECTED]


Hi Derek,

Thanks for your response. I'm using:

Crypt::GPG version 1.42
Perl version 5.6.0
gpg version 1.0.6

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




How can I upgrade Perl?

2006-03-10 Thread Richard Fernandez
Is there a simple way to upgrade the current version of Perl that's running on 
a unix box? Is it possible to use CPAN for this (I didn't see anytning about 
this in the man page).
   
  Thanks in advance.
   
  Richard


-
Yahoo! Mail
Bring photos to life! New PhotoMail  makes sharing a breeze. 

RE: Help: Math::Pari won't install

2006-02-28 Thread RICHARD FERNANDEZ
This has lingered long enough without response. Sorry it took me a while
to get back to it after initially seeing it. I had this same problem a
couple of years ago. It does appear that Math::PARI has an active
maintainer again so you might try dropping him a line about this issue.

I solved it by testing each previous version (of libPARI) until I hit
one that would install cleanly. As much as it stinks to not have the
most recent version of something, a working version is better than no
version.

HTH,

http://danconia.org


Thanks for the response. I did manage to solve the Math::Pari install
problem by following Jeff Eggen's idea about configuring it with
machine=none. I have no idea about whether or not, as he mentions, it's
unusably slow because I proceeded with the rest of the Net::SFTP install
and got similarly hung up on the install for Math::GMP. (Un)fortunately
enough time has elapsed on this that the Powers That Be decided to
shelve this project and go a different way. So for now I'm off the hook.

Ironically, we have Net::SFTP running fine in other environments. It's
just this one box...

Thanks again for the help!

richf

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Help: Math::Pari won't install

2006-02-22 Thread RICHARD FERNANDEZ
I'm trying to build Math::Pari along the way to building Net::SFTP, but
the make fails with the following error:

pariinl.h: In function `mulssmod':
pariinl.h:887: error: asm-specifier for variable `hiremainder' conflicts
with asm clobber list
pariinl.h:887: confused by earlier errors, bailing out
make[1]: *** [es.o] Error 1
make[1]: Leaving directory
`/s01/.cpan588/build/Math-Pari-2.010703/libPARI'
make: *** [libPARI/libPARI.a] Error 2

Not sure what other information is relevant, but I'm doing this on a
Solaris 8 box using:

# gcc -v
Reading specs from
/usr/local/lib/gcc-lib/sparc-sun-solaris2.8/3.3.2/specs
Configured with: ../configure --with-as=/usr/ccs/bin/as
--with-ld=/usr/ccs/bin/ld --disable-nls
Thread model: posix
gcc version 3.3.2

Any help would be appreciated!

richf



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




RE: Equal length numbers

2005-12-15 Thread RICHARD FERNANDEZ
 -Original Message-
From: Andrej Kastrin [mailto:[EMAIL PROTECTED] 
Sent: Thursday, December 15, 2005 9:09 AM
To: beginners@perl.org
Subject: Equal length numbers

Hi all,

Suppose that we have numbers 1 to 1000 and we want all numbers be equal
length; e.g.:
0001
0002
0003
...
..
1000

Any idea on how to fix this problem?

Best, Andrej




Perldoc -f sprintf

HTH

richf

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




How do you determine if a file is a symlink?

2005-12-15 Thread RICHARD FERNANDEZ
According to the docs, if you stat a symlink, you will get information
for the target file, and lstat works on symlinks...

I'm confused. How do you determine if a file is a symlink to begin with?

TIA

richf

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




RE: Help: Net::SFTP can't find my file..?

2005-11-11 Thread RICHARD FERNANDEZ
 
If anyone can shed any light on this it would be much appreciated!
TIA

From an old tested snippet I have, put takes 2 arguments

$sftp-put($put_from, $put_to_dir/$file) || die Can't open $!\n;



--
I'm not really a human, but I play one on earth.
http://zentara.net/japh.html





Thank you zentara. This did it. I had tried supplying a file name for
the remote side, but I hadn't thought to give it the _full_path_ on the
remote side. Now I know :)

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Help: Net::SFTP can't find my file..?

2005-11-10 Thread RICHARD FERNANDEZ
I know the answer must be right in front of me, but I just don't see
it...

I wrote a script that looks for files and then sends them to a remote
SFTP server:

code
#!/usr/bin/perl -w
use strict;
use Net::SFTP;
use Logit;  # this is a homegrown function that takes a filename and
a line
# of text to write to the file.

my $debug  = 1;
my $server = usmlrh03; 
my %sftp_args  = ( user = 'my_user',
   password = 'my_passwd',
   debug= $debug);


# Check for the presence of datafiles
my @datafiles = foo.*;

if ([EMAIL PROTECTED]) {
logit('mylog.log', No datafiles found);
die No datafiles;
};

my $sftp = Net::SFTP - new($server, %sftp_args) or do {
logit('mylog.log', Can't connect to $server via SFTP);
die Can't connect to $server via SFTP;
};

my $rc;
for (@datafiles) {

logit('mylog.log', Putting file: $_);

$rc = $sftp - put($_);

logit('mylog.log', Put to $server via SFTP: rc=$rc);
}
exit;
#logit('mylog.log', @datafiles: sent successfully);
#unlink $dotdone   or logit('mylog.log', Unable to delete $dotdone); 
#unlink @datafiles or logit('mylog.log', Unable to delete @datafiles);


/code

When I run this I get: 

Use of uninitialized value in concatenation (.) at
/usr/lib/perl5/site_perl/5.6.0/Net/SFTP.pm line 215.
usmlrh04: sftp: Sent SSH2_FXP_OPEN I:0 P:
Couldn't get handle: No such file or directory at
/usr/lib/perl5/site_perl/5.6.0/Net/SFTP.pm line 166.
usmlrh04: sftp: Sent message SSH2_FXP_WRITE I:1 O:0
Couldn't write to remote file: Failure at
/usr/lib/perl5/site_perl/5.6.0/Net/SFTP.pm line 261.
usmlrh04: sftp: Sent message T:4 I:2
Couldn't close file: Failure at
/usr/lib/perl5/site_perl/5.6.0/Net/SFTP.pm line 201.
Use of uninitialized value in concatenation (.) at ./my_sftp.pl line 37.

But there definitely is a file in the current directory called foo.csv.
I tried specifying the full path, ie, /home/user/foo.csv, but I got the
same results!

BTW I don't think this should matter, but this is running between two
(old) RH linux boxes.

If anyone can shed any light on this it would be much appreciated!
TIA

richf

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




recommendation: which web portal software?

2005-10-03 Thread RICHARD FERNANDEZ
Hi folks,
 
I'm doing some volunteer work in my community, and I've been asked to take over 
the administration for a small website. The site was set up over 5 years ago 
and is basically a set of HTML pages and PHP scripts that were thrown together 
to meet the need at the time.
 
Now that I'm taking it over I would like to clean things up a bit and make it 
easier to administer. I'm thinking about converting it to a web portal, but I 
want to use a Perl based solution (I don't know anything about PHP, not that I 
couldn't learn it :).
 
I won't have root access to the box since it's hosted externally, but it is a 
Linux environment.
In addition to Perl, I also have access to MySQL.
I wan't to minimize the amount of time I have to spend coding HTML, and I would 
like to make it somewhat easy for someone who is not too technically savvy to 
update.
 
Does anybody have any recommendations?
 
TIA
 
richf


Re: editing mail spool file

2003-10-07 Thread Richard Fernandez
On Mon, Oct 06, 2003 at 07:52:31PM -0500, Wiggins d'Anconia wrote:
 Richard Fernandez wrote:
  On Fri, Oct 03, 2003 at 09:24:01PM -0400, TN wrote:
  
 Based on your delete criteria, it would be much easier to filter out
 unwanted mail messages on an incoming relay mailer in your DMZ.  You
 could do other things there such as filtering out mail with MIME
 attachments beyond a certain size limit, or just nuking the attachemnts.
 You should not have to deal with the problem post facto.
 
 -tristram 
 
  
  
  Thanks for your response.
  
  Trouble is, this is mail from inside users, and not SPAM in the usual sense.
  We are usually not alerted to the fact that these messages have to be
  nuked until they are already spooled and waiting to be popped. Which
  ones get deleted has to do with the size of the message _and_ what their
  destination is.
  
  We can't just implement a rule that says that everything above a certain
  size gets deleted, because, generally we accept pretty large e-mails.
  
  I really need to be able to run something at the command line on as
  small or as large a pool as I need at the time. Something like:
  
  nukemail.pl some_pool_of_users sender subject
  
 
 This should be a relatively trivial exercise if you employee the help of 
 Mail::Box, it has facilities for editing/searching, etc. many types of 
 mail boxes, local and remote.  It has a relatively steep learning curve 
 as mail modules go, but in the end the power has been worth it for me.
 
 Check it out on CPAN and be sure to have a look at the docs, they are 
 extensive
 
 http://danconia.org
 

Thanks Wiggins,

This seems to be exactly what I need!

richf

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



editing mail spool file

2003-10-03 Thread Richard Fernandez
On occasion someone sends out a mail message with MIME attachment that we want 
to delete from the recipient's spool file. This happens on a Solaris box, so I'm
talking about editing /var/mail/username, and there are often dozens
of recipients.

What we've been doing is using mutt -f to open each individual spool
file, finding the message and manually deleting it.

Seems to me there should be a way to search through a batch of user spool
files and selectively delete based on some criterea like sender name
and subject line, but I'm at a loss as to how to code this.

Can anyone offer any pointers, thoughts, or docs as to how to accomplish
this?

Thanks!

richf

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



Excel spreadsheet: creating charts

2003-03-12 Thread Richard Fernandez
We have a manual process in place to create Excel worksheets that contain
bar charts. I'm trying to automate this process using perl. The problem is
that I don't know how to access the underlying formulas, in Excel, that
generate the charts. Our current process is as follows:

1) Generate a space separated list of stats on Sun box using sar(1).
2) cut and paste this list into a pre-existing Excel spreadsheet which then
automatically
re-draws the charts based on the new data.

What I need help with is figuring out how to create a sheet with the
necessary charts. Is this possible to do using Spreadsheet::WriteExcel? Is
there a way to determine form the existing worksheet what the formula is for
the charts.

I'm not opposed to doing this a different/better way if anyone has any
suggestions, but I'd like to avoid generating csv files since this would
require a manual import into Excel.

Any help is much appreciated!

Rich


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



RE: Excel spreadsheet: creating charts

2003-03-12 Thread Richard Fernandez
I'm told that this is relatively easy to do using VBScript...
Besides the fact that I don't know VBS I would like to do it the Perl way :)

-Original Message-
From: David Olbersen [mailto:[EMAIL PROTECTED]
Sent: Wednesday, March 12, 2003 10:56 AM
To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Subject: RE: Excel spreadsheet: creating charts


Rich,

I know for a fact that you can generate any of the formulas and data you
might need with Spreadsheet::WriteExcel -- I'm not so sure about the graphs
though. I think those would still need to be done manually.

--
David Olbersen
iGuard Engineer
11415 West Bernardo Court
San Diego, CA 92127
1-858-676-2277 x2152


 -Original Message-
 From: Richard Fernandez [mailto:[EMAIL PROTECTED]
 Sent: Wednesday, March 12, 2003 7:55 AM
 To: [EMAIL PROTECTED]
 Subject: Excel spreadsheet: creating charts


 We have a manual process in place to create Excel worksheets
 that contain
 bar charts. I'm trying to automate this process using perl.
 The problem is
 that I don't know how to access the underlying formulas, in
 Excel, that
 generate the charts. Our current process is as follows:

 1) Generate a space separated list of stats on Sun box using sar(1).
 2) cut and paste this list into a pre-existing Excel
 spreadsheet which then
 automatically
 re-draws the charts based on the new data.

 What I need help with is figuring out how to create a sheet with the
 necessary charts. Is this possible to do using
 Spreadsheet::WriteExcel? Is
 there a way to determine form the existing worksheet what the
 formula is for
 the charts.

 I'm not opposed to doing this a different/better way if anyone has any
 suggestions, but I'd like to avoid generating csv files since
 this would
 require a manual import into Excel.

 Any help is much appreciated!

 Rich


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



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

RE: Excel spreadsheet: creating charts

2003-03-12 Thread Richard Fernandez
Thanks! This looks like just what I was looking for. I'll give it a try and
see how it goes.

-Original Message-
From: Thomson Steven R Contr AFRL/VSIO [mailto:[EMAIL PROTECTED]
Sent: Wednesday, March 12, 2003 1:03 PM
To: '[EMAIL PROTECTED]'; [EMAIL PROTECTED]
Subject: RE: Excel spreadsheet: creating charts


If you have Excel, an easy way is to take the spreadsheet, open it in Excel,
start recording a macro, build the chart, the stop the macro recording.
Then go Tools-Macro, select the macro and edit.  This will show the code in
VB.  Translate it to Perl.

Here is a sample of what I am using to generate MS Exchange Statistics and a
3D Bar chart.

my $FALSE   = 0;
my $TRUE= ! $FALSE;

$Worksheet-Range(C3:H6)-Select;
$Excel-Charts-Add;
$Graph = $Excel-ActiveChart;
$Chart = new Win32::OLE(MSGraph.Application) || die GO Away. Can not
create\n;
$Chart-{Visible} = 1;

$Graph-{HasLegend} = 0;
$Graph-{ChartType} = xl3DColumn;
#


$Graph-SetSourceData({
Source=$Excel-Sheets(Msg Worksheet)-Range(C3:H6),
PlotBy=xlRows});

#This gives the labels for the Categories on the 'x' axis
$Graph-SeriesCollection(1)-{XValues} = ='Msg Worksheet'!R2C3:R2C7;

# This gives the label for the server name on the 'y' axis
$Graph-SeriesCollection(1)-{Name} = ='Msg Worksheet'!R3C1;
$Graph-SeriesCollection(2)-{Name} = ='Msg Worksheet'!R4C1;
$Graph-SeriesCollection(3)-{Name} = ='Msg Worksheet'!R5C1;
$Graph-SeriesCollection(4)-{Name} = ='Msg Worksheet'!R6C1;

$Graph-Location({
Where=xlLocationAsObject,
Name=Graph1});
$Graph = $Excel-ActiveChart;
$Graph-{HasTitle} = $TRUE;
$Graph-ChartTitle-Characters-{Text} = Exchange Email Internal Traffic;
$Graph-Axes(xlCategory)-{HasTitle} = $FALSE;
#$Graph-Axes(xlCategory)-AxisTitle-Characters-{Text} = $timeframe;
$Graph-Axes(xlSeries)-{HasTitle} = $TRUE;
$Graph-Axes(xlSeries)-AxisTitle-Characters-{Text} = $timeframe;
$Graph-Axes(xlValue)-{HasTitle} = $TRUE;
$Graph-Axes(xlValue)-AxisTitle-Characters-{Text} = Number of Messages;
$Graph-ChartTitle-Select;
$Excel-Selection-{AutoScaleFont}= 0;
$Excel-Selection-Font-{Size} = 14;


$Graph-Axes(xlCategory)-{HasMajorGridlines} = 1;
$Graph-Axes(xlCategory)-{HasMinorGridlines} = 0;
$Graph-Axes(xlSeries)-{HasMajorGridlines} = 1;
$Graph-Axes(xlSeries)-{HasMinorGridlines} = 0;
$Graph-Axes(xlValue)-{HasMajorGridlines} = 1;
$Graph-Axes(xlValue)-{HasMinorGridlines} = 0;

$Graph-Axes(xlValue)-{WallsAndGridlines2D} = 0;
$Graph-{HasLegend} = 0;
$Graph-{Elevation} = 13;
$Graph-{Perspective} = 35;
$Graph-{Rotation} = 54;
$Graph-{RightAngleAxes} = $FALSE;
$Graph-{HeightPercent} = 100;
$Graph-{AutoScaling} = $TRUE;

undef $Graph;

-Original Message-
From: Richard Fernandez [mailto:[EMAIL PROTECTED]
Sent: Wednesday, March 12, 2003 8:55 AM
To: [EMAIL PROTECTED]
Subject: Excel spreadsheet: creating charts


We have a manual process in place to create Excel worksheets that contain
bar charts. I'm trying to automate this process using perl. The problem is
that I don't know how to access the underlying formulas, in Excel, that
generate the charts. Our current process is as follows:

1) Generate a space separated list of stats on Sun box using sar(1).
2) cut and paste this list into a pre-existing Excel spreadsheet which then
automatically
re-draws the charts based on the new data.

What I need help with is figuring out how to create a sheet with the
necessary charts. Is this possible to do using Spreadsheet::WriteExcel? Is
there a way to determine form the existing worksheet what the formula is for
the charts.

I'm not opposed to doing this a different/better way if anyone has any
suggestions, but I'd like to avoid generating csv files since this would
require a manual import into Excel.

Any help is much appreciated!

Rich



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



upgrading perl

2003-02-13 Thread Richard Fernandez
I have a box that's running perl version 5.005_03 and I'ld like to upgrade
to the latest version.
What's the best way to accomplish this and maintain access to my currently
installed modules?

I'm doing this on a SUN box. Also,  this particular box is behind a firewall
and doesn't have internet connectivity.

TIA for any suggestions!


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




RE: upgrading perl

2003-02-13 Thread Richard Fernandez
Getting the software isn't that hard, just a question of using sneaker
net.
But I would like to avoid having to rebuild all my modules if possible.

Is it feasible to install 5.6 (someone has mentioned that 5.8 isn't binary
compatible with older versions) and then use symlinks to point to the old
modules?
Or is there more to it than that?

Thanks again!

-Original Message-
From: Richard Fernandez [mailto:[EMAIL PROTECTED]]
Sent: Thursday, February 13, 2003 10:26 AM
To: [EMAIL PROTECTED]
Subject: upgrading perl


I have a box that's running perl version 5.005_03 and I'ld like to upgrade
to the latest version.
What's the best way to accomplish this and maintain access to my currently
installed modules?

I'm doing this on a SUN box. Also,  this particular box is behind a firewall
and doesn't have internet connectivity.

TIA for any suggestions!


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



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




Replacing a string in a bunch of files

2003-01-31 Thread Richard Fernandez
I just had a situation where I needed to replace one string with another
string in 200 files.
This is what I came up with, but I know there has to be a better way. Below
is my code.

myfiles contains a list of the files I need to scrub, one per line.

---8-8---
#!/usr/local/bin/perl -w
use strict;
$|++;


my @files = `cat myfiles` or die;
for (@files) {

chomp;
push @ARGV, $_;
}


$^I = .bak;   # Got this from a previous message; thanks Peter!
while () {

s#/u01/app/webMethodsFCS#/u02/app/webMethodsFCSclone#g;
print;

}
-8--8---

Seems to me there should be a way to provide the filenames on the command
line
w/o having to read the list into an array first, but I tried using xargs
(this is unix) and a couple
of other things but couldn't figure it out.

Thanks for the help!


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




How do you code a tail -f if you're using Net::Rsh?

2003-01-22 Thread Richard Fernandez
There's a FAQ that deals with coding a tail -f if you're logfile is on the
same box as the perl script.
But what if you want to use rsh to tail a file remotely?

Here's what I have:
--8---8---


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

my $host = shift or die usage: my_rsh hostname command;
my $cmd  = shift or die usage: my_rsh hostname command;

my $session = Net::Rsh - new();

my @output = $session-rsh($host, 'local_user', 'remote_user', $cmd) or
die;

for (@output) {print;}

88
---8

and here's my command line:

$ sudo my_rsh.pl hostname tail -f /u01/app/apache/logs/access_log

It seems that I never reach the print statement...

I've tried things like:

open(OUTPUT, $session-rsh($host, 'local_user', 'remote_user', $cmd) )
or die;
while (OUTPUT) {print;}

but that doesn't work.

Can anyone shed some light on this?

Thanks.





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