How to remote control the 'meteor shell' from bash?

Hi Meteorites,

May be our topic is more an edge use case.
But I would really like to unterstand, whats going on here…

Disclaimer: We know: using meteor CLI in production is not a good idea. Nevertheless we have an internal “staging server” were things like automatic builds and hot code push are great. :wink: That said: We are using “meteor shell” to make some collection changes now and then in this staging server. To enter these statements inside the interactive REPL mode is cumbersome…

So we thought it might be possible, to let the shell pipe some JS commands into ‘meteor shell’.

In interactive mode of “meteor shell” this all works as expected in all examples below:

> console.log('ABC')
> console.log('ABC'); console.log('XYZ')
> import {BroadcastMessage} from '/imports/broadcastmessage'
> BroadcastMessage.show('Hello world')

Now we want to achieve the same from the (bash) shell. But here comes the funny stuff:

echo "console.log('ABC')" | meteor shell
=> OK. Puts out "ABC" on the server log of the running app

echo "console.log('ABC'); console.log('XYZ')" | meteor shell
=> SyntaxError: Unexpected token, expected , (1:19)

Huh? OK - we have to insert a comma instead of a semikolon? Funny.

echo "console.log('ABC'), console.log('XYZ')" | meteor shell
=> Great! Works! Puts out ABC and then XYZ on the server log

Anybody an idea where the “comma” syntax comes from? Frm bash or from JS or from meteor shell?

NEvertheless we were not able to get an import statement trough…

echo "import {BroadcastMessage} from '/imports/broadcastmessage'" | meteor shell
=> SyntaxError: Unexpected token (1:1)

While the same import works perfectly when entered in interactive REPL mode…

Anybody an idea whats going on here?

Thanks in advance…

Wolfram.

Hi @derwok, I found the cause of the comma syntax mystery

Please take a look to https://github.com/meteor/meteor/issues/8823