Maybe not a Ruby question but I still need to know

I'm using windows XP. I save my practice files in my thumb drive -
H:\Ruby\Practice , this directory is added to the path variables (in
Environment Variables), so that when I open command prompt and the
default directory is C:\Documents and Settings\user> , I can run my
problem example1.rb (which is in H:\Ruby\Practice) by typing "example1"
like so:

C:\Documents and Settings\user>example1

and it would run just fine, even if example1.rb is not in the default or
current directory (C:\Documents and Settings\user>).

However, I have another file saved in the same folder as example1.rb (in
the thumb drive), and the code opens a text file (about 18 paragraphs
worth of text). Why is it that I cannot run it directly from
C:\Documents and Settings\user like I did with example1.rb? I have to
go to H:\Ruby\Practice and type in the text file's filename.

Thanks guys!

···

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

what are you saying? that you want"H:\Ruby\Practice\example1.rb" to run when you are in "C:\Documents and Settings\user" ?? if that's what you're asking it can't be done just using the filname! Either you CD into the folder, or provide the full pathname + filename, "H:\Ruby\Practice\example1.rb"

···

On 10-11-06 02:19 AM, Kaye Ng wrote:

I'm using windows XP. I save my practice files in my thumb drive -
H:\Ruby\Practice , this directory is added to the path variables (in
Environment Variables), so that when I open command prompt and the
default directory is C:\Documents and Settings\user> , I can run my
problem example1.rb (which is in H:\Ruby\Practice) by typing "example1"
like so:

C:\Documents and Settings\user>example1

and it would run just fine, even if example1.rb is not in the default or
current directory (C:\Documents and Settings\user>).

However, I have another file saved in the same folder as example1.rb (in
the thumb drive), and the code opens a text file (about 18 paragraphs
worth of text). Why is it that I cannot run it directly from
C:\Documents and Settings\user like I did with example1.rb? I have to
go to H:\Ruby\Practice and type in the text file's filename.

Thanks guys!

--
Kind Regards,
Rajinder Yadav | DevMentor.org | Do Good! ~ Share Freely

GNU/Linux: 2.6.35-22-generic
Kubuntu x86_64 10.10 | KDE 4.5.1
Ruby 1.9.2p0 | Rails 3.0.1

what are you saying? that you want"H:\Ruby\Practice\example1.rb" to run
when you are in "C:\Documents and Settings\user" ?? if that's what
you're asking it can't be done just using the filname! Either you CD
into the folder, or provide the full pathname + filename,
"H:\Ruby\Practice\example1.rb"

Yes I can and I have been doing that for several months now. That's
because I've added "H:\Ruby\Practice" in my PATH VARIABLES

···

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

Does this other file in "H:\Ruby\Practice\" refuse to run at all:

C:>Documents and Settings\me> my-script.rb
'my-script.rb' is not recognized as an internal or external command,
operable program or batch file

Or does it run but raise an exception when it tries to run the code that
opens the text file you mentioned? I ask because I suspect this is an
issue of your "current working directory" being different and the fact that
you are opening this text file using a relative path name.

···

On Sat, Nov 6, 2010 at 9:14 PM, Kaye Ng <sbstn26@yahoo.com> wrote:

what are you saying? that you want"H:\Ruby\Practice\example1.rb" to run
when you are in "C:\Documents and Settings\user" ?? if that's what
you're asking it can't be done just using the filname! Either you CD
into the folder, or provide the full pathname + filename,
"H:\Ruby\Practice\example1.rb"

Yes I can and I have been doing that for several months now. That's
because I've added "H:\Ruby\Practice" in my PATH VARIABLES

--
Kendall Gifford
zettabyte@gmail.com

To Kendall Gifford,

someone answered me in another forum:
The PATH environment variable gives you access to executable files only.
Other file types, such as text files are not treated that way.
To do that you would use the APPEND command which sadly is obsolete now.
You may work around it by creating a CMD file such as a textfile.cmd
containing the commands:

@echo off
notepad H:\Ruby\Practice\textfile.txt

The bad news is you would have to create a CMD file for each text file
you want to open this way.

Cheers!

···

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