[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Help with system() call and pipe

Doan, Alex

7/11/2007 9:25:00 PM

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



7 Answers

Richard Lawrence

7/11/2007 11:05:00 PM

0

Doan, Alex wrote:
> 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.

Isn't this because you need to escape the space, too? so that
command_to_execute = "\"c:/program\ files/cvs.exe\" ..."

> Now if I remove the >>, the command work fine.
To me, that's the weird thing here...

Mariusz Pekala

7/12/2007 12:00:00 PM

0

On 2007-07-12 08:15:04 +0900 (Thu, Jul), Richard Lawrence wrote:
> Doan, Alex wrote:
> >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.
>
> Isn't this because you need to escape the space, too? so that
> command_to_execute = "\"c:/program\ files/cvs.exe\" ..."
>
> >Now if I remove the >>, the command work fine.
> To me, that's the weird thing here...
>

Isn't it better to use the system() with multiple parameters in this
case?
as in: system('c:/program files/cvs.exe', '-q','export', ... )

Then you don't need to escape the special characters. I am not sure
whether this works on Windows.
I know, it might not allow redirecting ('>> output.log'), but I recall
DOS did not handle the redirections for the programs and the programs
themselves had to.

Maybe popen() would be acceptable solution?

--
No virus found in this outgoing message.
Checked by 'grep -i virus $MESSAGE'
Trust me.

Michael Black

9/3/2012 11:58:00 PM

0

Rob Jensen

9/4/2012 12:11:00 AM

0

On Mon, 03 Sep 2012 15:44:39 -0700, "Ian J. Ball"
<ijball-NO_SPAM@mac.invalid> wrote:

>In article
><bb915cda-cd19-46aa-b7fa-47eb4d478e7c@v15g2000yqi.googlegroups.com>,
> Tom <drsoong@aol.com> wrote:
>
>> R.I.P.
>>
>> http://www.latimes.com/news/obituaries/la-michael-clarke-duncan-dead...
>> 26494.story
>>
>> Tom
>
>Sucky news - I was hoping he'd get his own series after "The Finder"
>tanked. :(

I liked The Finder a LOT. I will say, however, in this context only,
that it's a good thing that The Finder was cancelled because had it
been renewed like it should have been -- while it was on the bubble,
it had had a decent shot at renewal until Fox remembered its man-crush
on Keifer Sutherland and inexplicably renewed Touch -- it would be
filming this week and his death most certainly would have ended the
show anyway.

And about three minutes after I wrote the above and moved on to
reading other posts, it occurred to me that the show ended on a couple
of cliffhangers, with Willa running away and whatnot. Storylines that
*should* get resolved on parent-show Bones. The *obvious* solution
would be to have Walter promise on Leo's deathbead or graveside to
find Willa and then one or more gypsy skeletons find their way to the
Jeffersonian.

-- Rob

Dennis M

9/5/2012 3:52:00 AM

0

In article <k23f21$moi$1@dont-email.me>,
Arthur Lipscomb <arthur@alum.calberkeley.org> wrote:

> Coincidentally, I have The Green Mile on order. I hadn't planned
> on watching it anytime soon but now I'll definitely watch when it
> arrives.

Not one of your better King adaptations IMO. I always thought they tried
to ride on the coattails of Shawshank but the story was nowhere near as
good (MCD did a good job with what he had though).

Adam H. Kerman

9/5/2012 6:27:00 AM

0

Dennis M <dennism3@dennism3.invalid> wrote:
>Arthur Lipscomb <arthur@alum.calberkeley.org> wrote:

>>Coincidentally, I have The Green Mile on order. I hadn't planned
>>on watching it anytime soon but now I'll definitely watch when it
>>arrives.

>Not one of your better King adaptations IMO. I always thought they tried
>to ride on the coattails of Shawshank but the story was nowhere near as
>good (MCD did a good job with what he had though).

He didn't play a character but a plot device, but what he did with it
was entertaining enough.

Arthur Lipscomb

9/5/2012 6:26:00 PM

0

On 9/4/2012 11:27 PM, Adam H. Kerman wrote:
> Dennis M <dennism3@dennism3.invalid> wrote:
>> Arthur Lipscomb <arthur@alum.calberkeley.org> wrote:
>
>>> Coincidentally, I have The Green Mile on order. I hadn't planned
>>> on watching it anytime soon but now I'll definitely watch when it
>>> arrives.
>
>> Not one of your better King adaptations IMO. I always thought they tried
>> to ride on the coattails of Shawshank but the story was nowhere near as
>> good (MCD did a good job with what he had though).

I think that was my initial reaction when I saw it in the theater. I
think I liked it but not enough to want to sit through it again.


>
> He didn't play a character but a plot device, but what he did with it
> was entertaining enough.
>

I had a promo code for some free blu-rays from WB and Green Mile was on
the list of blu-rays to select from. After making some other
selections, I had narrowed my final selection down to Green Mile and a
couple of other choices. However, after reading various rave reviews, I
decided to give it another shot.