[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

Call a program

greg

8/17/2007 9:43:00 PM

Hi all,

Can anyone help me with the following issue: How can I call a program
(such as less, g++ etc.) from ruby script and save the output to a
variable inside the ruby script?

Thanks,
Greg

4 Answers

Robert Klemme

8/17/2007 9:51:00 PM

0

On 17.08.2007 23:42, greg wrote:
> Can anyone help me with the following issue: How can I call a program
> (such as less, g++ etc.) from ruby script and save the output to a
> variable inside the ruby script?

The easiest forms are these

x=`ls -l`
x=%x{ls -l}

For more complex interactions please look at various versions of popen.

Kind regards

robert

Mason Barge

11/12/2012 11:53:00 PM

0

On Mon, 12 Nov 2012 14:20:51 -0600, Jim G. <jimgysin@geemail.com.invalid>
wrote:

>Mason Barge sent the following on Fri, 09 Nov 2012 12:18:03 -0500:
>> On Thu, 8 Nov 2012 16:35:12 -0500, "Obveeus" <Obveeus@aol.com> wrote:
>>
>> >
>> >"Mason Barge" <masonbarge@gmail.com> wrote:
>> >> On Wed, 7 Nov 2012 16:18:18 -0500, "Obveeus" <Obveeus@aol.com> wrote:
>> >>
>> >>>
>> >>>"Jim G." <jimgysin@geemail.com.invalid> wrote:
>> >>>> Obveeus sent the following on Tue, 6 Nov 2012 14:29:40 -0500:
>> >>>>>
>> >>>>> "Mason Barge" <masonbarge@gmail.com> wrote:
>> >>>>> > On Mon, 5 Nov 2012 23:39:51 -0500, "Obveeus" <Obveeus@aol.com> wrote:
>> >>>>> >
>> >>>>> >>"Jim G." <jimgysin@geemail.com.invalid> wrote:
>> >>>>> >>> Perhaps that's why I like college sports so much. With sports,
>> >>>>> >>> coaches
>> >>>>> >>> and recruiters don't give a rat's backside about anything other
>> >>>>> >>> than
>> >>>>> >>> how
>> >>>>> >>> good you are at that sport. If you can play the game better than
>> >>>>> >>> the
>> >>>>> >>> others being recruited and if you can meet the minimal admissions
>> >>>>> >>> standards of the school, then you can make the team. Period.
>> >>>>> >>
>> >>>>> >>That is funny...as if the 'minimum admission standards' are not
>> >>>>> >>severly
>> >>>>> >>adjusted to fit the needs of sub par student athletes.
>> >>>>> >
>> >>>>> > That's not what he's saying. He's saying admission to the team and
>> >>>>> > the
>> >>>>> > amount of playing time someone gets has no element of Political
>> >>>>> > Correctness.
>> >>>>>
>> >>>>> Even if that is what he meant,
>> >>>>
>> >>>> "Even if"? How could you possibly *not* know that that was what I meant?
>> >>>>
>> >>>>> that isn't true, either, since there is still
>> >>>>> all kinds of 'good for team morale' attitude/sucking up stuff that has
>> >>>>> to
>> >>>>> be
>> >>>>> done in exchange for playing time.
>> >>>>
>> >>>> G0t some examples? Because this should be *really* entertaining.
>> >>>
>> >>>Seriously? You've never heard of a player being benched for having a bad
>> >>>attitude or not started as a penalty for missing the start of practice, or
>> >>>etc... Coaches make all kinds of playing decisions for reasons other than
>> >>>the players' abilities.
>> >>
>> >> You're out in left field somewhere. Benching a player for disciplinary
>> >> reasons is nothing akin to rejecting a better qualified white applicant in
>> >> favor of a minority applicant, because of race.
>> >
>> >Which, of course, was not what was under discussion in the first place. The
>> >discussion was about people getitng into a school with less worthiness than
>> >regular applicants. Jim tried to change the discussion into something about
>> >the merits of college sports where only the best are allowed on the field.
>>
>> He was clearly changing to a related topic, saying why he liked college
>> sports and comparing the decision process favorably to college admissions.
>
>Yep. And at no time did I make any effort to stop anyone from continuing
>the discussion in its original context. It's kind of funny, really, as
>I'm already seeing the usual (when he's in a hole, that is) Obveeus
>tactics coming into play.

I have a suggestion. Just let it go. You have better things to do with the
20 or 30 minutes you're about to waste.

Obveeus

11/13/2012 12:02:00 AM

0


"Mason Barge" <masonbarge@gmail.com> wrote:

> On Mon, 12 Nov 2012 16:17:32 -0500, "Obveeus" <Obveeus@aol.com> wrote:
>
>>"Jim G." <jimgysin@geemail.com.invalid> wrote:
>>> Middle school? Seriously? I'll take that as a concession on your part.
>>> Unless you can somehow explain why *middle* school is at all relevant to
>>
>>Well, I could explain to you how it was relevant, but I think I'll just
>>ask
>>you to bone up on your reading comprehension and note that Mason brought
>>the
>>subject up first, so I was responding to what he wrote.
>
> Yeah, but it was a bit off-topic. When I was in middle school, there was
> at least some chance a coach might play kids just to make sure everyone
> got some playing time. In the atmosphere of today's teenage sports
> leagues, I don't think they even do that in Little League any more. At
> least in some teams.

I'm 100% sure it still goes on at the Little League level. After all, those
parents are paying cash out of their pockets for their kids to be on the
team and the only way the coach/league makes money is if they can get a
large enough volume of kids involved. If those mediocre kids don't get
playing time, their parents are going to stop forking over the $400/9 weeks
entrant fee.

Back to something closer to on the topic, though... even though you and Jim
seem sure that athletes have the same academic requirements as other kids in
a school...both middle school and high school age kids on sports teams will
get a lot more free tutoring help (and do overs and extra credit
opportunities and etc...) than the same kids not on the sports team. And
when it comes time for graduation if some kid has an athletic scholarship to
college all lined up except for that last English credit, you can bet that
99 out of 100 teachers will find a way to give that kid a passing grade.
Regardless of if a kid deserves to pass high school, much less deserves to
go to college, very few teachers are going to step up and deny a kid the
opportunity when the choice is between:
A. free ride scholarship to a good 4 year school
and
B. kid will end up working at a fast food place or going to prison because
he has nothing going for him after high school.


Obveeus

11/13/2012 12:15:00 AM

0


"Mason Barge" <masonbarge@gmail.com> wrote:
> On Mon, 12 Nov 2012 14:20:51 -0600, Jim G. <jimgysin@geemail.com.invalid>
> wrote:

>>Yep. And at no time did I make any effort to stop anyone from continuing
>>the discussion in its original context. It's kind of funny, really, as
>>I'm already seeing the usual (when he's in a hole, that is) Obveeus
>>tactics coming into play.
>
> I have a suggestion. Just let it go. You have better things to do with the
> 20 or 30 minutes you're about to waste.

Jim, the fool, takes a conversation about Obama's worthiness to get into
Harvard Law, adjusts it to a declaration that all college records should be
disclosed, then adjusts it to a claim that athletics is pure of favoritism,
then adjusts it to claim that now high school records matter...
and yet claims that I am the one changing the subject when I respond to your
raising of the issue of middle school...and claims that I am changing the
subject when I try to respond to his silly sports parable by pointing out
that sports are not pure, either...and his best reply then is to explain
that coaches don't do that except when they do and when they do it doesn't
count as part of the topic of purity in sports.