How can i directly run the contents of the clipboard, I tried using the command python pbpaste
but it said python: can't open file 'pbpaste': [Errno 2] No such file or directory does the code have to be contained in a file to run it?
Asked
Active
Viewed 307 times
0

Paulo Almeida
- 7,803
- 28
- 36

kyle k
- 5,134
- 10
- 31
- 45
1 Answers
3
Since pbpaste
produces its output on the standard output and Python can take its input from the standard input, you can simply pipe them:
pbpaste | python

Matteo Italia
- 123,740
- 17
- 206
- 299
-
That is what i am looking for. Thanks, but why won't it work for **gcc** i tried this command `pbpaste | gcc` but it gave me this error **i686-apple-darwin11-llvm-gcc-4.2: no input files** my clipboard contains a simple hello world program. – kyle k Aug 25 '13 at 02:23
-
`gcc` is a different beast, AFAIK it doesn't accept its input from stdin. You could create a temporary file instead (you can e.g. use `mktemp` for that purpose). – Matteo Italia Aug 25 '13 at 02:24
-
1@kylek, Apparently [gcc can accept input from stdin if you specify the language](http://stackoverflow.com/questions/1003644/is-it-possible-to-get-gcc-to-read-from-a-pipe). – Paulo Almeida Aug 25 '13 at 02:48