Directory reading produces differnt files

S

STEPHEN BECKER I V

Hello,
I am running ruby and exploring the different things i have this code

Code:
FileTest.file?("Monkey.txt")?s = File.open("Monkey.txt","w+") :s =
File.new("Monkey.txt","w+")
print File.atime("Monkey.txt"),"\n"
print File.ctime("Monkey.txt"),"\n"
print File.basename("Monkey.txt"),"\n"
print File.dirname("Monkey.txt"),"\n"
print File.expand_path("Monkey.txt"),"\n"
dir = File.expand_path("Monkey.txt")
print File.stat("Monkey.txt"),"\n"
print File.split(File.expand_path("Monkey.txt")),"\n"
print File.new("Monkey.txt").flock(File::LOCK_UN)
files = Dir["*.*"]
files.each {|w| print w, "  "}

So it just creates a file locally called monkey.txt with nothing going
in it. I have the file saved on my desk top c:\documents and
settings\iv\desktop\file.rb when i call it from a .bat file (drag the
rb file in to the bat)

[code for bat]
@echo off
c:\ruby\bin\ruby.exe %1 %2 %3 %4 %5 %6 %7 %8 %9
pause
[/code]

It outputs the file contents of c:\documents and settings\iv
but if i run it from SciTE it will output the documents on my desktop
Is SciTE setting something i don't see?
Becker
 
R

Randy W. Sims

Hello,
I am running ruby and exploring the different things i have this code

Code:

So it just creates a file locally called monkey.txt with nothing going
in it. I have the file saved on my desk top c:\documents and
settings\iv\desktop\file.rb when i call it from a .bat file (drag the
rb file in to the bat)

[code for bat]
@echo off
c:\ruby\bin\ruby.exe %1 %2 %3 %4 %5 %6 %7 %8 %9
pause
[/code]

It outputs the file contents of c:\documents and settings\iv
but if i run it from SciTE it will output the documents on my desktop
Is SciTE setting something i don't see?

SciTE probably sets the current working directory to the directory
containing the script. You should use the complete absolute path to the
file in your script or set the working directory.

Randy.
 
A

Austin Ziegler

Not related to your question:

[code for bat]
@echo off
c:\ruby\bin\ruby.exe %1 %2 %3 %4 %5 %6 %7 %8 %9
pause
[/code]

If you're on Win2000, WinXP, or Win2003, use the following instead:

@echo off
C:\path\to\ruby.exe %*
pause

This way, you will not be limited to nine parameters.

-austin
 

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

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top