[#30920] [REQ] Regexp#match! — Minero Aoki <aamine@...>

あおきです。

19 messages 2001/08/16

[#30945] file exist check method? — "Inoue" <inoue@...>

井上です。

98 messages 2001/08/17
[#30947] Re: file exist check method? — "U.Nakamura" <usa@...> 2001/08/17

こんにちは、なかむら(う)です。

[#30949] Re: file exist check method? — Koji Arai <JCA02266@...> 2001/08/17

新井です。

[#30950] Re: file exist check method? — "U.Nakamura" <usa@...> 2001/08/17

こんにちは、なかむら(う)です。

[#30951] Re: file exist check method? — Koji Arai <JCA02266@...> 2001/08/17

新井です。

[#30953] Re: file exist check method? — nobu.nakada@... 2001/08/17

なかだです。

[#30954] Re: file exist check method? — Koji Arai <JCA02266@...> 2001/08/17

新井です。

[#30955] Re: file exist check method? — "U.Nakamura" <usa@...> 2001/08/17

こんにちは、なかむら(う)です。

[#30956] Re: file exist check method? — Koji Arai <JCA02266@...> 2001/08/17

新井です。

[#30958] Re: file exist check method? — "U.Nakamura" <usa@...> 2001/08/18

こんにちは、なかむら(う)です。

[#30962] Re: file exist check method? — Koji Arai <JCA02266@...> 2001/08/18

新井です。

[#30963] Re: file exist check method? — "U.Nakamura" <usa@...> 2001/08/18

こんにちは、なかむら(う)です。

[#30965] Re: file exist check method? — Koji Arai <JCA02266@...> 2001/08/18

新井です。

[#30969] Re: file exist check method? — nobu.nakada@... 2001/08/18

なかだです。

[#30970] Re: file exist check method? — Koji Arai <JCA02266@...> 2001/08/18

新井です。

[#30981] Re: file exist check method? — Kazuhiro Yoshida <moriq.kazuhiro@...> 2001/08/18

もりきゅうです。長文ごめんなさい。

[#30983] Re: file exist check method? — IWATSUKI Hiroyuki <don@...> 2001/08/18

岩月と申します。そろそろ寝なくては。

[#30988] Re: file exist check method? — Kazuhiro Yoshida <moriq.kazuhiro@...> 2001/08/19

もりきゅうです。

[#30989] Re: file exist check method? — Kazuhiro Yoshida <moriq.kazuhiro@...> 2001/08/19

もりきゅうです。

[#30997] Re: file exist check method? — nobu.nakada@... 2001/08/19

なかだです。

[#31020] Re: file exist check method? — Kazuhiro Yoshida <moriq.kazuhiro@...> 2001/08/20

もりきゅうです。

[#31022] Re: file exist check method? — maili31s@... (SugHimsi == SUGIHARA Hiroshi) 2001/08/20

すぎむし。

[#31024] Re: file exist check method? — nobu.nakada@... 2001/08/20

なかだです。

[#31025] File#join — Kazuhiro Yoshida <moriq.kazuhiro@...> 2001/08/20

もりきゅうです。subject 変えました。

[#31029] Re: File#join — Kazuhiro NISHIYAMA <zn@...> 2001/08/21

In <200108201823.AA00825@yoshida.nifty.ne.jp>

[#31079] Re: File#join — "K.Umakoshi" <pegacorn@...> 2001/08/22

File#join とか File#split とか使った事ないんですが…

[#31062] Re: file exist check method? — "U.Nakamura" <usa@...> 2001/08/21

こんにちは、なかむら(う)です。

[#31065] Re: file exist check method? — nobu.nakada@... 2001/08/22

なかだです。

[#31067] Re: file exist check method? — Kazuhiro Yoshida <moriq.kazuhiro@...> 2001/08/22

もりきゅうです。

[#31068] Re: file exist check method? — "U.Nakamura" <usa@...> 2001/08/22

こんにちは、なかむら(う)です。

[#31073] Re: file exist check method? — nobu.nakada@... 2001/08/22

なかだです。

[#31082] Re: file exist check method? — "U.Nakamura" <usa@...> 2001/08/22

こんにちは、なかむら(う)です。

[#31087] Re: file exist check method? — nobu.nakada@... 2001/08/23

なかだです。

[#31094] Re: file exist check method? — "U.Nakamura" <usa@...> 2001/08/23

こんにちは、なかむら(う)です。

[#31096] Re: file exist check method? — "U.Nakamura" <usa@...> 2001/08/23

こんにちは、なかむら(う)です。

[#31005] インストールしました — 嶋崎 正貴 <hayashih@...>

嶋崎と申します

15 messages 2001/08/20

[#31144] create_process または Win での外部コマンド実行 — Take_tk <ggb03124@...>

Windows で外部コマンドを実行するにはどういう方法があるのでしょうか?。

33 messages 2001/08/29
[#31145] Re: create_process または Win での外部コマンド実行 — "U.Nakamura" <usa@...> 2001/08/29

こんにちは、なかむら(う)です。

[#31152] Re: create_process または Win での外部コマンド実行 — nobu.nakada@... 2001/08/29

なかだです。

[#31153] Re: create_process または Win での外部コマンド実行 — Take_tk <ggb03124@...> 2001/08/29

たけ(tk)です。

[ruby-list:30822] Re: expect.rb について

From: NAKAJIMA Taku <tnaka@...>
Date: 2001-08-01 17:53:47 UTC
List: ruby-list #30822
中島@ブレーンです。

On Wed, Aug 01, 2001 at 05:40:18PM +0900,
 takashi Yamaoka wrote:

> UNIXでのパスワード変更のコマンド(passwd)は
> 対話形式ですのでRubyのexpect.rbを使えば
> これを実現できるというのは自分なりに調べて
> 分かったんですが、具体的にどのようにロジックを
> 書いてやればよいのか見当がつきません。

PFMというツールの中で、まさにそれ(expect.rbによるパスワード変更)をやっ
ています。単体で動くように修正したものを引用します。

-------------------------------------------------------------------
require "pty"
require "expect"

$expect_verbose = true

module Expect2
  def spawn(cmd)
    raise "Expect2::spawn is not reentranrant" if defined? @r_f and @r_f
    puts "spawn #{cmd}" if $expect_verbose
    PTY.spawn(cmd) do  |r_f,w_f,pid|
      @r_f = r_f
      @w_f = w_f
      @child_pid = pid
      @w_f.sync = true
      PTY.protect_signal do
	yield
      end
    end
    Process.waitpid(@child_pid, nil)
    @r_f = @r_w = @child_pid = nil
  end
    
  def expect(pattern, timeout=10)
    unless defined? @r_f and @r_f
      raise "expect must be called in spawn do ... end " 
    end
    ret = @r_f.expect(pattern, timeout) do | match |
      unless match
	pattern = pattern.source if pattern.kind_of?(Regexp)
	raise "expect #{pattern} timeout "
      end
      put_to_cmd yield(match)
    end
  end
  
  def put_to_cmd(msg)
    unless defined? @r_f and @r_f
      raise "put_to_cmd must be called in spawn do ... end " 
    end
    @w_f.puts(msg)
  end
end


if $0 == __FILE__
  include Expect2
  def set_password(user, pass)
    spawn("/usr/bin/passwd #{user}") do
      expect(/New UNIX password:/) { pass }
      expect(/Retype new UNIX password:/) { pass }
    end
  end

  set_password("test", "testpass1")
end
-------------------------------------------------------------------

-- 
「stableでなければ生きていけない。unstableでなければ生きてる意味がない」
中島 拓 (株)ブレーン 研究部 (p95@brain-tokyo.co.jp)
http://www03.u-page.so-net.ne.jp/dc4/tnaka/

In This Thread

Prev Next