smarx / waz-cmd

Ruby-based command-line tool for the Windows Azure Service Management API
Microsoft Public License
11 stars 3 forks source link

Bad URI issue #4

Open ffjia opened 12 years ago

ffjia commented 12 years ago

Hi smarx,

I'd like to restart all apps with waz reboot, but when I run this with for loop, error pop up:

d=waz list applications | grep "^Production"

$ for i in ${d[@]}; do echo $i; done Production-ap-hongkong-a-1 Production-ap-hongkong-b-2 Production-ap-hongkong-c-3

$ for i in ${d[@]}; do echo $i; waz -t reboot instance "$i" production VMRole1_IN_0; sleep 30; done Production-ap-hongkong-a-1 /Users/ffjia/.rvm/rubies/ruby-1.8.7-p358/lib/ruby/1.8/uri/common.rb:436:in split': bad URI(is not URI?): https://management.core.windows.net/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/services/hostedservices/Production-ap-hongkong-/deploymentslots/production/roleinstances/VMRole1_IN_0?comp=reboot (URI::InvalidURIError) from /Users/ffjia/.rvm/rubies/ruby-1.8.7-p358/lib/ruby/1.8/uri/common.rb:485:inparse' from /Users/ffjia/.rvm/gems/ruby-1.8.7-p358/gems/rest-client-1.6.3/lib/restclient/request.rb:114:in parse_url' from /Users/ffjia/.rvm/gems/ruby-1.8.7-p358/gems/rest-client-1.6.3/lib/restclient/request.rb:118:inparse_url_with_auth' from /Users/ffjia/.rvm/gems/ruby-1.8.7-p358/gems/rest-client-1.6.3/lib/restclient/request.rb:63:in execute' from /Users/ffjia/.rvm/gems/ruby-1.8.7-p358/gems/rest-client-1.6.3/lib/restclient/request.rb:33:inexecute' from /Users/ffjia/.rvm/gems/ruby-1.8.7-p358/gems/waz-cmd-0.4.2/lib/waz-cmd.rb:45:in make_call' from /Users/ffjia/.rvm/gems/ruby-1.8.7-p358/gems/waz-cmd-0.4.2/lib/waz-cmd.rb:67:inrestar_instance' from /Users/ffjia/.rvm/gems/ruby-1.8.7-p358/gems/commander-4.0.4/lib/commander/command.rb:180:in call' from /Users/ffjia/.rvm/gems/ruby-1.8.7-p358/gems/commander-4.0.4/lib/commander/command.rb:180:incall' from /Users/ffjia/.rvm/gems/ruby-1.8.7-p358/gems/commander-4.0.4/lib/commander/command.rb:155:in run' from /Users/ffjia/.rvm/gems/ruby-1.8.7-p358/gems/commander-4.0.4/lib/commander/runner.rb:387:inrun_active_command' from /Users/ffjia/.rvm/gems/ruby-1.8.7-p358/gems/commander-4.0.4/lib/commander/runner.rb:74:in run!' from /Users/ffjia/.rvm/gems/ruby-1.8.7-p358/gems/commander-4.0.4/lib/commander/delegates.rb:7:inrun!' from /Users/ffjia/.rvm/gems/ruby-1.8.7-p358/gems/commander-4.0.4/lib/commander/import.rb:10 from /Users/ffjia/.rvm/gems/ruby-1.8.7-p358/bin/waz:19

But I can run it with a single command:

$ waz -t reboot instance Production-ap-hongkong-a-1 production VMRole1_IN_0 Waiting for operation to complete... Operation succeeded (200)

Could you give some hints about this? Thanks.

smarx commented 12 years ago

Just a guess, but I wonder if it's the double quotes around $i? Have you tried it without them?

On Tue, May 29, 2012 at 8:35 PM, Feifei Jia < reply@reply.github.com

wrote:

Hi smarx,

I'd like to restart all apps with waz reboot, but when I run this with for loop, error pop up:

d=waz list applications | grep "^Production"

$ for i in ${d[@]}; do echo $i; done Production-ap-hongkong-a-1 Production-ap-hongkong-b-2 Production-ap-hongkong-c-3

