Rexml and external entities

It’s too bad those two things … entity expansion and validation … got
tied together since they are really separate things. Entity expansion gets
used as an include mechanism. It’s easy to see how one might want to use
that, but not care about validation.

···

-----Original Message-----
From: ser@germane-software.com [mailto:ser@germane-software.com]
Sent: Wednesday, January 07, 2004 1:32 PM
To: ruby-talk@ruby-lang.org
Subject: Re: rexml and external entities

Clifford Heath cjh-nospam@nospaManagesoft.com wrote in
message news:Xns94697F721B661cjhnospamnospaManage@172.16.33.11

The rexml included with 1.8-preview3 doesn’t expand
external entities.
Has this been added in a more recent version, or is it
otherwise planned?
Otherwise how may I expand them?

REXML is not a validating parser, and therefore is not required to
expand external entities. REXML may expand external entities in the
future, but I wouldn’t hold your breath.


A.G. Edwards & Sons’ outgoing and incoming e-mails are electronically
archived and subject to review and/or disclosure to someone other
than the recipient.


“Volkmann, Mark” Mark.Volkmann@AGEDWARDS.com wrote in
news:89539780CB9BD51182270002A5897DF605ECFF74@hqempn04.agedwards.com:

It’s too bad those two things … entity expansion and validation …
got tied together since they are really separate things. Entity
expansion gets used as an include mechanism. It’s easy to see how one
might want to use that, but not care about validation.

Exactly my need. Sean, if I locate the external file, do I need to
do anything special to load it? Because then I could add any entities
defined in it to the loaded rexml tree and they should get expanded as
if they were internal entities. Can you give an example or some hints
on how to do this? I’m kinda stuck with external entities, as we’re
using the one XML file for generating code (ruby program) and now our
documentation team want to include entities which expand differently
for this purpose (different include file) than for code-generation.

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

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. This would prove
beneficial in the case that I ssh into several server and gather data from
each server in my script. Any ideas?

Thanks,

Zach

“Zach Dennis” zdennis@mktec.com 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

Zach Dennis wrote:

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

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. This would prove
beneficial in the case that I ssh into several server and gather data from
each server in my script. Any ideas?

I’ve never used it, but does shell.rb in the standard lib do what you want?

Robert Klemme wrote:

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

Thank you so much Robert, your code has proven to be invaluable to my
learning process!!

Zach