Newbie help: running command-line utils in Ruby

G

greg f.

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
 
B

Brian Schröder

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,053
Latest member
BrodieSola

Latest Threads

Top