From: Robert Klemme Date: 2004-01-08T18:16:42+09:00 Subject: Re: Store shell session/cmd.exe session in some object? "Zach Dennis" schrieb im Newsbeitrag news:NCEFIOKHDAJMKDIGMJJKCEEFCJAA.zdennis@mktec.com... > I'd like to do something like: > > mysession = SystemShell.new //Would I open a pipe? Would it be a IO.new? > dir_list = mysession.puts( "ls -al" ) //on Linux > dir_list = mysession.puts( "dir" ) //on Windows How about using Dir.entries( "." ) - this is more portable and likely faster, too. > and then further more do this: > > mysession.puts( "ssh -l myname 127.0.0.1" ) > mysession.puts( "cd /opt/webstar/etc/etc/" ) > list = mysession.puts( "ls -al" ) > > And so on. Does this make sense. Basically I am looking to be able to keep a > session open with the system and receive it's output. You mean "with the command processor". For simple usage you can resort to IO.popen() (some caveats apply for windows). An example: IO.popen( "cmd.exe", "r+" ) do |cmd| Thread.new(cmd) do |io| while line = io.gets puts line end end cmd.puts "dir" cmd.puts "cd \\" cmd.puts "dir" sleep 3 end Else there is expect for Ruby. http://raa.ruby-lang.org/list.rhtml?name=ruby-expect Regards robert