You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
conn = WinRM::Connection.new(opts)
conn.shell(:cmd) do |shell|
output = shell.run("dir") do |stdout, stderr|
p "stdout: #{stdout}"
p "stderr: #{stderr}"
end
puts "The script exited with exit code #{output.exitcode}"
end
-- 1.rb ----------------->8-----------------
running this gives and error:
----------------- execute and error ----------------------
#> bundle exec ruby 1.rb
/Users/user/dddd/bundles/ruby/2.2.0/gems/rubyntlm-0.6.2/lib/net/ntlm.rb:164:in upcase': invalid byte sequence in UTF-8 (ArgumentError) from /Users/user/dddd/bundles/ruby/2.2.0/gems/rubyntlm-0.6.2/lib/net/ntlm.rb:164:in ntlmv2_hash'
from /Users/user/dddd/bundles/ruby/2.2.0/gems/rubyntlm-0.6.2/lib/net/ntlm/client/session.rb:192:in ntlmv2_hash' from /Users/user/dddd/bundles/ruby/2.2.0/gems/rubyntlm-0.6.2/lib/net/ntlm/client/session.rb:196:in calculate_user_session_key!'
from /Users/user/dddd/bundles/ruby/2.2.0/gems/rubyntlm-0.6.2/lib/net/ntlm/client/session.rb:27:in authenticate!' from /Users/user/dddd/bundles/ruby/2.2.0/gems/rubyntlm-0.6.2/lib/net/ntlm/client.rb:36:in init_context'
from /Users/user/dddd/bundles/ruby/2.2.0/gems/winrm-2.2.3/lib/winrm/http/transport.rb:229:in init_auth' from /Users/user/dddd/bundles/ruby/2.2.0/gems/winrm-2.2.3/lib/winrm/http/transport.rb:168:in send_request'
from /Users/user/dddd/bundles/ruby/2.2.0/gems/winrm-2.2.3/lib/winrm/shells/cmd.rb:56:in open_shell' from /Users/user/dddd/bundles/ruby/2.2.0/gems/winrm-2.2.3/lib/winrm/shells/base.rb:168:in block in open'
from /Users/user/dddd/bundles/ruby/2.2.0/gems/winrm-2.2.3/lib/winrm/shells/retryable.rb:37:in retryable' from /Users/user/dddd/bundles/ruby/2.2.0/gems/winrm-2.2.3/lib/winrm/shells/base.rb:166:in open'
from /Users/user/dddd/bundles/ruby/2.2.0/gems/winrm-2.2.3/lib/winrm/shells/base.rb:129:in with_command_shell' from /Users/user/dddd/bundles/ruby/2.2.0/gems/winrm-2.2.3/lib/winrm/shells/base.rb:81:in run'
from 1.rb:20:in block in <main>' from /Users/user/dddd/bundles/ruby/2.2.0/gems/winrm-2.2.3/lib/winrm/connection.rb:44:in shell'
from 1.rb:19:in `
'
----------------- execute and error ----------------------
any idea ?
The text was updated successfully, but these errors were encountered:
I'm encountering something that I think is similar. When I send and echo µsomemessage - where µ is a valid character in both UTF-8 and Windows-1252 (my target system's encoding) - I get 'invalid byte sequence' when run from Windows (but behaves okay from macOS/Linux). In particular
sent from Windows, I get back the Windows-1252 encoding of µ but Ruby thinks it's a UTF-8 string. Under some scenarios where I use the string, I get 'invalid byte sequence' because the Windows-1252 byte sequence of µ isn't a valid UTF-8 byte sequence.
sent from macOS or Linux, I get back the UTF-8 encoding and the string is expected to be UTF-8. No errors encountered here.
Update: this seems to specifically affect Ruby 2.3 on Windows. Seems fixed under Ruby 2.4.
hi
using below script throws an error. trying it with username 'user' and it works.
-- 1.rb -----------8<---------------
require 'winrm'
user = "サザ"
pass = 'secret'
end = '1.2.3.4'
opts = {
endpoint: "http://#{end}/wsman",
user: user,
password: pass,
overall_timeout: 5,
retry_limit: 1,
retry_delay: 1
}
conn = WinRM::Connection.new(opts)
conn.shell(:cmd) do |shell|
output = shell.run("dir") do |stdout, stderr|
p "stdout: #{stdout}"
p "stderr: #{stderr}"
end
puts "The script exited with exit code #{output.exitcode}"
end
-- 1.rb ----------------->8-----------------
running this gives and error:
'----------------- execute and error ----------------------
#> bundle exec ruby 1.rb
/Users/user/dddd/bundles/ruby/2.2.0/gems/rubyntlm-0.6.2/lib/net/ntlm.rb:164:in
upcase': invalid byte sequence in UTF-8 (ArgumentError) from /Users/user/dddd/bundles/ruby/2.2.0/gems/rubyntlm-0.6.2/lib/net/ntlm.rb:164:in
ntlmv2_hash'from /Users/user/dddd/bundles/ruby/2.2.0/gems/rubyntlm-0.6.2/lib/net/ntlm/client/session.rb:192:in
ntlmv2_hash' from /Users/user/dddd/bundles/ruby/2.2.0/gems/rubyntlm-0.6.2/lib/net/ntlm/client/session.rb:196:in
calculate_user_session_key!'from /Users/user/dddd/bundles/ruby/2.2.0/gems/rubyntlm-0.6.2/lib/net/ntlm/client/session.rb:27:in
authenticate!' from /Users/user/dddd/bundles/ruby/2.2.0/gems/rubyntlm-0.6.2/lib/net/ntlm/client.rb:36:in
init_context'from /Users/user/dddd/bundles/ruby/2.2.0/gems/winrm-2.2.3/lib/winrm/http/transport.rb:229:in
init_auth' from /Users/user/dddd/bundles/ruby/2.2.0/gems/winrm-2.2.3/lib/winrm/http/transport.rb:168:in
send_request'from /Users/user/dddd/bundles/ruby/2.2.0/gems/winrm-2.2.3/lib/winrm/shells/cmd.rb:56:in
open_shell' from /Users/user/dddd/bundles/ruby/2.2.0/gems/winrm-2.2.3/lib/winrm/shells/base.rb:168:in
block in open'from /Users/user/dddd/bundles/ruby/2.2.0/gems/winrm-2.2.3/lib/winrm/shells/retryable.rb:37:in
retryable' from /Users/user/dddd/bundles/ruby/2.2.0/gems/winrm-2.2.3/lib/winrm/shells/base.rb:166:in
open'from /Users/user/dddd/bundles/ruby/2.2.0/gems/winrm-2.2.3/lib/winrm/shells/base.rb:129:in
with_command_shell' from /Users/user/dddd/bundles/ruby/2.2.0/gems/winrm-2.2.3/lib/winrm/shells/base.rb:81:in
run'from 1.rb:20:in
block in <main>' from /Users/user/dddd/bundles/ruby/2.2.0/gems/winrm-2.2.3/lib/winrm/connection.rb:44:in
shell'from 1.rb:19:in `
----------------- execute and error ----------------------
any idea ?
The text was updated successfully, but these errors were encountered: