I’m using system call and pipping the output to a log. Something funny
happen when I have more then two escaped quotes and ‘>>’ in my call. Can
someone shed some light on the issue:
Case:
command_to_execute = ““c:/program files/cvs.exe” -q export -r HEAD -d
TEST “1sks/src folder” >> output.log”
system( command_to_execute )
This call will error out stating that c:/program is not recognized. Now
if I remove the >>, the command work fine. Or if I replace the module
(“1sks/src folder”) to a module that doesn’t require the quote like:
command_to_execute = ““c:/program file/cvs.exe” -q export -r HEAD -d
TEST 1sks/build >> ouput.log”
Then system work fine.
Below are some test with pinging cmd, save to file call test.rb.
Test Case:
Tried it on the ping command with quoting and >, gave me the same issue.
(I dont need the quote with ping, but they are there to represent issue
where I would need the escape quote and the system command is giving me
issue.)
a = "“C:/WINDOWS/system32/ping.exe” “BFI3CHL671” >> out.txt "
system(a)
output:
‘C:/WINDOWS/system32/ping.exe" "BFI3CHL671’ is not recognized as an
internal or external command,
operable program or batch file.
Without the >:
a = "“C:/WINDOWS/system32/ping.exe” “BFI3CHL671"”
system(a)
output:
Pinging BFI3CHL671 [114.19.9.181] with 32 bytes of data:
Reply from 114.19.9.181: bytes=32 time<1ms TTL=38
Reply from 114.19.9.181: bytes=32 time=1ms TTL=38
Reply from 114.19.9.181: bytes=32 time<1ms TTL=38
Reply from 114.19.9.181: bytes=32 time<1ms TTL=38
Ping statistics for 114.19.9.181:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 0ms, Maximum = 1ms, Average = 0ms
Without the third/fourth escaped quote:
a = "“C:/WINDOWS/system32/ping.exe” BFI3CHL671 >> out.txt "
system(a)
ouput:
out.txt contain the appropriate lines