Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re^3: back tick to do ssh

by kirillm (Friar)
on Dec 31, 2007 at 00:47 UTC ( [id://659678]=note: print w/replies, xml ) Need Help??


in reply to Re^2: back tick to do ssh
in thread back tick to do ssh

Hi convenientstore,

Enclose the command you want to be executed on the remote host in quotes, like this:

my $result = `ssh host1 'echo something | /bin/others'`;

This way echo something | /bin/others will be run on host1 and the result will end up in $result.

Replies are listed 'Best First'.
Re^4: back tick to do ssh
by graff (Chancellor) on Dec 31, 2007 at 01:02 UTC
    That sort of solution would be okay for toy examples and really simple cases, but as soon as you get to situations involving real work, the constraints of quoting and escaping things for shell command operations can get really hairy and unworkable. It's the proverbial road to hell, paved with good intentions.

      Sure it is! ;-) Putting everything in a shell script on the remote server and running that script, rather than juggling with quotes, escapes and pipes is easier, safer and gives more predictable results...

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://659678]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (2)
As of 2024-04-26 04:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found