Very odd IO problem

B

Brad

All:

I have a very strange problem. I'm hoping someone can help me with
an answer or at least point me in the right direction. I've been
plagued with this problem for quite sometime now, however, up until
now it has only been an intermittent problem.

File: [bh.scripts]cwd.rb
print Dir.getwd


A:BH> ruby
p `ruby [bh.scripts]cwd.rb`.dump
puts `ruby [bh.scripts]cwd.rb`
Exit
"\"D\\nS\\nA\\n0\\n:\\n[\\nB\\nH\\n]\\n\""
D
S
A
0
:
[
B
H
]


Any ideas about how to fix this?


Regards,
Brad
 
Y

Yukihiro Matsumoto

Hi,

In message "Very odd IO problem"

|I have a very strange problem. I'm hoping someone can help me with
|an answer or at least point me in the right direction. I've been
|plagued with this problem for quite sometime now, however, up until
|now it has only been an intermittent problem.

Hmm, it seems working pretty as I expect. What's your problem?
I mean, what do you expect from it?

matz.
 
Y

Yukihiro Matsumoto

Hi,

In message "Re: Very odd IO problem"

||I have a very strange problem. I'm hoping someone can help me with
||an answer or at least point me in the right direction. I've been
||plagued with this problem for quite sometime now, however, up until
||now it has only been an intermittent problem.
|
|Hmm, it seems working pretty as I expect. What's your problem?
|I mean, what do you expect from it?

Oops, I was looking at the second part. You were talking about getwd.
Sorry. But It seems like it's a problem in the VMS port which I don't
know.

matz.
 
B

Brad

Yukihiro said:
Hi,

In message "Re: Very odd IO problem"

||I have a very strange problem. I'm hoping someone can help me with
||an answer or at least point me in the right direction. I've been
||plagued with this problem for quite sometime now, however, up until
||now it has only been an intermittent problem.
|
|Hmm, it seems working pretty as I expect. What's your problem?
|I mean, what do you expect from it?

Oops, I was looking at the second part. You were talking about getwd.
Sorry. But It seems like it's a problem in the VMS port which I don't
know.

matz.

matz:

Thanks for the reply! I was hoping that it wasn't a VMS only problem.
:)

I guess I'll keep trying until I find the source of the problem, or
until someone has an idea to try.

Your response is greatly appreciated. :)

One last question:
With what I have shown, is there anything that comes to mind that may
be suspect? Any bit of information that could narrow my search would
be great.

If not, thanks for trying. :)


Regards,
Brad
 
N

nobu.nokada

Hi,

At Wed, 17 Dec 2003 10:21:57 +0900,
Brad said:
I have a very strange problem. I'm hoping someone can help me with
an answer or at least point me in the right direction. I've been
plagued with this problem for quite sometime now, however, up until
now it has only been an intermittent problem.

File: [bh.scripts]cwd.rb
print Dir.getwd

At first, this script works correctly? Which do you have the
problem, with Dir.getwd only or with backticks?

Anyhow, perhaps VMS style path names would cause many problems
at File.dirname etc.


Index: util.c
===================================================================
RCS file: /cvs/ruby/src/ruby/util.c,v
retrieving revision 1.38
diff -u -2 -p -r1.38 util.c
--- util.c 22 Nov 2003 03:59:18 -0000 1.38
+++ util.c 17 Dec 2003 03:11:48 -0000
@@ -638,4 +638,8 @@ ruby_getcwd()
{
#ifdef HAVE_GETCWD
+# ifdef __VMS
+ char *buf = getcwd(NULL, 0, 0);
+ if (!buf) rb_sys_fail("getcwd");
+# else
int size = 200;
char *buf = xmalloc(size);
@@ -646,4 +650,5 @@ ruby_getcwd()
buf = xrealloc(buf, size);
}
+# endif
#else
# ifndef PATH_MAX
 
B

Brad

Hi,

