Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

using rsh command in perl

by Anonymous Monk
on Dec 22, 2001 at 15:32 UTC ( #133962=perlquestion: print w/replies, xml ) Need Help??

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

Hi, I want to generate a report for all the users working in the office displaying the server & the no. of users home partitions hosted on a particular server.For that, i need to connect to each server ( using rsh <servername> ). Then go to a particular directory & count the no. of words of the output of "ls command" ( which will be the no. of users on that server). for this i'm using the following perl program but i'm not able to connect to the servers using "rsh" command in perl. can anyone please help me with that. The problem is to write a perl code, such that, using a foreach loop, i can log on to each server (one-by-one), then reach a particular directory on that server, execute a commnad to count the no. of users on that. Please reply me on Thanks, Sethji

Replies are listed 'Best First'.
Re: using rsh command in perl
by tachyon (Chancellor) on Dec 22, 2001 at 21:11 UTC

    Sadly requests from Anonymous Monk for personalised replies to tend not to meet with enthusiastic responses. Perl can do all of what you want and more. To execute a command line command in perl you just enclose it in back ticks like this:

    my $output = `rsh blah blah`;

    The output of the command is caught by $output. For info on loops see tutorials




Re: using rsh command in perl
by Anonymous Monk on Dec 22, 2001 at 20:28 UTC
    I do something like that to check the status of my servers.
    @hosts = qw(hosta hostb hostc); foreach $host (@hosts) { $status{$host} = `rsh -l ems $host /path/command`; }

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://133962]
Approved by root
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (3)
As of 2020-09-25 20:56 GMT
Find Nodes?
    Voting Booth?
    If at first I donít succeed, I Ö

    Results (141 votes). Check out past polls.