Node.JS for sysadmin scripting or non-web stuff - books, guides, examples?

2,972 views
Skip to first unread message

Victor Hooi

unread,
Nov 21, 2013, 8:23:59 PM11/21/13
to nod...@googlegroups.com
Hi,

I'm curious on people's experiences with using Node.JS for sys-admin scripts or non-Web glue stuff - i.e. the sorts of things you might use Perl or Python for (e.g. log parsing, manipulating config files etc.)

Is Node.JS suitable for these things?

Are there any books or guides out there on these sorts of things? (Most of the books I've seen are geared to Node.JS purely as a web app language).

Or any detailed examples people have posted up of what they use it for?

Cheers,
Victor

Tim Smart

unread,
Nov 21, 2013, 8:31:28 PM11/21/13
to nod...@googlegroups.com
Grunt.js is a great place to start: http://gruntjs.com/
> --
> --
> Job Board: http://jobs.nodejs.org/
> Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
> You received this message because you are subscribed to the Google
> Groups "nodejs" group.
> To post to this group, send email to nod...@googlegroups.com
> To unsubscribe from this group, send email to
> nodejs+un...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/nodejs?hl=en?hl=en
>
> ---
> You received this message because you are subscribed to the Google Groups "nodejs" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+un...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
signature.sig

Andre Contreras

unread,
Nov 21, 2013, 8:35:19 PM11/21/13
to nod...@googlegroups.com
I've used in my company to make a tiny web hosting panel, it is working very well.


2013/11/21 Tim Smart <t...@fostle.com>

// ravi

unread,
Nov 21, 2013, 11:39:48 PM11/21/13
to nod...@googlegroups.com
On Nov 21, 2013, at 8:23 PM, Victor Hooi <victo...@gmail.com> wrote:
>
> I'm curious on people's experiences with using Node.JS for sys-admin scripts or non-Web glue stuff - i.e. the sorts of things you might use Perl or Python for (e.g. log parsing, manipulating config files etc.)
>
> Is Node.JS suitable for these things?
>

Sure, JavaScript is a capable and feature-rich *high-level* language. NodeJS provides decent access to OS facilities, and NPM is a reliable source of additional functionality (even if it is no CPAN, or not yet CPAN). But I’d say, stepping strictly into personal opinion or preference territory, JavaScript (or Python for that matter) will never be as comfortable for sys-admin tasks as Perl. If having to carry the cognitive load of thorough-going async for inherently synchronous activities does not tax you, then the lack of Perl’s terse and intuitive (for a Unix-head) syntax for things like file test (-f, -l, etc), pipes (“|”), regular expressions, program execution (``), etc, might. Even if they do, it might be a small price to pay *if* the rest of your code is JavaScript/NodeJS.


> Are there any books or guides out there on these sorts of things? (Most of the books I've seen are geared to Node.JS purely as a web app language).
>
> Or any detailed examples people have posted up of what they use it for?


Sorry, I do not know of any.

—ravi


lith

unread,
Nov 22, 2013, 9:33:12 AM11/22/13
to nod...@googlegroups.com


I'm curious on people's experiences with using Node.JS for sys-admin scripts or non-Web glue stuff - i.e. the sorts of things you might use Perl or Python for (e.g. log parsing, manipulating config files etc.)

Is Node.JS suitable for these things?

The main hurdle is node's asynchronous paradigm that doesn't exactly lend itself to script logic. E.g. running external commands and reuse their output isn't as easy as it should be. Most of the time there are npm packages to make life easier (for the moment) but on the long run you'd better learn to write your scripts in an async manner -- if you want to take that road. So far, I like the async scripts I've written in node, which I would have otherwise written in ruby.

Matt

unread,
Nov 22, 2013, 9:53:38 AM11/22/13
to nod...@googlegroups.com

On Thu, Nov 21, 2013 at 11:39 PM, // ravi <ravi-...@g8o.net> wrote:
> Is Node.JS suitable for these things?
>

Sure, JavaScript is a capable and feature-rich *high-level* language. NodeJS provides decent access to OS facilities, and NPM is a reliable source of additional functionality (even if it is no CPAN, or not yet CPAN). But I’d say, stepping strictly into personal opinion or preference territory, JavaScript (or Python for that matter) will never be as comfortable for sys-admin tasks as Perl. If having to carry the cognitive load of thorough-going async for inherently synchronous activities does not tax you, then the lack of Perl’s terse and intuitive (for a Unix-head) syntax for things like file test (-f, -l, etc), pipes (“|”), regular expressions, program execution (``), etc, might. Even if they do, it might be a small price to pay *if* the rest of your code is JavaScript/NodeJS.

I absolutely 100% concur. I've written things that are very "sysadmin scripting" like in Node and realistically they would have been far neater in Perl. It's just better designed for that kind of thing.

Having said that, if you don't know Perl, the sigils ($/@/% in front of all the variables) and special variables will look really annoying.

Matt.

Mark Hahn

unread,
Nov 22, 2013, 1:45:23 PM11/22/13
to nodejs
running external commands and reuse their output isn't as easy as it should be. 

How hard is it to do exec rm -rf /

or if you are coffeescript-impaired ...

exec('rm -rf /');



Matt

unread,
Nov 22, 2013, 2:10:15 PM11/22/13
to nod...@googlegroups.com
On Fri, Nov 22, 2013 at 1:45 PM, Mark Hahn <ma...@reevuit.com> wrote:
How hard is it to do exec rm -rf /

or if you are coffeescript-impaired ...

exec('rm -rf /');

The problem is that's executed asynchronously, so you have to implement a callback to catch errors and output. This gets hairy fast when just writing a simple sysadmin script.

The node guys have promised us an execSync soon, but I'm not sure if it's showing up in 0.12 or not.

Matt.

// ravi

unread,
Nov 22, 2013, 9:02:31 PM11/22/13
to nod...@googlegroups.com
On Nov 22, 2013, at 9:53 AM, Matt <hel...@gmail.com> wrote:
>
> Having said that, if you don't know Perl, the sigils ($/@/% in front of all the variables) and special variables will look really annoying.
>

Especially once the dereferencing gets complicated.

—ravi

Peter Rust

unread,
Nov 23, 2013, 10:45:40 AM11/23/13
to nod...@googlegroups.com
I have to agree with ravi, lith & Matt. If you use node 24x7 for other things, then I guess it would make sense to use it for a few sysadmin scripts on the side, but it's not really the best fit.

Personally I've written a few sysadmin scripts in Python as well as Node and found Python to be better suited for the task -- Perl may be even better, but I haven't used it myself. If you're looking for a language that combines the convenience of synchronous programming with the performance of async, you might look at Go (goroutines use epoll/kqueue for IO operations so you get the same c10k performance as node).

Floby

unread,
Nov 24, 2013, 3:16:10 PM11/24/13
to nod...@googlegroups.com
You can have a look at the nodejitsu open-source stack of node tools
Reply all
Reply to author
Forward
0 new messages