From: Luis Lavena Date: 2010-09-29T07:45:51+09:00 Subject: Re: passing single backslash character as commang line argument On Sep 27, 2:40 pm, Kashyap Ivaturi wrote: > Hi, > > I am trying to pass a string as a command line argument to another ruby > program and I am not able to send a single backslash character as part > of that string. > > Example: > test1.rb: > test2AbsolutePath = "C:\\test2.rb" > text = "Sample Ruby '\\' String" > system("ruby #{test2AbsolutePath} \"#{text}\"") > > test2.rb: > text  = ARGV[0] > puts "text: #{text}" > > Output : > C:\>ruby test1.rb > text: Sample Ruby '' String > > Please let me know how to get the backslash character in the string in > the test2.rb program. > Please include which version of Ruby are you using. Ruby 1.8.x versus 1.9.1, specially 1.9.2, differ in how commands are processed by Kernel.system Also, pretty much all the modern tools and command line applications can parse file paths with backslashes as normally as forward slashes. If what are you trying to achieve is feed backslashes into evaluate (ruby -e) then you need to use double quotes and escape inner double quotes inside: ruby -ve "puts \"hello\"" -- Luis Lavena