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

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.

Replies are listed 'Best First'.
Re^3: user net:openSSH and File::find::Rule together.
by salva (Canon) on Feb 15, 2018 at 17:16 UTC
    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.

        No, what you send in stdin_data must be a complete script.

        As I already told you, for more complex things you can use Object::Remote.