in reply to user net:openSSH and File::find::Rule together.

There are several ways to do what you want:

Replies are listed 'Best First'.
Re^2: user net:openSSH and File::find::Rule together.
by garcimo (Novice) on Feb 15, 2018 at 17:12 UTC
    thanks I prefer using the stdin_data route. somehow it is not doing it: this is the code:
    $ssh->error and die "Couldn't establish SSH connection: ". $ssh->error; my $output = $ssh->capture(stdin_data => <<'EOS', '/usr/bin/perl'); use File::Find::Rule; my $today = time(); my $onehour = $today - (60*60); my @files = File::Find::Rule->file() ->name("*.0") ->mtime("<$onehour") ->in( "/mypath/" ); for my $file (@files) { print "$file\n"; } EOS
    the scripts outputs this: bash: line 15: stdin_data: command not found I do not understand what bash has to do here since we are full perl. thanks in advance for the coop.
      Oops, the options to capture have to be passed as a hash reference. I have corrected the code above.

        could the contents of the data feed by stdin_data we put in a subroutine instead..

        I tried to put it in a subroutine like this:
        sub finder { use File::Find::Rule; my $today = time(); my $onehour = $today - (60*60); my @files = File::Find::Rule->file() ->name("*.0") ->mtime("<$onehour") ->in( "/export/home/adm_garcimo" ); for my $file (@files) { return $file; } }
        then call the subroutine:
        my $output = $ssh->capture({stdin_data => <<'EOS'}, '/usr/bin/perl'); finder() EOS print $output
        but it does not find the subroutine..

        thanks again.