D
Doan, Alex
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 =3D "\"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 =3D "\"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 =3D "\"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 =3D "\"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=3D32 time<1ms TTL=3D38
Reply from 114.19.9.181: bytes=3D32 time=3D1ms TTL=3D38
Reply from 114.19.9.181: bytes=3D32 time<1ms TTL=3D38
Reply from 114.19.9.181: bytes=3D32 time<1ms TTL=3D38
Ping statistics for 114.19.9.181:
Packets: Sent =3D 4, Received =3D 4, Lost =3D 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum =3D 0ms, Maximum =3D 1ms, Average =3D 0ms
------------------------------------------------------------------------
Without the third/fourth escaped quote:
a =3D "\"C:/WINDOWS/system32/ping.exe\" BFI3CHL671 >> out.txt "
system(a)
ouput:
out.txt contain the appropriate lines
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 =3D "\"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 =3D "\"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 =3D "\"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 =3D "\"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=3D32 time<1ms TTL=3D38
Reply from 114.19.9.181: bytes=3D32 time=3D1ms TTL=3D38
Reply from 114.19.9.181: bytes=3D32 time<1ms TTL=3D38
Reply from 114.19.9.181: bytes=3D32 time<1ms TTL=3D38
Ping statistics for 114.19.9.181:
Packets: Sent =3D 4, Received =3D 4, Lost =3D 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum =3D 0ms, Maximum =3D 1ms, Average =3D 0ms
------------------------------------------------------------------------
Without the third/fourth escaped quote:
a =3D "\"C:/WINDOWS/system32/ping.exe\" BFI3CHL671 >> out.txt "
system(a)
ouput:
out.txt contain the appropriate lines