Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re^2: Splitting up quoted/escaped command line arguments

by Tommy (Chaplain)
on Feb 11, 2014 at 18:23 UTC ( #1074463=note: print w/ replies, xml ) Need Help??


in reply to Re: Splitting up quoted/escaped command line arguments
in thread Splitting up quoted/escaped command line arguments

...Because that sends it through a shell. I need to avoid that.

Tommy
A mistake can be valuable or costly, depending on how faithfully you pursue correction


Comment on Re^2: Splitting up quoted/escaped command line arguments
Re^3: Splitting up quoted/escaped command line arguments
by salva (Monsignor) on Feb 11, 2014 at 18:30 UTC
    But hose commands would not work unless you pass them through a shell!

    Or if you prefer to view it from a different angle, you will have to implement in your program all the shell functionality used by those commands!

    Update: And BTW, if those commands involve calling ssh, then a shell would be invoked at the remote side. This is an unavoidable feature of the SSH protocol.

      Yes, I'm keenly aware that a shell is going to be invoked on the remote side. That's fine. I need to avoid it on the local machine. Why do you say that these commands won't work unless passed to a shell vs calling ssh directly? The perldocs don't seem to agree with your assertion.

       

      Tommy
      A mistake can be valuable or costly, depending on how faithfully you pursue correction
        Why do you say that these commands won't work unless passed to a shell vs calling ssh directly?

        Because it's obvious they have been written to be parsed by a shell.

        Can you assure that there would be no entries using redirections, pipes, back-quotes, logical operators, variables, wildcards, etc.? Those are features that any intermediate shell user employs frequently.

Re^3: Splitting up quoted/escaped command line arguments
by runrig (Abbot) on Feb 11, 2014 at 19:02 UTC
    I need to avoid that.
    Why?

      I'll potentially be doing hundreds of these calls in parallel and I have to avoid the overhead of shelling out every time. I've already tested and the difference is very significant when opening to ssh vs opening to a shell opening to ssh. There's a huge slowdown on the local machine when I involve the shell.

      Tommy
      A mistake can be valuable or costly, depending on how faithfully you pursue correction
        Store the string in the database with some token that you can split on, that won't show up in the command itself. But, the "||" in your example is a shell operation, it won't work in 'exec @args'. Ignore that last part...I see it's part of the remote command passed to ssh.

        Update: Isn't the command just one arg then that's passed to ssh?

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (11)
As of 2014-08-22 12:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (156 votes), past polls