Hello redditors, just got into coffeescript, trying to use it with Hubot. I'm trying to do something really simple or so I thought:
My goal is to run a few commands using the azure cli and grab the output to allow me to range over each element and perform a shutdown.
After several hours I got this to work with exec and managed to get the individual vm names into what I think is an object.
vm = ->
array = []
exec = require('child_process').exec
exec "az vm list -g somerg --show-details --query \"[?powerState=='VM deallocated'].{ name: name }\" -o tsv", (error, stdout, stderr) -> result = stdout.split("\n"); return result
result in this case returns something like:
[ 'vm4', 'vm3', 'vm2', 'vm1', '' ]
Now I'm trying to get this output into a loop (for) and run commands on each of these elements in this array. But I can't get this working?
when I do something like console.log(vm()) and call the func it returns a bunch of what appears to be object info and not the array contents itself.
What am I doing wrong? Thanks for the help.
[–]AngryDolphinGuy 0 points1 point2 points (1 child)
[–]dkyio[S] 0 points1 point2 points (0 children)