Eric C. | 1 Dec 2010 02:07
Picon
Favicon

Entering password in shell

HI:

I'm trying to run a shell to install a gem:

PTY.spawn("sudo gem install #{gem} --local 2>&1") do |stdin,stdout,pid|
  stdout.write("#{pass}\n")
  puts stdin.read.lstrip  #write output to screen
end

This works fine if the password is correct.  However, if the password is
not correct it hangs.  I've tried this line too:

  stdout.write("#{pass}\n\n\n\n\n\n")

to try to get it to terminate, but it still hangs.  Is there a way to
enter passwords into the command line or enter them ahead of time?

Thanks,
Eric

--

-- 
Posted via http://www.ruby-forum.com/.

David Masover | 1 Dec 2010 02:40
Gravatar

Re: Ruby 1.8 vs 1.9

On Tuesday, November 30, 2010 02:31:29 am Phillip Gawlowski wrote:
> On Mon, Nov 29, 2010 at 10:38 AM, David Masover <ninja <at> slaphack.com> wrote:
> > Then why the fsck is he CTO of anything?
> > 
> >> and probably doesn't care.
> > 
> > This is the part I don't get.
> > How do you get to be CTO by not caring about technology?
> 
> Because C-level execs working for any of the S&P 500 don't deal with
> minutiae, and details. They set *policy*. Whether or not to even look
> into the cloud services, if and how to centralize IT support, etc.

To do that effectively would require some understanding of these, however. In 
particular, "cloud" has several meanings, some of which might make perfect 
sense, and some of which might be dropped on the floor.

> The CTO supports the CEO, and you hardly expect the CEO to be
> well-versed with a tiny customer, either, would you?

I'd expect the CEO to know and care at least about management, and hopefully 
marketing and the company itself.

> Oh, and he's the fall guy in case the database gets deleted. :P

Ideally, the person who actually caused the database to get deleted would be 
responsible -- though management should also bear some responsibility.

> >> Together with the usual
> >> bureaucratic infighting and processes to change *anything*, you'll be
(Continue reading)

Michael Granger | 1 Dec 2010 02:59

[ANN] treequel 1.2.0


Version 1.2.0 of treequel has been released.

# Treequel - an honest LDAP library

Treequel is an LDAP toolkit for Ruby. It is intended to allow quick, easy
access to LDAP directories in a manner consistent with LDAP's hierarchical,
free-form nature. 

It's inspired by and modeled after [Sequel](http://sequel.rubyforge.org/), a
kick-ass database library.

## Examples

Here are a few short examples to whet your appetite:

    # Connect to the directory at the specified URL
    dir = Treequel.directory( 'ldap://ldap.company.com/dc=company,dc=com' )

    # Get a list of email addresses of every person in the directory (as
    # long as people are under ou=people)
    dir.ou( :people ).filter( :mail ).map( :mail ).flatten

    # Get a list of all IP addresses for all hosts in any ou=hosts group
    # in the whole directory:
    dir.filter( :ou => :hosts ).collection.filter( :ipHostNumber ).
      map( :ipHostNumber ).flatten

    # Get all people in the directory in the form of a hash of names 
    # keyed by email addresses
(Continue reading)

brabuhr | 1 Dec 2010 05:49
Picon

Re: dbi doesnt work well with sqlite3!?!?

On Tue, Nov 30, 2010 at 12:43 PM, Tianshuo Deng <dengtianshuo <at> gmail.com> wrote:
> Hi, guys, I want to share my discovery with you. If you found I am wrong, pleas point it out:)
>
> if you use dbi to generate a prepared statement by doing:
>
> sth=dbh.prepare("INSERT INTO WORDS VALUES(?,?,?)")
>
> (0..1).each{|i|
>        sth.execute("1","2","3")
> }
>
> it will give you a /sqlite3-ruby-1.3.2/lib/sqlite3/statement.rb:41:in `bind_param': library
routine called out of sequence (SQLite3::MisuseException).
>
> Is there anybody using dbi??????
> Is that very useful???I know it should be useful....but the only way I can make my program work is to bypass dbi.....

I'm not using DBI, but based on an online tutorial for DBI:Mysql I
made this test program:

require "dbi"

dbh = DBI.connect("DBI:SQLite3:memory:")

dbh.do("DROP TABLE IF EXISTS EMPLOYEE")
dbh.do("CREATE TABLE EMPLOYEE ( FIRST_NAME  CHAR(20) NOT NULL,
LAST_NAME  CHAR(20), AGE INT,  SEX CHAR(1), INCOME FLOAT )")

sth = dbh.prepare( "INSERT INTO EMPLOYEE(FIRST_NAME, LAST_NAME, AGE,
SEX, INCOME) VALUES (?, ?, ?, ?, ?)")
(Continue reading)

Tianshuo Deng | 1 Dec 2010 06:00
Picon
Gravatar

Re: dbi doesnt work well with sqlite3!?!?

Thanks brabuhr :)

Just like what you said. It will happen when you have more than one record to insert.

On Nov 30, 2010, at 10:49 PM, brabuhr <at> gmail.com wrote:

> On Tue, Nov 30, 2010 at 12:43 PM, Tianshuo Deng <dengtianshuo <at> gmail.com> wrote:
>> Hi, guys, I want to share my discovery with you. If you found I am wrong, pleas point it out:)
>> 
>> if you use dbi to generate a prepared statement by doing:
>> 
>> sth=dbh.prepare("INSERT INTO WORDS VALUES(?,?,?)")
>> 
>> (0..1).each{|i|
>>        sth.execute("1","2","3")
>> }
>> 
>> it will give you a /sqlite3-ruby-1.3.2/lib/sqlite3/statement.rb:41:in `bind_param': library
routine called out of sequence (SQLite3::MisuseException).
>> 
>> Is there anybody using dbi??????
>> Is that very useful???I know it should be useful....but the only way I can make my program work is to bypass dbi.....
> 
> I'm not using DBI, but based on an online tutorial for DBI:Mysql I
> made this test program:
> 
> require "dbi"
> 
> dbh = DBI.connect("DBI:SQLite3:memory:")
> 
(Continue reading)

zuerrong | 1 Dec 2010 08:50
Picon

A algorithm for finding the number

Hi members,

Maybe this is not a special question to ruby.
But since my ruby app has meet this algorithm problem, so please give
the suggestion if you'd like.

I have these datas in a mysql table:

mysql> select startNum,endNum from ip_data limit 10;
+----------+----------+
| startNum | endNum   |
+----------+----------+
| 16777216 | 16777471 |
| 16843008 | 16843263 |
| 16909056 | 16909311 |
| 17367040 | 17498111 |
| 17498112 | 17563647 |
| 17563648 | 17825791 |
| 17825792 | 18153471 |
| 18153472 | 18219007 |
| 18219008 | 18350079 |
| 18350080 | 18874367 |
+----------+----------+

(Those are actually the bigint for ip addresses.)

Given a numer, say 17498200, I want to find this number is in which
row of the table.

I could run the SQL with ruby's mysql API (dbi and mysql::dbd):
(Continue reading)

jun yu | 1 Dec 2010 09:29
Picon

A question about string#%

I have an integer number like 1111, How can I get a string like below
by  the string#% ?

"11110000"

I know   "%-8d" % 1111 can get "1111    ".

Thank you.

Mike Stephens | 1 Dec 2010 09:36

Re: A algorithm for finding the number

The common sense thing to do is exactly what you have done. Make sure
you have indexes on the fields. If it's still slow, try a different
database. Five minutes and you should be able to move the data into
Access (Jet), like this:

            require 'win32ole'
            connection = WIN32OLE.new('ADODB.Connection')
            connection.Open('Provider=Microsoft.Jet.OLEDB.4.0;Data
            Source=c:\Ruby\RubyAccess.mdb')
            recordset =  WIN32OLE.new('ADODB.Recordset')
            sql = 'SELECT * FROM T1'
            recordset.Open(sql, connection)
            data = recordset.GetRows.transpose
            puts data
            recordset.close
          end

--

-- 
Posted via http://www.ruby-forum.com/.

Gabor Medve | 1 Dec 2010 09:50
Picon
Favicon

ruby/ldap - available Active Directory attributes, negative filter

Hi,

I'm trying to get user information from Active directory via Ruby/LDAP
and I don't see all attributes I'd like to use. I tried to look for
relevant information, RTFM, but unfortunately I didn't find a solution
until this time. One of the attributes I'd like to use is accountExpires
and I see the following attributes are listed by the following code:

--
require 'ldap'

$LDAP_HOST = 'my active directory server
$LDAP_PORT = LDAP::LDAP_PORT
$LDAP_USER = 'bin user DN
$LDAP_PW   = 'bind pw

conn = LDAP::Conn.new($LDAP_HOST, 3268)
conn.bind($LDAP_USER, $LDAP_PW)

  my_filter = "(&(objectCategory=person)(objectclass=user)
  res = conn.search2("dc=mydc,dc=com", LDAP::LDAP_SCOPE_SUBTREE,
my_filter)
  res[0].keys.each { |k| puts k }

conn.unbind
--

the results are (sorted):
cn
company
(Continue reading)

Harry Kakueki | 1 Dec 2010 10:10
Picon

Re: A question about string#%

On Wed, Dec 1, 2010 at 5:29 PM, jun yu <mail2fish <at> gmail.com> wrote:
> I have an integer number like 1111, How can I get a string like below
> by  the string#% ?
>
> "11110000"
>
> I know   "%-8d" % 1111 can get "1111    ".
>
>
> Thank you.
>
>

Is String#% a requirement or just your first idea?

num = 1111
p num.to_s.ljust(8,"0")

#> "11110000"

Harry


Gmane