perl

problem making an SSH session using perl

use Net::SSH::Perl; my $ssh = Net::SSH::Perl->new('$host',22); $ssh->login('$user','$pass'); my $out = $ssh->cmd("show clock"); print $out; I have the above script to have an ssh session using perl but I'm having the error message "Can't map service name 'ssh' to port number". I'm using Windows OS. Please advise me where I'm wrong. ...

how to check whether the remote machine is pingable in perl

Hi I need to do check whether the remote machine is pinging so that i can do ssh to that machine and execute commands over there. how to do this check in perl? ...

Difficulty in building an irc bot via Bot::BasicBot

Hi, I am completely new to Perl. I am trying to build a basic IRC bot. In the module Bot::BasicBot, what does the line my ($self, $message) = @_; in the "said" function mean? I do know that my is for private, and @_ is the array for receiving parameters in the function, but how is a hash reference passed here? Also, how do I access...

How can I spawn a long running process in a Perl CGI script?

I'm writing a Perl CGI script right now but it's becoming a resource hog and it keeps getting killed by my web host because I keep hitting my process memory limit. I was wondering if there is a way I can split the script I have into multiple scripts and then have the first script call the next script then exit so the entire script isn't...

How do you check the success of open (file) in Perl?

Hello, The following (not very Perl-ish) code #!/usr/bin/perl if (! -e "mydir/") { print "directory doesn't exist.\n"; } open (my $fh, ">", "mydir/file.txt"); if ($fh) { print "file opened.\n"; print $fh; print $fh "some text\n" or die "failed to write to file.\n"; close ($fh); } else { print "failed to open file.\n"; } ...

How do I reverse the order of two words in a string?

I have a string like this: $a = "Mike , Tree "; I want to reverse it to "Tree, Mike". Is there any function to do that? ...

Why am I seeing DBI errors on the console even though I have wrapped the DBI calls in an eval?

I have a database query that I am running inside an eval, to trap the error. Problem is that the error message is outputting to console, even though it is being trapped. How do I stop the error message from doing this, as I want to parse it myself and spit back my own messages? my $dbh = DBI->connect('dbi:Pg:dbname=database;host=localho...

Array of hashes

Hi , In perl , i have an array of hashes like 0 HASH(0x98335e0) 'title' => 1177 'author' => 'ABC' 'quantity' => '-100' 1 HASH(0x832a9f0) 'title' => 1177 'author' => 'ABC' 'quantity' => '100' 2 HASH(0x98335e0) 'title' => 1127 'author' => 'DEF' 'quantity' => '5100' 3 HASH(0x832a9f0) 'title' => 1277 ...

How can I install Perl modules on a restricted server?

I have a server that I can ssh into but that's it. Otherwise it is totally closed off from the outside world. I'm trying to deploy some scripts I wrote to it but they have several Perl dependencies (Params::Validate, XML::Simple, etc.) I can't get them via yum since our satellite server doesn't have those packages and the normal CPAN ins...

Perl XML::LibXML::Schema will stop validation on first error

Hello, I'm trying to use the XML::LibXML::Schema to validate a xml file against a xsd. The problem is if my xml has multiple semantic issues the validation will die on the first one and not report the others. It finds the first error, no reference to <foobar/> bash-3.2$ ./test.pl test.xsd test.xml xmlfile <test.xml> failed validati...

Perl - Hash of hash and columns :(

Hi folks, I've a set of strings with variable sizes, for example: AAA23 AB1D1 A1BC AAB212 My goal is have in alphabetical order and unique characters collected for COLUMNS, such as: first column : AAAA second column : AB1A and so on... For this moment I was able to extract the posts through a hash of hashes. But now, how can I ...

Parsing / Extracting the inside of an HTML Tag using Perl?

I've been searching a lot on this the past couple days but still haven't found a clear way to do this... I know its simple to parse HTML with Perl to retrieve the text between tags, but I need to actually retrieve the text inside of a tag instead, such as this: <input type="hidden" name="next_webapp_page" value=""/> Here, I would want...

perl sort key then by subkey--if subkey undef set to null string

my %data ( KEY1 => { SUBKEY1 => "Canada", SUBKEY3 => "75.00", SUBKEY2 => "50.00", }, KEY3 => { SUBKEY2 => "150.00", }, KEY2 => { SUBKEY3 => "200.00", SUBKEY1 => "Mexico", }, ); How do I print a list that is sorted by Keyname and for each keyname sorted by subke...

I have create a user account with "user password type: Crypted Password" is there any way I can script

I have create a user account with "user password type: Crypted Password" is there any way I can script it to "user password type: open directory" I've use perl-ldap to create user account but I don't know how to change user password type to open directory, is there any way to do that? USING APPLESCRIPT, PERL BASH....etc? thanks ...

Parsing Just a specific HTML tag by name or ID in Perl?

This is something thats been hard for me to find info on, I was fortunate to get an answer on the other thing I was trying to do that relates to this (code below).. so say I am using the $content input (in reality it would be a full HTML page, not just the snippet I gave below) and I want to just get the contents of the input tag that ha...

Is there a pure regex split of a string containing escape sequences?

Given a string of pipe-separated values (call it $psv), I want to be able to split by those pipes and populate an array. However, the string can also contain escaped pipes (\|) and escaped escapes (\\), both of which are to be considered mere literals. I have a couple solutions for this problem in mind: Replace both escape sequences wi...

In Perl, how can I iterate over multiple elements of an array?

I have a CSV file that I use split to parse into an array of N items, where N is a multiple of 3. Is there a way i can do this foreach my ( $a, $b, $c ) ( @d ) {} similar to Python? ...

Exploding ROOT.war

I am copying my ROOT.war file to webapps of Tomcat 6.0 . Is there a way I can explode the file upon copying. i.e when my script copies it in the webapps .. it should explode and create ROOT directory ?? ...

In Perl, how can I parse an XML file that is too large to fit in available memory?

I have a very large XML file (If you care, it's an AIXM file from EAD, but that's not important). In order to figure out how it is used, I want to write a simple script that goes through and for every node, record what subnodes occur below it and how many times, so I can see which nodes contain <AptUid> and whether most <Rdn> nodes have...

Perl regex testing blank or expression

hi - why is this expression returning true for character 1 or V (and others)? how could i rewrite it so that it would return true only when its blank or a character a-z? ~((^$)||(^[a-z]$))~ ...