in reply to Creating path on remote host
Besides being more secure, the other advantage of jeffa's solution is that it gives you standard output, standard error, and command exit status neatly packaged up. That way you can check exit status and/or standard error to see why it failed. In your example you can do something similar by redirecting standard error to a file and checking if anything ends up there, something like this:
My experience with rsh is that it usually does not propagate back any bad exit status from the remote side. I do sometimes bypass ssh for internal connections.use strict; use POSIX qw(tmpnam); my $dir = '/foo/bar'; my $server = 'fred'; my $error_file = tmpnam(); my $remotecmd = `rsh $server mkdir -p $dir 2>$error_file`; if ((stat($error_file))[7]) { local *ERROR; open ERROR, "<$error_file" or die "Failed to ope $error_file: $!\n +"; my @lines = <ERROR>; warn "Failed to make remote directory: ", join("\n", @lines), "\n" +; } unlink($error_file);
|
|---|