in reply to shell to perl equivalent
... system('scp', '/users/myuser/merc/rem_snew.pl', "$remoteuser\@$remotes +erver:/users/$remoteuser/tmp/rem_snew2.pl"); my $result = `ssh $remoteuser\@$remoteserver perl /users/$remoteuser/t +mp/rem_snew2.pl`; print "$result\n"; system('ssh', "$remoteuser\@$remoteserver", 'rm', ...);
Of course, you can use a subroutine to factor out all the common arguments that are being used, but this is basically how you would do it.
Update: there really should be a multi-argument form of the backtick operator. One could be created using IPC::Open2, but there really should be one that's readily available. Is there one? Otherwise something like the following should be made into a module:
use IPC::Open2; sub backtick { my $pid = open2(my $rfh, undef, @_); my $buf; while (<$rfh>) { $buf .= $_; } close($rfh); waitpid $pid, 0; $buf; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: shell to perl equivalent
by mercuryshipz (Acolyte) on Feb 18, 2008 at 19:41 UTC | |
by kyle (Abbot) on Feb 18, 2008 at 20:12 UTC | |
by mercuryshipz (Acolyte) on Feb 18, 2008 at 21:19 UTC | |
by graff (Chancellor) on Feb 18, 2008 at 22:09 UTC | |
by mercuryshipz (Acolyte) on Feb 18, 2008 at 22:31 UTC | |
by shmem (Chancellor) on Feb 18, 2008 at 21:55 UTC |