Skip to content
Advertisement

How to execute command line via input

I’ve read this and this, but didn’t make it work.

Here’s my script:

JavaScript

and it output things like:

JavaScript

Now I’d juste like to execute it in the same line, but xargs makes all incoming into one line of arguments (and it doesn’t run it). xargs -0 doesn’t work either. And I’d like to run it using env -i to run it in an environment without variables, and to set temporarily my env variables (= like I did at the very first command), something like (which doesn’t work):

JavaScript

Advertisement

Answer

Does this work:

JavaScript

The while loop will read each whole line from the output, and just execute it.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement