Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > Newbie help: running command-line utils in Ruby

Reply
Thread Tools

Newbie help: running command-line utils in Ruby

 
 
greg f.
Guest
Posts: n/a
 
      11-17-2004
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

 
Reply With Quote
 
 
 
 
Brian Schröder
Guest
Posts: n/a
 
      11-18-2004
On Thu, 18 Nov 2004 02:43:15 +0900
"greg f." <> 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-schroeder.de/



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
OT: Freeware utils Neil MCSE 33 04-21-2006 09:16 PM
problems in using id-utils for C++ files venkatesh C++ 1 05-03-2005 10:21 AM
file encryption utils Koger Computer Security 2 03-12-2005 12:31 PM
dev-utils gem... How do I require_gem 'dev-utils/debug' ? Eirikur Hallgrimsson Ruby 3 10-10-2004 07:47 AM
in using ADS 1.2, does utils.h = Utils.h for example ... in windows XP arm developer C++ 0 06-03-2004 02:33 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57