in reply to File test on remote machine and mkpath

An alternative is to use the Module GRID::Machine (version 0.78 or higher, available at CPAN) I've developed. See an example:

$ cat copyandmkdir.pl #!/usr/local/bin/perl -w use strict; use GRID::Machine; my $host = 'orion.pcg.ull.es'; my $dir = shift || "somedir"; my $file = shift || $0; # By default copy this program my $machine = GRID::Machine->new( host => $host, uses => [qw(Sys::Hostname)], ); my $r; $r = $machine->mkdir($dir, 0777) unless $machine->_w($dir); die "Can't make dir\n" unless $r->ok; $machine->chdir($dir)->ok or die "Can't change dir\n"; $machine->put([$file]) or die "Can't copy file\n"; print "HOST: ",$machine->eval(" hostname ")->result,"\n", "DIR: ",$machine->getcwd->result,"\n", "FILE: ",$machine->glob('*')->result,"\n";
when running the former example we obtain an output like this:
$ copyandmkdir.pl HOST: orion DIR: /home/casiano/somedir FILE: copyandmkdir.pl

Replies are listed 'Best First'.
Re^2: File test on remote machine and mkpath
by DeadPoet (Scribe) on Jan 18, 2011 at 00:16 UTC
    If your target is a UNIX machine you can send through your communications handler 'test -e file_name && echo EXISTS || echo DOESNOTEXIST'