[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

Can't see ouput of executed command

Andi Schacke

2/27/2007 4:55:00 PM

Hi,

On a windows system, I execute a command using the 'backtick' notation,
but I can't see the output of the command.

For example:

`echo Hello` --> no output

`mvn.bat -version` --> no output

`date` --> no output

When I enter these commands in irb, I can see the correct output. What
irritates me in addition to that is that I can see the output of several
commands, for example

`cvs --help` --> gives me the CVS-Help-output

Any hints?

Thanks
Andi

--
Posted via http://www.ruby-....

4 Answers

Vincent Fourmond

2/27/2007 5:01:00 PM

0

Andi Schacke wrote:
> Hi,
>
> On a windows system, I execute a command using the 'backtick' notation,
> but I can't see the output of the command.
>
> For example:
>
> `echo Hello` --> no output
>
> `mvn.bat -version` --> no output
>
> `date` --> no output

If you mean there's not output on your terminal while you are calling
this from a ruby program, that is perfectly normal. The idea behind the
backticks is that *instead* of outputting the result to the terminal,
the generated text is the value of the expression. You do see it in irb
because irb prints the values of the expressions it evaluates.

Try out:

txt = `echo stuff`
puts "got #{txt} from echo"

> When I enter these commands in irb, I can see the correct output. What
> irritates me in addition to that is that I can see the output of several
> commands, for example
>
> `cvs --help` --> gives me the CVS-Help-output

This is normal, as cvs gives its help on standard error, which is not
taken by the backticks and goes to your terminal.

If you simply want to execute a command and see it's output in a
terminal, use system "command" rather than the backticks.

Cheers,

Vince
--
Vincent Fourmond, PhD student (not for long anymore)
http://vincent.fourmon...

Andi Schacke

2/27/2007 5:10:00 PM

0

>
> If you simply want to execute a command and see it's output in a
> terminal, use system "command" rather than the backticks.
>

Thanks a lot. So what's the difference between system() and exec()?

Cheers Andi

--
Posted via http://www.ruby-....

Vincent Fourmond

2/27/2007 5:14:00 PM

0

Andi Schacke wrote:
>> If you simply want to execute a command and see it's output in a
>> terminal, use system "command" rather than the backticks.
>>
>
> Thanks a lot. So what's the difference between system() and exec()?

system = spawns a subprogram to run something
exec = replaces the current program by the given command.

Unless you know what you are doing, you'll never need exec.

Cheers,

Vince

--
Vincent Fourmond, PhD student (not for long anymore)
http://vincent.fourmon...

John Doe

1/28/2011 10:48:00 AM

0

On 28 Jan 2011 08:21:11 GMT, rfischer@sonic.net (Ray Fischer) wrote:

>NoBody <NoBody@nowhere.com> wrote:
>>On 26 Jan 2011 06:39:32 GMT, rfischer@sonic.net (Ray Fischer) wrote:
>>
>>>NoBody <NoBody@nowhere.com> wrote:
>>>>On 22 Jan 2011 09:27:52 GMT, rfischer@sonic.net (Ray Fischer) wrote:
>>>>
>>>>>NoBody <NoBody@nowhere.com> wrote:
>>>>>>On 21 Jan 2011 07:30:57 GMT, rfischer@sonic.net (Ray Fischer) wrote:
>>>>>>
>>>>>>>NoBody <NoBody@nowhere.com> wrote:
>>>>>>>> rfischer@sonic.net (Ray Fischer) wrote:
>>>>>>>>>NoBody <NoBody@nowhere.com> wrote:
>>>>>>>>>> rfischer@sonic.net (Ray Fischer) wrote:
>>>>>>>>>>>NoBody <NoBody@nowhere.com> wrote:
>>>>>>>
>>>>>>>>>>>> If
>>>>>>>>>>>>ray-ray says the Supreme Court is never wrong (he didn't clarify or
>>>>>>>>>>>>limit in any way)
>>>>>>>>>>>
>>>>>>>>>>>That is an outright lie, but it's what you terrorists supporters do.
>>>>>>>>>>
>>>>>>>>>>I don't support terrorists of any persuasion.
>>>>>>>>>
>>>>>>>>>And I don't support the Dredd Scott Decision, but since when do you
>>>>>>>>>care about facts? You lie.
>>>>>>>>
>>>>>>>>Where did I say you support the Dredd Scott Decision. All I've done
>>>>>>>>is ask for clarification of your statement:
>>>>>>>
>>>>>>>That's another lie, terrorist supporter.
>>>>>>
>>>>>>Proof?
>>>>>
>>>>>The clarification is just above, but you're a _special_ kind of
>>>>>stupid that thinks that proving that you're a liar is smart.
>>>>
>>>>Must be in invisible type since it's not there.
>>>
>>>No, you're just a spceial kind of stupid.
>>
>>Irony anyone
>
>Whines the rightard too stupid to read the text he posts.
>
>>> "And I'm just *sure* you posted condemning Rachel Maddow's remarks
>>> about killing Buish...." whined Nobody in <7i1ri6lsfqj5qcj020rqqf20oru89o8rj5@4ax.com>
>>> apparently trying to excuse the right-wing political assassination attempt that
>>> killed six people.
>>
>>And even more irony from ray-ray since the quotation from me doesn't
>>excuse anything
>
>Apparently it does, asshole.

Explain exactly how liar.

"The US Supreme Court, by definition, is never wrong." (apparently
saying that the Dredd Scott Decision was correct -- watch him squirm
and twist folks...).

Ray Fischer in
http://groups.google.com/group/alt.fan.rush-limbaugh/msg/a64a6e42ee66e572?dm...