`exec': string contains null byte (ArgumentError)
Your cmd
string has got a null (i.e. zero) byte in it somehow. Using puts
won’t show up any null bytes, they’ll just be left out of the output:
1.8.7 :001 > exec "\0"
ArgumentError: string contains null byte
from (irb):1:in `exec'
from (irb):1
1.8.7 :002 > puts "n\0n"
nn
=> nil
You should probably check how your rep
, svn_user
and pxs
variables are being populated to see if you can track down the source of these null bytes, but as a quick fix you could use gsub!
to remove them:
cmd.gsub!(/\0/, '')
ArgumentError: string contains null byte when writing Marshalled data into a file
The order of the file name and content argument is reversed. The first argument must be the name and the second one the content. The argument error is raised because file names shouldn't contain null bytes.
And since you're dealing with binary data, you should use IO.binwrite
:
File.binwrite "users.txt", Marshal.dump(users)
Can't run logstash. pathname contains null byte
it seems you have non-printing character in your config file.
check with cat -vET /usr/share/logstash/bin/logstash.conf
Write string with null characters to stdin of program
This is not a ruby-specific problem. Arguments on a nix system are passed as null-terminated strings (see exec(2)
for more details). That means null characters are the one type of characters arguments to any command can't have. You'll need to think of a way of passing the null-containing message in a different way than via arguments. (stdin would probably be the simplest alternative).
Related Topics
Setting Mime Type for .Ogv Files in Rails Development Environment
Documentation for Psych To_Yaml Options
Could Not Find Rake-10.0.4 in Any of the Sources (Bundler::Gemnotfound)
Instance Variable, Class Variable and the Difference Between Them in Ruby
Why Is Throw and Catch Hardly Ever Used in Ruby
Rails 4: How to Upload Files with Ajax
Calling a Sinatra App Instance Method from Testcase
How to Use Variables in a Yaml File
How to Sign_In for Devise to Test Controller with Minitest
Finding the Product of a Variable Number of Ruby Arrays
JSON::Parsererror: 757: Unexpected Token at '{
Ruby: Escaping Special Characters in a String
Serialize Array with Strong_Parameters
Use Windows or Linux to Start Work with Ruby on Rails
Convert Ruby Source Code from Old Style to New Style Hash
Regex to Validate String Having Only Characters (Not Special Characters), Blank Spaces and Numbers
Ruby - Extracting the Unique Values Per Key from an Array of Hashes