$ for i in ${d[@]}; do echo $i; waz -t reboot instance "$i" production VMRole1_IN_0; sleep 30; done Production-ap-hongkong-a-1 /Users/ffjia/.rvm/rubies/ruby-1.8.7-p358/lib/ruby/1.8/uri/common.rb:436:in split': bad URI(is not URI?): https://management.core.windows.net/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/services/hostedservices/Production-ap-hongkong-/deploymentslots/production/roleinstances/VMRole1_IN_0?comp=reboot(URI::InvalidURIError) from /Users/ffjia/.rvm/rubies/ruby-1.8.7-p358/lib/ruby/1.8/uri/common.rb:485:in parse' from /Users/ffjia/.rvm/gems/ruby-1.8.7-p358/gems/rest-client-1.6.3/lib/restclient/request.rb:114:in parse_url' from /Users/ffjia/.rvm/gems/ruby-1.8.7-p358/gems/rest-client-1.6.3/lib/restclient/request.rb:118:in parse_url_with_auth' from /Users/ffjia/.rvm/gems/ruby-1.8.7-p358/gems/rest-client-1.6.3/lib/restclient/request.rb:63:in execute' from /Users/ffjia/.rvm/gems/ruby-1.8.7-p358/gems/rest-client-1.6.3/lib/restclient/request.rb:33:in execute' from /Users/ffjia/.rvm/gems/ruby-1.8.7-p358/gems/waz-cmd-0.4.2/lib/waz-cmd.rb:45:in make_call' from /Users/ffjia/.rvm/gems/ruby-1.8.7-p358/gems/waz-cmd-0.4.2/lib/waz-cmd.rb:67:in restar_instance' from /Users/ffjia/.rvm/gems/ruby-1.8.7-p358/gems/commander-4.0.4/lib/commander/command.rb:180:in call' from /Users/ffjia/.rvm/gems/ruby-1.8.7-p358/gems/commander-4.0.4/lib/commander/command.rb:180:in call' from /Users/ffjia/.rvm/gems/ruby-1.8.7-p358/gems/commander-4.0.4/lib/commander/command.rb:155:in run' from /Users/ffjia/.rvm/gems/ruby-1.8.7-p358/gems/commander-4.0.4/lib/commander/runner.rb:387:in run_active_command' from /Users/ffjia/.rvm/gems/ruby-1.8.7-p358/gems/commander-4.0.4/lib/commander/runner.rb:74:in run!' from /Users/ffjia/.rvm/gems/ruby-1.8.7-p358/gems/commander-4.0.4/lib/commander/delegates.rb:7:in run!' from /Users/ffjia/.rvm/gems/ruby-1.8.7-p358/gems/commander-4.0.4/lib/commander/import.rb:10 from /Users/ffjia/.rvm/gems/ruby-1.8.7-p358/bin/waz:19

But I can run it with a single command:

$ waz -t reboot instance Production-ap-hongkong-a-1 production VMRole1_IN_0 Waiting for operation to complete... Operation succeeded (200)

Could you give some hints about this? Thanks.


Reply to this email directly or view it on GitHub: https://github.com/smarx/waz-cmd/issues/4

ffjia commented 12 years ago

I've tried that, but with the same error...

smarx commented 12 years ago

Okay, my next guess is that it's some hidden formatting. Try piping through "col -b", like "waz list applications | col -b". I believe this will solve your problem.

No, I don't know why there would be hidden formatting there, but it looks like there is (based on doing "echo x${i}x" and observing that the last character didn't get printed).

On Tue, May 29, 2012 at 9:44 PM, Feifei Jia < reply@reply.github.com

wrote:

I've tried that, but with the same error...


Reply to this email directly or view it on GitHub: https://github.com/smarx/waz-cmd/issues/4#issuecomment-6002087

ffjia commented 12 years ago

Thanks Steve, yes, "col -b" solved the problem.

Is it possible that the the "puts Tilt.new(template('list_applications.erb'), 1, :trim => '%').render(nil, :apps => apps) " in "list applications" print those hidden char out?

smarx commented 12 years ago

Well, that's the line of code that causes the output, and the output has those characters, so I'd say yes. :-)

But I have no idea why (and I suspect it's deeper in the templates). If you figure it out, I'd be happy to accept a patch.

On Tue, May 29, 2012 at 10:26 PM, Feifei Jia < reply@reply.github.com

wrote:

Thanks Steve, yes, "col -b" solved the problem.

Is it possible that the the "puts Tilt.new(template('list_applications.erb'), 1, :trim => '%').render(nil, :apps => apps) " in "list applications" print those hidden char out?


Reply to this email directly or view it on GitHub: https://github.com/smarx/waz-cmd/issues/4#issuecomment-6002484

ffjia commented 12 years ago

I'd like to, if I can figure out the reason, :)