[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

command help

Tom Allison

10/4/2006 11:56:00 PM

Found a buddy who used something like:

hostname = open("|hostname").gets

And...

I see that it works, but I don't find any of the documentation that makes sense.

So -- it seems to be IO class, but how? There's no IO declaration there.
Also, I can't find anything that says you can open a command with a preceding
pipe and get the output of the executed command.

I'm familiar with perls open: open(FH, "hostname |") with a suffixed pipe --
which is consistent with unix pipe usage.

But can someone explain to me what's going on here so my brain doesn't implode?

18 Answers

Jano Svitok

10/5/2006 12:02:00 AM

0

On 10/5/06, Tom Allison <tallison@tacocat.net> wrote:
> Found a buddy who used something like:
>
> hostname = open("|hostname").gets
>
> And...
>
> I see that it works, but I don't find any of the documentation that makes sense.
>
> So -- it seems to be IO class, but how? There's no IO declaration there.
> Also, I can't find anything that says you can open a command with a preceding
> pipe and get the output of the executed command.
>
> I'm familiar with perls open: open(FH, "hostname |") with a suffixed pipe --
> which is consistent with unix pipe usage.
>
> But can someone explain to me what's going on here so my brain doesn't implode?
>

http://ruby-doc.org/core/classes/Kernel.ht...

Bil Kleb

10/5/2006 1:09:00 AM

0

Tom Allison wrote:
>
> But can someone explain to me what's going on here so my brain doesn't
> implode?

Throw back to the old ftp pipe days? E.g., see,

http://www.ii.com/internet/ftp/archie_ftp_unco...

Later,
--
Bil Kleb
http://fun3d.lar...

Tom Allison

10/5/2006 1:15:00 AM

0

Jan Svitok wrote:
> On 10/5/06, Tom Allison <tallison@tacocat.net> wrote:
>> Found a buddy who used something like:
>>
>> hostname = open("|hostname").gets
>>
>> And...
>>
>> I see that it works, but I don't find any of the documentation that
>> makes sense.
>>
>> So -- it seems to be IO class, but how? There's no IO declaration there.
>> Also, I can't find anything that says you can open a command with a
>> preceding
>> pipe and get the output of the executed command.
>>
>> I'm familiar with perls open: open(FH, "hostname |") with a suffixed
>> pipe --
>> which is consistent with unix pipe usage.
>>
>> But can someone explain to me what's going on here so my brain doesn't
>> implode?
>>
>
> http://ruby-doc.org/core/classes/Kernel.ht...
>


OK, I missed the "Kernel#open" in the list of where I can use open. NOTE: the
list from 'ri' could be better formatted.

What's with the pipe being at the wrong end?
What's the thinking behind that?

Ara.T.Howard

10/5/2006 5:26:00 AM

0

Pit Capitain

10/5/2006 7:14:00 AM

0

Tom Allison schrieb:
>>> hostname = open("|hostname").gets
>
> What's with the pipe being at the wrong end?
> What's the thinking behind that?

You can find a short description in ri or the Pickaxe:

C:\tmp>ri IO
-------------------------------------------------------------- Class: IO
Class +IO+ is the basis for all input and output in Ruby. An I/O
stream may be _duplexed_ (that is, bidirectional), and so may use
more than one native operating system stream.

Many of the examples in this section use class +File+, the only
standard subclass of +IO+. The two classes are closely associated.

As used in this section, _portname_ may take any of the following
forms.

* A plain string represents a filename suitable for the
underlying operating system.

>>>>>
* A string starting with ``+|+'' indicates a subprocess. The
remainder of the string following the ``+|+'' is invoked as a
process with appropriate input/output channels connected to it.
>>>>>

* A string equal to ``+|-+'' will create another Ruby instance as
a subprocess.

Regards,
Pit

Peter Webb

10/11/2012 3:42:00 AM

0



"Farm1" wrote in message news:k53clb$sbd$22@dont-email.me...

"Peter Webb" <webbfamily@DIE_SPAMoptusnet.com.au> wrote in message
news:k53bbr$co1$1@news.albasani.net...



> However, I'm not so sure that Abbott wants a by election in Thomson's seat
> any more. That would give him the PM's job but with a majority of 1 and a
> hostile senate. If he waits 12 months, he is quite likely to win with a
> majority of ten or more, and a marginally less hostile senate. Better to
> wait.

It's too late for Abbott now. He needed the government to fall over long
before this. Now he's just looking like a bovver boy wiff blooming big
boots who has very limited responses. He's shown he can hit out, kick till
the cows come home, be negative and whinge but he hasn't shown that he can
get anyone to co-operate with him, ever.
_____________________________________________________
ROFL. He has united the entire Liberal Party behind him. He enjoys far
better support from his colleagues that does Gillard.

He'd need to be able to do that to
be PM because he'll need to be able to stich up deals in his own party and
across party lines.
_______________________________________________
But he has stitched up deals in his own party and across party lines (eg
with the Nationals). Have you not followed politics for the last few years?

Farm1

10/11/2012 6:34:00 AM

0

"Peter Webb" <webbfamily@DIE_SPAMoptusnet.com.au> wrote in message
news:k55f79$v2r$1@news.albasani.net...
> "Farm1" wrote in message news:k53clb$sbd$22@dont-email.me...
> "Peter Webb" <webbfamily@DIE_SPAMoptusnet.com.au> wrote in message
> news:k53bbr$co1$1@news.albasani.net...
>
>
>
>> However, I'm not so sure that Abbott wants a by election in Thomson's
>> seat any more. That would give him the PM's job but with a majority of 1
>> and a hostile senate. If he waits 12 months, he is quite likely to win
>> with a majority of ten or more, and a marginally less hostile senate.
>> Better to wait.
>
> It's too late for Abbott now. He needed the government to fall over long
> before this. Now he's just looking like a bovver boy wiff blooming big
> boots who has very limited responses. He's shown he can hit out, kick
> till
> the cows come home, be negative and whinge but he hasn't shown that he
> can
> get anyone to co-operate with him, ever.
> _____________________________________________________
> ROFL. He has united the entire Liberal Party behind him. He enjoys far
> better support from his colleagues that does Gillard.

Hmmmm...... That's not what I'm hearing.

> He'd need to be able to do that to
> be PM because he'll need to be able to stich up deals in his own party and
> across party lines.
> _______________________________________________
> But he has stitched up deals in his own party and across party lines (eg
> with the Nationals). Have you not followed politics for the last few
> years?

Not heard of bipartisanship Peter? Not heard of the names of those pesky
Independents who didn't trust him enough to stitch up a deal with him to
make PM? Have you bothered to follow politics for the last few years?


Peter Webb

10/11/2012 7:43:00 AM

0



"Farm1" wrote in message news:k55p80$qtn$2@dont-email.me...

"Peter Webb" <webbfamily@DIE_SPAMoptusnet.com.au> wrote in message
news:k55f79$v2r$1@news.albasani.net...
> "Farm1" wrote in message news:k53clb$sbd$22@dont-email.me...
> "Peter Webb" <webbfamily@DIE_SPAMoptusnet.com.au> wrote in message
> news:k53bbr$co1$1@news.albasani.net...
>
>
>
>> However, I'm not so sure that Abbott wants a by election in Thomson's
>> seat any more. That would give him the PM's job but with a majority of 1
>> and a hostile senate. If he waits 12 months, he is quite likely to win
>> with a majority of ten or more, and a marginally less hostile senate.
>> Better to wait.
>
> It's too late for Abbott now. He needed the government to fall over long
> before this. Now he's just looking like a bovver boy wiff blooming big
> boots who has very limited responses. He's shown he can hit out, kick
> till
> the cows come home, be negative and whinge but he hasn't shown that he
> can
> get anyone to co-operate with him, ever.
> _____________________________________________________
> ROFL. He has united the entire Liberal Party behind him. He enjoys far
> better support from his colleagues that does Gillard.

Hmmmm...... That's not what I'm hearing.

> He'd need to be able to do that to
> be PM because he'll need to be able to stich up deals in his own party and
> across party lines.
> _______________________________________________
> But he has stitched up deals in his own party and across party lines (eg
> with the Nationals). Have you not followed politics for the last few
> years?

Not heard of bipartisanship Peter? Not heard of the names of those pesky
Independents who didn't trust him enough to stitch up a deal with him to
make PM?
_______________________________________
They got a better deal from Gillard. Or thought they did. I note Gillard
screwed Wilkie over and reneged; as he is of the left wing she could afford
to do that, he isn't going to form government with the Coalition, and there
is no point in Abbott trying to get him on side. (Although he will retain
his seat at the next election). As Oakeshott and Windsor are very unlikely
to be re-elected,the independents will be irrelevant after the next
election.



Have you bothered to follow politics for the last few years?
_________________________________________
Sure. Abbott's doing a great job of pressuring the government. He would also
have won any election held in the last 12 months, and would win today in a
landslide. Clearly he has got the Liberals working together, and just as
clearly he is very likely to be the next PM, whatever you may believe about
his personal character.

bringyagrogalong

10/11/2012 8:01:00 AM

0

"Peter Webb" <webbfamily@DIE_SPAMoptusnet.com.au> wrote:
> "Farm1"  wrote in messagenews:k55p80$qtn$2@dont-email.me...
>
> Not heard of bipartisanship Peter?  Not heard of the names of those pesky
> Independents who didn't trust him enough to stitch up a deal with him to
> make PM?
> _______________________________________
>
> They got a better deal from Gillard. Or thought they did. I note Gillard
> screwed Wilkie over and reneged; as he is of the left wing she could afford
> to do that.

Fair dinkum, Webb, your ignorance is breathtaking.

"Wilkie trained at the Royal Military College, Duntroon and graduated
in 1984. He joined the Young Liberals while a cadet. After graduation
and being stationed in Brisbane, he became a member of the Liberal
Party".

Some left-winger.

You really are a doofus, no wonder it's so easy to make you look
stupid.

Incidentally do you still maintain that inverted commas aren't
quotation marks. LOL

--------------

"Labor frontbencher Jenny Macklin denied the Prime Minister had
supported Mr Slipper’s remarks by refusing to vote against him in the
no confidence motion.

“The Prime Minister did not vote for those remarks…what she voted
against was Tony Abbott’s latest attempt to wreck the Parliament.”

Peter Webb

10/11/2012 11:17:00 AM

0



"bringyagrogalong" wrote in message
news:be75a583-94c4-4cb3-826d-4cc4a4c0affd@wm7g2000pbc.googlegroups.com...

"Peter Webb" <webbfamily@DIE_SPAMoptusnet.com.au> wrote:
> "Farm1" wrote in messagenews:k55p80$qtn$2@dont-email.me...
>
> Not heard of bipartisanship Peter? Not heard of the names of those pesky
> Independents who didn't trust him enough to stitch up a deal with him to
> make PM?
> _______________________________________
>
> They got a better deal from Gillard. Or thought they did. I note Gillard
> screwed Wilkie over and reneged; as he is of the left wing she could
> afford
> to do that.

Fair dinkum, Webb, your ignorance is breathtaking.

"Wilkie trained at the Royal Military College, Duntroon and graduated
in 1984. He joined the Young Liberals while a cadet. After graduation
and being stationed in Brisbane, he became a member of the Liberal
Party".

Some left-winger.

____________________________________
And subsequently became a member of the Greens, unsuccessfully standing for
election with them.


You really are a doofus, no wonder it's so easy to make you look
stupid.
_____________________________________
Name one single piece of legislation where he has voted with the Right.

Incidentally do you still maintain that inverted commas aren't
quotation marks. LOL
_____________________________________________
Can't recall saying that. Do you still maintain that the Apollo 11 moon
landing was a hoax, and that the nuclear attacks on Hiroshima and Nagasaki
played no part in Japan's decision to surrender in World War 2? Because both
of those indicate serious mental problems, where as best I can tell you seem
to be complaining about a disagreement on syntax.