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

How do I do an 'ls -alp' in a directory on a remote machine?

Replies are listed 'Best First'.
Re: remote server directory read
by Beatnik (Parson) on May 24, 2001 at 20:29 UTC
    Using Net::SSH::Perl (and not rsh !!)
    #!/usr/bin/perl -w use Net::SSH::Perl; use strict; my $user = ""; #Fill me in my $pass = ""; #Fill me in my $ssh = Net::SSH::Perl->new($host); $ssh->login($user, $pass); my($stdout, $stderr, $exit) = $ssh->cmd("ls -alp");
    Greetz
    Beatnik
    ... Quidquid perl dictum sit, altum viditur.
Re: remote server directory read
by no_slogan (Deacon) on May 24, 2001 at 19:52 UTC
    ssh remote_machine ls -alp
    (if you have passwordless ssh access to remote_machine, which is probably a bad idea)

    mount remote_machine:/remote_dir /mnt ; ls -alp /mnt
    (if remote_machine exports /remote_dir with NFS, and you're root locally)

    ls -alp /net/remote_machine/remote_dir
    (if remote_machine exports the dir, and local machine has automount set up with a hosts map)

Re: remote server directory read
by blue_cowdawg (Monsignor) on May 24, 2001 at 19:48 UTC

    Very carefully! (sorry... could'nt resist!) :-)

    rsh -l user machine ls -alp
    oughta do it. Of course if you doing this within Perl it would be more like:
    open PIPE,"rsh -l user machine ls -alp |" or die "Screaming!:$!";
    milage will vary depending on the platform of course...

    ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    Peter L. Berghold --- Peter@Berghold.Net
    "Those who fail to learn from history are condemned to repeat it."