to run most other scripts through a pipe, something similar to the following is usually enough:
cat script.sh | sh
cat perl.pl | perl -- "<arguments"
However, for javascript command line scripts, i cant seem to get this to work. Any ideas?
cat hull.js
#!/usr/bin/js
console.log("Hello, world!");
attempts to run it by piping:
root@gbrown-VirtualBox:~# cat hull.js | js
[stdin]:1
#!/usr/bin/js
^
SyntaxError: Unexpected token ILLEGAL
at Object.<anonymous> ([stdin]-wrapper:6:22)
at Module._compile (module.js:456:26)
at evalScript (node.js:532:25)
at Socket.<anonymous> (node.js:154:11)
at Socket.EventEmitter.emit (events.js:117:20)
at _stream_readable.js:920:16
at process._tickCallback (node.js:415:13)
root@gbrown-VirtualBox:~#
root@gbrown-VirtualBox:~#
root@gbrown-VirtualBox:~# cat hull.js | node
[stdin]:1
#!/usr/bin/js
^
SyntaxError: Unexpected token ILLEGAL
at Object.<anonymous> ([stdin]-wrapper:6:22)
at Module._compile (module.js:456:26)
at evalScript (node.js:532:25)
at Socket.<anonymous> (node.js:154:11)
at Socket.EventEmitter.emit (events.js:117:20)
at _stream_readable.js:920:16
at process._tickCallback (node.js:415:13)
root@gbrown-VirtualBox:~#
root@gbrown-VirtualBox:~#
root@gbrown-VirtualBox:~# cat hull.js | nodejs
[stdin]:1
#!/usr/bin/js
^
SyntaxError: Unexpected token ILLEGAL
at Object.<anonymous> ([stdin]-wrapper:6:22)
at Module._compile (module.js:456:26)
at evalScript (node.js:532:25)
at Socket.<anonymous> (node.js:154:11)
at Socket.EventEmitter.emit (events.js:117:20)
at _stream_readable.js:920:16
at process._tickCallback (node.js:415:13)
root@gbrown-VirtualBox:~#
root@gbrown-VirtualBox:~#
root@gbrown-VirtualBox:~# cat hull.js | nodejs --
[stdin]:1
#!/usr/bin/js
^
SyntaxError: Unexpected token ILLEGAL
at Object.<anonymous> ([stdin]-wrapper:6:22)
at Module._compile (module.js:456:26)
at evalScript (node.js:532:25)
at Socket.<anonymous> (node.js:154:11)
at Socket.EventEmitter.emit (events.js:117:20)
at _stream_readable.js:920:16
at process._tickCallback (node.js:415:13)
root@gbrown-VirtualBox:~#
root@gbrown-VirtualBox:~# cat hull.js | node --
[stdin]:1
#!/usr/bin/js
^
SyntaxError: Unexpected token ILLEGAL
at Object.<anonymous> ([stdin]-wrapper:6:22)
at Module._compile (module.js:456:26)
at evalScript (node.js:532:25)
at Socket.<anonymous> (node.js:154:11)
at Socket.EventEmitter.emit (events.js:117:20)
at _stream_readable.js:920:16
at process._tickCallback (node.js:415:13)
root@gbrown-VirtualBox:~#
root@gbrown-VirtualBox:~#
root@gbrown-VirtualBox:~# cat hull.js | js -
Error: unrecognized flag -
Try --help for options
[stdin]:1
#!/usr/bin/js
^
SyntaxError: Unexpected token ILLEGAL
at Object.<anonymous> ([stdin]-wrapper:6:22)
at Module._compile (module.js:456:26)
at evalScript (node.js:532:25)
at Socket.<anonymous> (node.js:154:11)
at Socket.EventEmitter.emit (events.js:117:20)
at _stream_readable.js:920:16
at process._tickCallback (node.js:415:13)
root@gbrown-VirtualBox:~#