[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

Newbie help: running command-line utils in Ruby

greg f.

11/17/2004 5:39:00 PM

I have this (It's not mine, I found it somewhere):

(Not sure how to format for viewing here)
lines = %x{ssh-agent}

File.open("c:/workspace/sshagent_barf.bat", "w") do |file|
lines.each do |line|
chunks = line.chomp.split ';'

if chunks[0] =~ /^SSH/
file.puts "SET #{chunks[0]}"
end
end
end


What I would like to do is not save the the lines in a .bat but in a
variable or to the screen, and run ssh-add, and be prompted for my
password.

Any help will be greatly appreciated!

~greg

1 Answer

Brian Schröder

11/18/2004 10:08:00 AM

0

On Thu, 18 Nov 2004 02:43:15 +0900
"greg f." <redghoti@gmail.com> wrote:

> I have this (It's not mine, I found it somewhere):
>
> (Not sure how to format for viewing here)
> lines = %x{ssh-agent}
>
> File.open("c:/workspace/sshagent_barf.bat", "w") do |file|
> lines.each do |line|
> chunks = line.chomp.split ';'
>
> if chunks[0] =~ /^SSH/
> file.puts "SET #{chunks[0]}"
> end
> end
> end
>
>
> What I would like to do is not save the the lines in a .bat but in a
> variable or to the screen, and run ssh-add, and be prompted for my
> password.
>
> Any help will be greatly appreciated!
>
> ~greg
>
>

You can execute Programs in differnt ways.
See
- `` Backticks
- popen
- system.

I do not know ssh-add, so I'm not shure what you want to accomplish.

Regards,

Brian


--
Brian Schröder
http://www.brian-sch...