using SSH without modules

N

Nene

Hello,

My object is to do a few things without the use of modules, I only
know how to use
open(SSH, "$ssh $command |") || die "ssh: $!";


But I want to cd into a directory and search through multiple files.
My example below opens a single file. Is it possble to do what I
want?


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


my $misc = '192.168.xxx.xxx.';
my $MAX = '100';


foreach my $x (1..$MAX) {


{
my $ssh = "ssh user\@$misc";
my $command = "perl -ne 'print' /root/file/log.txt";


open(SSH, "$ssh $command |") || die "ssh: $!";


print "connected to $misc$x\n";


while (my $current_line = <SSH>) {
my $QUERY = 'regex1_example';
my $QUERY_1 = 'regex2_example';


if ( $current_line =~ /COMPLETE: (?:$QUERY|$QUERY_1) .* from \S+
complete in (?:[3-9]{5}|[1-9]{6,9}) msecs/ ) {


print LOG "$current_line\n";
 
T

Tad J McClellan

My object is to do a few things without the use of modules,


What is wrong with modules?

my $command = "perl -ne 'print' /root/file/log.txt";


my $command = 'cat /root/file/log.txt';

or if wheel reinvention really is required for some odd reason:

my $command = 'perl -pe1 /root/file/log.txt';
 
N

News123

I have some potential explications about why some people try to avoid
modules:


In big companies the assumption that perl is installed in the companies
network is installed can be made.

A certain minimal perl version can also be assumed.
Companies have often networks with mixed with solaris / linux / HP-UX /
(Windows)

Many companies manage to have such a 'smart' setup, that about 90 % of
all programs of the type "./configure ; make ; make install" do not compile.
In these setup compiling a perl module which contains C-code can be a
night mare.

Additionally every perl module with C code has to be compiled for all
existing platforms.

Firewalls, that don't allow to access CPAN directly and the fact, that
some modules have a quite impressive dependency tree are another factor.
part of the plain perl)

Many users are not smart enough to download and install perl modules in
sach a pretty setup.

The fact, that some companies don't give root privileges to users and
that perl modules can therefore not be installed in the default paths
doesn't help either.

If on the other hand somebody distributes a small perl script or a small
tar file with perl only code and it is written halfways clean, then he
code is reusable across many platforms and can be installed by almost
anybody.


Of course there might be suggestions like.
distributing root privileges, sticking to standard linux distributions,
etc. but don't believe seriously, that you manager and all the other
managers of the other teams and sites would accept such simple solutions.

Almost every time I wrote a perl script, which depends on modules, which
are not distributed with every perl releaseI had to do remote nanying to
make the scripts work for others.

perl only code on the other hand travels quite easily.


Just some thoughts.


Perhaps one solution would be to add more modules to the standard perl
distribution.


For all perl code, that I write for myself I try to use as many modules
as possible.
It's always more fun to concentrate on something new and not to
er-invent the wheel.


bye


N
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,185
Members
46,738
Latest member
JinaMacvit

Latest Threads

Top