CoffeeScript - Run a bash script with arguments

I am playing with the GitHub Hubot and I am trying to run a bash script inside my robotic work.
I managed to execute my script, but I can not get it to work if I add some arguments to this script.

{ spawn } = require 'child_process'
s = spawn './myScript.sh' + " url" + " title"     <------- doesn't work due to args
s = spawn './myScript.sh'                         <------- alright without args
s.stdout.on 'data', ( data ) -> console.log "Output: #{ data }"
s.stderr.on 'data', ( data ) -> console.error "Error: #{ data }"
s.on 'close', -> console.log "'s' has finished executing."

How to pass arguments to my script?
thanks for the help

+3
source share
1 answer

As described in the documentation:

http://nodejs.org/api/child_process.html#child_process_child_process_spawn_command_args_options

Arise as the second parameter, an array made of your various arguments. It will look like this:

s = spawn './myScript.sh', [url, title]
+7
source

All Articles