At Wed, 17 Dec 2003 10:21:57 +0900,
Brad said:
I have a very strange problem. I'm hoping someone can help me with
an answer or at least point me in the right direction. I've been
plagued with this problem for quite sometime now, however, up until
now it has only been an intermittent problem.

File: [bh.scripts]cwd.rb
print Dir.getwd

At first, this script works correctly? Which do you have the
problem, with Dir.getwd only or with backticks?

Anyhow, perhaps VMS style path names would cause many problems
at File.dirname etc.


Index: util.c
===================================================================
RCS file: /cvs/ruby/src/ruby/util.c,v
retrieving revision 1.38
diff -u -2 -p -r1.38 util.c
--- util.c 22 Nov 2003 03:59:18 -0000 1.38
+++ util.c 17 Dec 2003 03:11:48 -0000
@@ -638,4 +638,8 @@ ruby_getcwd()
{
#ifdef HAVE_GETCWD
+# ifdef __VMS
+ char *buf = getcwd(NULL, 0, 0);
+ if (!buf) rb_sys_fail("getcwd");
+# else
int size = 200;
char *buf = xmalloc(size);
@@ -646,4 +650,5 @@ ruby_getcwd()
buf = xrealloc(buf, size);
}
+# endif
#else
# ifndef PATH_MAX

Nobu:

Thanks for the response! I applied the specified patch to util.c
however, it doesn't seem to have made a difference. Dir.getwd works
ok, I think the problem is in the ``. I'll keep looking and if I find
something I will be sure to post the fix.

I will remain open to suggestions as I've hunted this problem off and on
for quite awhile. Any suggestions are appreciated.

Regards,
Brad
 
N

nobu.nokada

Hi,

At Wed, 17 Dec 2003 21:07:00 +0900,
Brad said:
Thanks for the response! I applied the specified patch to util.c
however, it doesn't seem to have made a difference. Dir.getwd works
ok, I think the problem is in the ``. I'll keep looking and if I find
something I will be sure to post the fix.

I know the previous patch wouldn't fix the odd behavior, since
it was just for the style of returned value from Dir.getwd.

I doubt that it might be concerned with READ_DATA_PENDING(),
READ_DATA_BUFFERED() etc, however, it would need more
investigation.

* Does File.read method work correctly?
* That behavior occurs with pipe?
 
B

Brad

Clifford said:
Brad said:
Thanks for the reply! I was hoping that it wasn't a VMS only problem.

Directories on VMS are quite odd to those from a MSDOS or Unix world.
In particular, the name of a directory is quite different from the name
of the file containing the directory. I have several hundred lines of C
code somewhere here that does various operations on OpenVMS directories.
To get the directory filename from the directory name you have to handle
the following transformations:
x.y cwd.dir
a:x.y a:000000.dir
[]x.y cwd.dir
a:[]x.y a:000000.dir
[d]x.y [000000]d.dir
a:[d]x.y a:[000000]d.dir
[d.e]x.y [d]e.dir
a:[d.e]x.y a:[d]e.dir

Ugly, but I'm not familiar with how Ruby deals with it.

Clifford:

Thanks for the response! For the most part ruby handles VMS paths
pretty well. I had to make a few tweaks, likely with more on the
way. But the problem is not with the directory...unfortunatly. :)

I know this because, if I run

ruby -e "print Dir.getwd"

The directory will be printed correctly.

I *believe* the problem lies in the implementation of the `` and the
communication between the main ruby program and the invoked ruby
program (via the ``).

Regards,
Brad
 
B

Brad

This said:
Hi,

At Wed, 17 Dec 2003 21:07:00 +0900,


I know the previous patch wouldn't fix the odd behavior, since
it was just for the style of returned value from Dir.getwd.

I doubt that it might be concerned with READ_DATA_PENDING(),
READ_DATA_BUFFERED() etc, however, it would need more
investigation.

* Does File.read method work correctly?
* That behavior occurs with pipe?

