From: sin kanti Date: 2005-04-26T04:54:57+09:00 Subject: Re: escape special charactor i use $output = `command` because i want to puts $output later sinchai On 4/25/05, Joel VanderWerf wrote: > sin kanti wrote: > > Hi all, > > > > I write script to send password to unix shell. > > But i found out that if the password contain special charactor such as &, > > Shell will interpret it as background process. > > So, it have to use \& instead. > > > > Is there any function can detect special char? > > and return it is escape form? ( like \& ) > > > > i found similar function in Regexp.escape, but it can't detect & > > Are you using #system? If so, you can prevent the shell from expanding > things by passing each shell argument as a separate ruby argument: > > irb(main):001:0> system "echo foo&" > foo > => true > irb(main):002:0> system "echo", "foo&" > foo& > => true > >