9

From command line, I'd like to take a script from my paste board (FYI: pbpaste is an OSX feature) and pipe it into the Node's repl command line tool. For example:

pbpaste | node -e

This does not evaluate the contents in my clipboard. How do I get the runtime to do this?

1
  • 1
    It should just work without the -e, I think. Commented Jan 16, 2013 at 7:21

2 Answers 2

13

The -e option is for running JS passed as an argument. To run JS from stdin, you can simply pipe to node directly.

pbpaste | node
Sign up to request clarification or add additional context in comments.

2 Comments

I can't get this to work for piping a downloaded script to node. (i.e. "curl -L https://<myscipt> | node")
@ColeChamberlain Please post a new question.
4

This seems to do the trick:

node -e "$(pbpaste)"

1 Comment

node -e "process.stdout.write('hi');"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.