Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

using Net::SSH::Perl: problem with Math::Pari

by Anonymous Monk
on May 07, 2008 at 04:59 UTC ( [id://685142]=perlquestion: print w/replies, xml ) Need Help??

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hello,

I'm currently trying to open an SSH session via perl, execute a command, and retrieve the result of the command for analysis.

I use a Mac, and succeeded after many tries to install Net::SSH::Perl. (Compiled using Macports)

Unfortunately, Math::Pari has a problem ("hiremainder symbol not defined") when I use SSH-2 but it seems to work with SSH-1, at least it tries to connect. Unfortunately, my host accept only SSH-2 (and I have no admin access to it).

So, here my questions:

— Has anybody already had this problem with Math::Pari?
— What is the best method for this task in your opinion? pexpect? This script will actually always run on a unix platform (Mac OS X or centOS), so win32 doesn't matter.

Math::Pari version: 2.010709
Net::SSH::Perl version 1.30

Greetings,
  • Comment on using Net::SSH::Perl: problem with Math::Pari

Replies are listed 'Best First'.
Re: using Net::SSH::Perl: problem with Math::Pari
by tachyon-II (Chaplain) on May 07, 2008 at 05:37 UTC
      Hello,

      well I tool a look at it, but I'm not able to use this information:

      — I have no GP/PARI directory on my system
      — I have no kernel*.o files in my libPARI directory

      I think there is something I don't understand at all.

      I'll try Net::SSH. Thank you for your answer!

        The error seems to occur when different compilers have compiled the OS and Perl. Net::SSH ought to work without problems but if you need to install Net::SSH::Perl on approach would be to compile your own Perl from source, then install Math::Pari (it will pull down lib pari itself for you) and then Net::SSH::Perl.

Re: using Net::SSH::Perl: problem with Math::Pari
by derby (Abbot) on May 07, 2008 at 11:38 UTC

    It appears to be a Net::SSH week! I would recommend Net::SSH2 over both Net::SSH::Perl (and it's loooong chain of dependencies) and Net::SSH (which is just a thin wrapper over the ssh command line program).

    I'm beginning to think (stay back!) that with this week's questions about Net::SSH and petdance's blog about perl decentralizing, a real nice diversity site would be a *recommended* CPAN where someone (or some group) has pared down CPAN to what they consider the best selection(s). I know, I know ... "what's best for me, isn't best for you" ... "removing TMTOWTDI is bad" ... "it's not the perl way" ... "yadda yadda yadda." ... but it could have it's uses like 'Beginners CPAN' or 'Pure Perl' CPAN or 'Easy Cheesy' CPAN ... or my favorite 'Don't Make me Think' CPAN. (but then again, maybe this functionality all ready exists in the current CPAN and I'm just missing it).

    -derby

    Update: I'm not suggesting a CPAN replacement ... just a *filter* of CPAN ... under the covers, it would still be CPAN.

Re: using Net::SSH::Perl: problem with Math::Pari
by sgt (Deacon) on May 07, 2008 at 22:42 UTC

    Humm, you say you are on Un*x. Why not qx(ssh host command)? or is it that you wished to use Net::SSH::Perl mainly to bend authorization (passwd, certs etc) rules

    cheers --stephan
      I don't understand what you mean with bending the authoriation rules...

      I just want a script able to log in via ssh2 periodically as a cron job, so not requesting any user interaction.

        Well, first you are aware that 'ssh host command' runs command on host, aren't you. If certificates have been set up you will not be prompted for a passwd. So this would be suitable for cron. Note that command will be executed by the system shell, so you can actually use perl on the local side to build a (shell) script. You could also scp the command (or script) and then execute it remotely.

        Now if the remote sshd asks for a passwd, you'll need to pass the passwd using expect for example (Perl module or command), or tweak pssh the client that comes with Net::Ssh::Perl so that it can read the passwd from a file o env_var o whatever.

        Finally there are security implications doing the latter.

        As an example I'll show you a remote uname -a using expect and ssh:

        #!/bin/expect -f spawn "ssh -l my_user remote_host uname -a\r" expect -re "[Pp]assword: " send "my_passwd\r"
        cheers --stephan
Re: using Net::SSH::Perl: problem with Math::Pari
by mvcorrea (Novice) on Jun 25, 2010 at 17:12 UTC
    The way I manage to install Net::SSH::Perl thru hand installing Math::Pari on a Debian System

    download
    ftp://megrez.math.u-bordeaux.fr/pub/pari/unix/OLD/pari-2.1.7.tgz
    http://search.cpan.org/CPAN/authors/id/I/IL/ILYAZ/modules/Math-Pari-2.0305_01080604a.tar.gz
    unpack everything and copy the Math-Pari folder inside the pari folder
    then make Math-Pari as usual
    steps: > tar xvfz pari-2.1.7.tgz > cd pari-2.1.7 > mv ../Math-Pari-2.0305_01080604a.tar.gz . > tar xvfz Math-Pari-2.0305_01080604a.tar.gz > cd Math-Pari-2.0305_01080604a > perl Makefile.PL && make && make test && make install > perl -MCPAN -e 'install Net::SSH::Perl'
      HI
      am using the following code


      my $user = "root";
      my $pass = "root";
      my $host = "192.168.239.108";
      my $cmd = "ls";
      use Net::SSH::Perl;
      my $ssh = Net::SSH::Perl->new($host);
      $ssh->login($user, $pass);
      my($stdout, $stderr, $exit) = $ssh->cmd($cmd);
      print("$stdout, $stderr, $exit");


      but am getting the bellow response
      "Can't set socket non-blocking: Bad file descriptor at C:/Perl/site/lib/Net/SSH/Perl.pm line 216."




      can some one tell me the reason for this response?

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://685142]
Approved by ysth
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (2)
As of 2024-04-20 03:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found