From: Dale Martenson Date: 2006-07-29T00:44:44+09:00 Subject: Double quotes embedded in a string ... Here is something that I am struggling with -- I would like to execute a command string with an IO.popen call that contains embedded double quote characters. When I build the initial command string everything seems to work, but once I pass is on to IO.popen, it seems to mess up the double quotes. Here is my example, I want to execute the following command from a Ruby program: pppd connect "chat -v '' ATZ OK ATDT5551234 CONNECT '' ogin: username word: password" /dev/ttyS0 115200 -detach crtscts modem defaultroute I create the command string by the long and somewhat ugly ruby command: command = "pppd connect \\\"chat -v '' #{initialization_command} #{initialization_response} #{dial_command} #{dial_response} '' #{username_prompt} #{username} #{password_prompt} #{password}\\\" #{device.name} #{speed} -detach crtscts modem defaultroute\r\n" In this case, I escaped the escaped the double quote. I have also tried various combinations of multiple double quotes (4 in a row, etc.). If I now echo the command using a system call: system( "echo #{command}" ) the command seems to echo the desired result: pppd connect "chat -v ATZ OK ATD5551234 CONNECT ogin: username word: password" /dev/ttyS0 115200 -detach crtscts modem defaultroute But when I pass it to IO.popen, I get pppd: unrecognized option '-v' pppd version 2.4.1 Usage: pppd [ options ], where options are: Communicate over the named device Set the baud rate to : Set the local and/or remote interface IP addresses. Either one may be omitted. asyncmap Set the desired async map to hex auth Require authentication from peer connect

Invoke shell command

to set up the serial line crtscts Use hardware RTS/CTS flow control defaultroute Add default route through interface file Take options from file modem Use modem control lines mru Set MRU value to for negotiation See pppd(8) for more options. which is caused by that the double quotes are being stripped by IO.popen. How do I avoid this? Thanks, Dale Martenson -- Posted with http://DevLists.com. Sign up and save your mailbox.