Nobu:

I tried using File.read and it worked successfully.
I have also made other experiments which lead me to believe that pipes
work as expected:

`perl cwd.prl` ==> Worked correctly
`@[]cwd.com` ==> Worked correctly (VMS .com files are akin to
.BAT files on MS-DOS)

I've also tried using miniruby and wrapping the call to the ruby script
in perl and DCL (.com file), each of which returned the output:

C==character of a path

C\nC\nC\n

which prints as one would expect:

C
C
C

It seems only to occur when I invoke ruby from ruby.

Regards,
Brad
 
Y

Yukihiro Matsumoto

Hi,

In message "Re: Very odd IO problem"

|I *believe* the problem lies in the implementation of the `` and the
|communication between the main ruby program and the invoked ruby
|program (via the ``).

How does the following work?

ruby -e 'puts `ruby -e "print "hello"`'

matz.
 
B

Brad

Yukihiro said:
ruby -e 'puts `ruby -e "print "hello"`'


matz:

I tried the above example, but it has a syntax error, 3 ".
So, I tried adding a fourth " to balance out the quoting,
ruby didn't complain, but nothing was displayed either.

I also tried a variation on this:

ruby -e 'puts `ruby -e "puts(4)"`'


I think it failed because of the way command line arguments
are parsed. Interesting fact: command line parsing must be
be written by the programmer on VMS. i.e. expanding wild cards
is not automatically handled by the command line interpreter.
The quotes must not have been handled properly; I'll have to
look into this.

E.g. for ruby to handle

ruby.exe script.rb *.c

I had to implement processing of wild cards; Perl on VMS also
shares this fate. I know Perl shares this fate because I based
my command line parsing code on Perls. :/

Hopefully this hasn't been too convoluted.

Regards,
Brad
 
Y

Yukihiro Matsumoto

Hi,

In message "Re: Very odd IO problem"

|I tried the above example, but it has a syntax error, 3 ".
|So, I tried adding a fourth " to balance out the quoting,
|ruby didn't complain, but nothing was displayed either.

Oops, sorry.

|I also tried a variation on this:
|
|ruby -e 'puts `ruby -e "puts(4)"`'
|
|I think it failed because of the way command line arguments
|are parsed. Interesting fact: command line parsing must be
|be written by the programmer on VMS. i.e. expanding wild cards
|is not automatically handled by the command line interpreter.
|The quotes must not have been handled properly; I'll have to
|look into this.

How about replacing Dir.getcwd in the first example with

print "hello"

i.e.

File: [bh.scripts]cwd.rb
print "hello"


A:BH> ruby
p `ruby [bh.scripts]cwd.rb`.dump
puts `ruby [bh.scripts]cwd.rb`

can you try?

matz.
 
B

Brad

This said:
puts `ruby [bh.scripts]cwd.rb`


matz:

No problem. I tried what you asked and here is the
output:



CWD.RB:
print "hello"

A:BH.SCRIPTS> ruby
p `ruby [bh.scripts]cwd.rb`.dump
puts `ruby [bh.scripts]cwd.rb`
Exit
"\"h\\ne\\nl\\nl\\no\\n\""
h
e
l
l
o



Regards,
Brad
 
Y

Yukihiro Matsumoto

Hi,

In message "Re: Very odd IO problem"

|No problem. I tried what you asked and here is the
|output:

Thank you. Do me one more favor.

A:BH.SCRIPTS> ruby
s = open("|ruby [bh.scripts]cwd.rb").read
p s
puts s
 
B

Brad

Yukihiro said:
s = open("|ruby [bh.scripts]cwd.rb").read
p s
puts s


matz:

Ok, here it is:

A:175000> ruby
s = open("|ruby [bh.scripts]cwd.rb").read
p s
puts s
Exit
"h\ne\nl\nl\no\n"
h
e
l
l
o
A:175000>


Your help is greatly appreciated. :)


Regards,
Brad
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top