Sponsored Content
Full Discussion: Perl Module
Top Forums Shell Programming and Scripting Perl Module Post 302293068 by Phi01 on Monday 2nd of March 2009 09:18:30 AM
Old 03-02-2009
Quote:
Originally Posted by KevinADC
The short of it is that the system you are running the script on does not support getpwuid. I don't know what you can do about it though.
My system is Windows XP, surly i can run a connection script to a unix box on that.

I'm having these errors now, with these scripts, maybe this will help in me getting an answe. I'm using this script to create a connection.

Code:
use Net::SSH::Perl::SSH1 ;

$scon = Net::SSH::Perl->new ("com123.mynetwork.mydomain.com");
$scon->login("user123","pass123");
print "looking around ...\n";
($output,$errors,$exit) = $scon->cmd("ls -l");
print $output;

With this error:
Code:
Can't set socket non-blocking: Bad file descriptor at C:/Perl/site/lib/Net/SSH/P
erl.pm line 217.

Another Example:
Code:
#!/opt/local/bin/perl
#
# checkDiskspace.pl: See if any partitions are greater than a percentage and notify
#
use strict;
use warnings;

use Net::SSH::Perl;
use Math::BigInt::GMP;  # Don't forget this!

$| = 1;

my $alert_percent = 75;
my $server = 'com123.mynetwork.mydomain.com';
my $username = 'user123';
my $password = 'pass123';


# However you wanna notify yourself (like email)
sub alert_notify {
    my $message = shift;
    print "STUB: $message\n";
}

# Log into server
print "Creating ssh object... ";
my $ssh = Net::SSH::Perl->new($server); # Error check this
print "done\n";
print "Logging into server... ";
$ssh->login($username, $password); # Error check this
print "done\n";

# Check df
my $command = "df";
print "Running command ($command)... ";
my ($stdout, $stderr, $exit) = $ssh->cmd($command); # Check output
print "done\n";

# Find percentage
foreach my $df_line (split(/\n/, $stdout)) {
    # If disk space usage percent > $alert_percent, notify
    if ($df_line =~ /\s+(\d+)%\s+(\/.*)/ && $1 >= $alert_percent) {
        alert_notify ("[$server] device $2 at $1 percent!");
    }
}

With this error:
Code:
Creating ssh object... Can't set socket non-blocking: Bad file descriptor at C:/
Perl/site/lib/Net/SSH/Perl.pm line 217.

Final Example, this time the dos command promt hangs, i'm still waiting to see if anything happens.

Code:
use strict;
use warnings;

use Net::SSH::Perl;

my $server = 'alpha12z';
my $user = 'user123';
my $pwd = 'pass123';

my $ssh = Net::SSH::Perl->new($server);

$ssh-> login($user, $pwd);
my ($out, $err, $exit) = $ssh-> cmd("ls");

The Result is that the command prompt hangs, i'm gracefully waiting and hoping for a connection, at this point i will be happy with any connection even a slow one.!!
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Replace Perl Module name in all Perl scripts

I want to replace a Perl module name in all my Perl Scripts in the cgi-bin directory. How is it possible? I have the following statement in my scripts use myUtil; I want to change it to use myUtil777; Regards, Rahul (2 Replies)
Discussion started by: rahulrathod
2 Replies

2. Shell Programming and Scripting

perl module question

Couple questions on perl module.. 1)where is the best place on web where it tells you what modules can do? For example, use Text::Autoformat Where is the best place on line or via command line to find the exact capability of autoformat? 2)Is there already a perl module to read *.cap... (1 Reply)
Discussion started by: convenientstore
1 Replies

3. Shell Programming and Scripting

Perl Module Help

Hi All, I am using a perl module Win32::AdminMisc in my perl script. When i running in activestate perl v5.10.0 it shows folling error --- Can't locate loadable object for module Win32::AdminMisc in @INC (@INC contains: C:/Perl/site/lib C:/Perl/lib .) at example.pl Please reply. ... (7 Replies)
Discussion started by: suprcool
7 Replies

4. Shell Programming and Scripting

Help with Perl Module

I dont know if this is a dumb question, but I am unable to move ahead and need help - There is a perl module called Header.pm which was written by someone else. I am trying to write a simple perl script which uses a function provided by the module. The function has been exported by the module... (9 Replies)
Discussion started by: NewDeb
9 Replies

5. UNIX for Dummies Questions & Answers

help in writing perl module

Hi i have written a perl script which was then converted to perl module by me. it works as expected. but i have to put it on many servers so i want to build a package for it. i dont know how to do that. just to check i copied perl module in "lib" directory which is working. ( directly copied... (1 Reply)
Discussion started by: zedex
1 Replies

6. Shell Programming and Scripting

Which Perl Module to use?

Hi, I need to read an excel binary file and write the data to a text file. Is it possible using Spreadsheet-ParseExcel-0.58 ? If not, is there any module available in CPAN to do this? Thanks, Js (1 Reply)
Discussion started by: jisha
1 Replies

7. Shell Programming and Scripting

calling perl subroutine from perl expect module

All, Is it possible to call a subroutine from the perl expect module after logging to a system that is within the same program. My situation is I need to run a logic inside a machine that I'm logging in using the expect module, the logic is also available in the same expect program. Thanks,... (5 Replies)
Discussion started by: arun_maffy
5 Replies

8. Shell Programming and Scripting

Perl SSH without a perl module

I'm trying to create a perl script that will do 1 SSH session, but be able to write multiple commands to the session and receive multiple outputs. I know there are modules out there like Net:SSH::Perl, but I'm not allowed to use it. I was thinking of doing something like an open3 on an ssh... (4 Replies)
Discussion started by: mrwatkin
4 Replies

9. Shell Programming and Scripting

Perl module

I am recieiving an out of memory issue in my perl module while updating the records in the oracle table. Let me know what are the check or troubleshoot steps need to be done from my end to fix the issue. (1 Reply)
Discussion started by: ramkumar15
1 Replies

10. Shell Programming and Scripting

Perl script module

I took the copy of the production module to the home directory and executing the module. one of the test prdmsk.pm module is present in the home directory ctskk. would like to know whether the below syntax is correct. use strict; use lib "/home/ssprod/ctskk"; use lib::Prdmsk; ... (0 Replies)
Discussion started by: ramkumar15
0 Replies
All times are GMT -4. The time now is 07:47 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy