http://www.perlmonks.org?node_id=133962

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 sethji2@rediffmail.com 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 me@home.com 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

    cheers

    tachyon

    s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print

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`; }