Re: Implementation of sFTP using Perl

2014-04-07 Thread Wernher Eksteen
I preffer to use Net::OpenSSH ( http://search.cpan.org/~salva/Net-OpenSSH-0.60/lib/Net/OpenSSH.pm) This is an exceptional Perl module on most things SSH related, not limited to just sFTP which allows the use of various other SSH calls from the same module without the need to use other modules to f

Re: Reading a config file and exporting it updated with the new/changes values in the same format.

2014-03-03 Thread Wernher Eksteen
ame entries and their values intact. Regards, Wernher On Tue, Mar 4, 2014 at 5:18 AM, Wernher Eksteen wrote: > Hi Jim, > > The format of the config file is like this: > > *Config file example1:* For one host in this case named hostname1 > belonging to 4 contactgroups (group1

Re: Reading a config file and exporting it updated with the new/changes values in the same format.

2014-03-03 Thread Wernher Eksteen
rod', 'tag_networking': 'lan'}}) < end config file example 2 --------> Final note: Notice the lines containing FOLDER_PATH in the *all_hosts +=*section in config file example 2: "hostname1|cmk-agent*|prod*|lan|tcp|wato|/" + FOLDER_P

Re: Reading a config file and exporting it updated with the new/changes values in the same format.

2014-03-03 Thread Wernher Eksteen
2014 at 12:33 PM, Shlomi Fish wrote: > Hello Wernher, > > On Sun, 2 Mar 2014 21:42:00 +0200 > Wernher Eksteen wrote: > > > Hi Everyone, > > > > I need your help with this one please. > > > > I have a config file that is written/updated with a Pyth

Reading a config file and exporting it updated with the new/changes values in the same format.

2014-03-02 Thread Wernher Eksteen
Hi Everyone, I need your help with this one please. I have a config file that is written/updated with a Python based web front end tool. I would like to add/remove hosts to/from this config file using Perl. The idea I have is for Perl to read this config file, and instead of adding/replcing valu

Re: regex to get version from file name

2014-02-23 Thread Wernher Eksteen
Great thank you! On Fri, Feb 21, 2014 at 6:02 PM, Jim Gibson wrote: > > On Feb 21, 2014, at 6:21 AM, Wernher Eksteen wrote: > > > Hi all, > > > > From the below file names I only need the version number 1.2.4 without > explicitly specifying it. > > >

Re: regex to get version from file name

2014-02-23 Thread Wernher Eksteen
Thanks, this also worked for me... foreach my $i (@fileList) { push @versions, $i =~ m/\b(\d+\.\d+\.\d+)\b/g; } my %seen; my @unique = grep { ! $seen{$_}++ } @versions; On Sun, Feb 23, 2014 at 4:27 PM, Jim Gibson wrote: > > On Feb 23, 2014, at 5:10 AM, Wernher Eksteen

Re: regex to get version from file name

2014-02-23 Thread Wernher Eksteen
wrote: > Use LWP to get web data - not lynx and the like unless you can't help it. > I prefer using Web::Scraper to parse html but either way it's probably best > not to use a regex (see SO and similar for discussions on the like). > > On Feb 23, 2014 8:13 AM, "Wernher E

Re: regex to get version from file name

2014-02-23 Thread Wernher Eksteen
ot; next to each other, if I pass a newline to $i such as "$i\n" it then prints "11" ? foreach my $i (@fileList) { print $i =~ /\b(\d+\.\d+\.\d+)\b/; } Thank you, Wernher On Fri, Feb 21, 2014 at 4:27 PM, Shawn H Corey wrote: > On Fri, 21 Feb 2014 16:21:57 +0200

regex to get version from file name

2014-02-21 Thread Wernher Eksteen
Hi all, >From the below file names I only need the version number 1.2.4 without explicitly specifying it. check_mk-1.2.4.tar.gz check_mk-agent-1.2.4-1.noarch.rpm check_mk-agent-logwatch-1.2.4-1.noarch.rpm check_mk-agent-oracle-1.2.4-1.noarch.rpm mk-livestatus-1.2.4.tar.gz mkeventd-1.2.4.tar

Comparing two arrays

2012-06-06 Thread Wernher Eksteen
Hi, I have two arrays that I need to compare, and then print the differences: @array1 contains this: /dev/sdmt1 /c4devpr64 /dev/sdmq1 /c4devpr66 /dev/sdmp1 /c4devpr67 /dev/sdml1 /c4devpr69 @array2 contains this: /dev/sdmt1 /c4devpr64 /dev/sdms1 /c4devpr65 /dev/sdmn1 /c4devpr68 /dev/sdml1 /c4de

Re: How can I install a perl module without a root authority?

2011-08-16 Thread Wernher Eksteen
If you can justify the need for it and the importance thereof, surely your Linux/Unix Admin can install it for you or provide you with the necessary sudo access so you can do it yourself. That probably depends on various factors, ie if that's a production system, if change control needs to take pla

Re: Verifying an e-mail address

2011-07-01 Thread Wernher Eksteen
On 27 June 2011 20:53, wrote: >I'd like to find a way to check if an e-mail address that is entered > on a form is valid or, at the very least, just not invalid. Checking CPAN, > I ran across a module called Email::Verify::SMTP. Has anyone used this > before? If so, what are your impre

Re: String Formatting by Column

2011-06-28 Thread Wernher Eksteen
> > That's exactly right. I meant that, if you were using an external file, > you only needed to replace the line > > my $fh = *DATA; > > with > > open my $fh, '<', 'myfile.txt' or die $!; > > which is pretty much what you have done. Unfortunately I made a mistake > and wrote > > while () { > > in

Re: matplotlib

2011-06-28 Thread Wernher Eksteen
Ok well on second thought, MATLAB probably is MATLIB... On 28 June 2011 20:10, Wernher Eksteen wrote: > I really don't know much about MATLIB, but looking on their site it doesn't > seem free: http://www.mathworks.com/products/matlab/ > > I stumbled on PDL by chance

Re: matplotlib

2011-06-28 Thread Wernher Eksteen
.org/search?query=pgplot&mode=all) and GnuPlot ( > http://search.cpan.org/search?query=gnuplot&mode=allapplications) are > discussed. I don't know enough about your task (or about Perl to be honest) > to know if those will help, but that is as far as my googling gets me. > > On

Re: String Formatting by Column

2011-06-28 Thread Wernher Eksteen
Hi Rob, I wasn't quite sure at first what you meant by passing the file handle in the while loop when $fh already existed, so I changed the code slightly like this: my $file = "file.txt"; open(my $fh, "<", $file) or die $!; while (<$fh>) { Works like a charm, thanks again! Regards, Wernher

Re: matplotlib

2011-06-28 Thread Wernher Eksteen
cial packages such as MATLAB and IDL this is of considerable importance for workers who want to do some work at home and cannot afford the considerable cost to buy commercial packages for personal use. Wernher On Tue, Jun 28, 2011 at 6:58 PM, Wernher Eksteen wrote: > Not sure if this is

Re: matplotlib

2011-06-28 Thread Wernher Eksteen
Not sure if this is relevant, but I stumbled on this.. http://pdl.perl.org/ Wernher On Thu, Jun 23, 2011 at 9:30 AM, Sayth Renshaw wrote: > On Thu, Jun 23, 2011 at 6:32 AM, Bryan R Harris > wrote: >> >> >> I much prefer perl to python given my recent forays into that language >> (python's regex

Re: String Formatting by Column

2011-06-26 Thread Wernher Eksteen
All I need to do is follow the road, and then build my own maps based on what I have learned from people such as yourself. Regards, Wernher On 25 June 2011 19:02, Rob Dixon wrote: > On 24/06/2011 08:45, Wernher Eksteen wrote: > > > > I've attached a text file containing the ori

Re: String Formatting by Column

2011-06-24 Thread Wernher Eksteen
or am I wrong? Regards, Wernher On 24 June 2011 10:19, Dermot wrote: > On 24 June 2011 08:45, Wernher Eksteen wrote: > > Hi, > > > > I've attached a text file containing the original and required format and > > avoid the format > > being lost by jus

String Formatting by Column

2011-06-24 Thread Wernher Eksteen
Hi, I've attached a text file containing the original and required format and avoid the format being lost by just pasting it in the email body. The original format is separated by a space, but need to replace the space with a comma, so it will become a comma delimited csv file which I will then i

Re: Perl Hash Comparison and concatenate result from %hash2 compared to %hash1 into %hash3

2011-04-04 Thread Wernher Eksteen
k1 @$aref"; >                $string = ' ' x length($string) if $seen{$k1}++; > >                print "$string\t$key $hash2{$key}\n"; >        } > } > > delete @hash1{ keys %seen }; > print "$_ @{ $hash1{$_} }\n" for sort keys %hash1; Chris, thank you so very much for this, it does exactly the way I need it!!! I have learned a great deal of things since I joined this list last week Friday the 1st. Kind regards, Wernher Eksteen -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

Re: Perl Hash Comparison and concatenate result from %hash2 compared to %hash1 into %hash3

2011-04-03 Thread Wernher Eksteen
Hi Shawn, Thank you very much, Shown from your code below and my print1 and prin2 comments below: print1 correctly prints the following: emcpoweraa sdae sdch sdek sdgn /dwpdb033 emcpowerd sdba sddd sdfg sdhj /odsdb005 emcpowerc sdbb sdde sdfh sdhk /odsdb006 emcpowerbc sdb sdbe sddh sdfk /s00_11

Re: Perl Hash Comparison and concatenate result from %hash2 compared to %hash1 into %hash3

2011-04-03 Thread Wernher Eksteen
Hi John, >%hash1 > emcpowera sdbd sddg sdfj sdhm >emcpoweraa sdae sdch sdek sdgn >emcpowerbc sdb sdbe sddh sdfk >emcpowerc sdbb sdde sdfh sdhk >emcpowerd sdba sddd sdfg sdhj > >%hash2 >emcpowera1 /dwpdb006 > emcpoweraa1 /dwpdb033 >emcpowerbc1 /s00_11 >

Re: Perl Hash Comparison and concatenate result from %hash2 compared to %hash1 into %hash3

2011-04-03 Thread Wernher Eksteen
> I suggest you reduce your tab size from eight characters, which leave > your code spread out and less readable. Four or two is more usual > nowadays. Thank you, I will do so from now on. > Meaningful variable names are also important. Using $i as the key to > %hash1 and $b as the key to %hash2

Re: Perl Hash Comparison and concatenate result from %hash2 compared to %hash1 into %hash3

2011-04-03 Thread Wernher Eksteen
> so, lets do what you asked (i like hashes better anyway :) ) > > my %hash3, %nothash; > my $found = 0; > while( my( $ikey, $ival ) = each( %hash1 ) ) { >   while( my( $jkey, $jval ) = each( %hash2 ) ) { >      if( ( $ikey == $jkey ) and ( $ival == $ikey ) ) { >         $hash3{ $ikey } = $ival; >

Re: Perl Hash Comparison and concatenate result from %hash2 compared to %hash1 into %hash3

2011-04-03 Thread Wernher Eksteen
Got this to work, but is there a better way to do this? #!/usr/bin/perl use strict; use warnings; my ( $val, @matched, @unmatched, %hash1, %hash2 ); %hash1 = ( "emcpowera" => "sdbd sddg sdfj sdhm", "emcpoweraa" => "sdae sdch sdek sdgn", "emcpowerbc" => "sdb sdbe sddh sdfk", "emcpowerc" => "sdbb

Perl Hash Comparison and concatenate result from %hash2 compared to %hash1 into %hash3

2011-04-03 Thread Wernher Eksteen
Hi, How do I compare the column 1 in %hash2, with column 1 in %hash1 so that when a match is found to append or concatenate the hash key (column 1) and it's associated values from %hash2 with that of %hash1 and build a new hash %hash3 as the end result. %hash1 emcpowera   sdbd sddg sdfj sdhm emcp

Re: How can I do this in Perl?

2011-04-03 Thread Wernher Eksteen
Hi, Thank you for showing me a better way to run the while loops, not using the foreach loop, but the for loop and some extra regex ways to accomplish things. Otherwise it prints out exactly what I had before :-) I have attached my request in a text file this time, to make it more readable withou

Re: How can I do this in Perl?

2011-04-02 Thread Wernher Eksteen
$i, join(' ', @{$allEmcMountedDisks{$i}}); } # [2nd foreach loop] # Print each local mouted disk found with it's mount point on the same line. foreach my $i (sort keys %allLocalMountedDisks) { printf "\n%s %s\n", $i, join ' ', @{$allLocalMountedDisks{

Re: How can I do this in Perl?

2011-04-01 Thread Wernher Eksteen
> that * isn't doing what you think it does. perl regexes are not shell > globs. it happens to work anyway since the tokens are unique > enough. read perlretut to learn perl regexes. > > what have you tried so far? you know enough perl to get the array of > lines and loop over that. in english (or

Re: How can I do this in Perl?

2011-04-01 Thread Wernher Eksteen
pipe to a child process running your command, > rather than read all the output into an array and process that. I > suggest something like the program below, which builds a hash of the > device/disk relationship and prints it out at the end. > > HTH, > > Rob Thanks Rob, th

How can I do this in Perl?

2011-04-01 Thread Wernher Eksteen
Hi, >From the folowing list is a result of the @power array, when run through the foreach loop: Pseudo name=emcpowerd 1 lpfc sdba SP A7 active alive 0 0 1 lpfc sddd SP B7 active alive 0 0 3 lpfc