Dir.mkdir fails

J

Jesper Olsen

From a mod_ruby cgi_script I try to use

Dir.mkdir("mydir")

to create a new directory via a web application.

For some reason this fails - this is at $SAFE=1
I tried untaint on the mkdir argument, but it makes
no difference.

How can I create directories in this situation?

Cheers
Jesper
 
J

Jesper Olsen

How is it failing? What is the error being reported or exception
being thrown? Is it possible that you're trying
to create the directory underneath a directory that doesn't exist?
As long as the argument is untainted, Dir.mkdir should be allowed at
$SAFE == 1.

-Mark
Ahm...I forgot that the cgi process did not have my usual file permissions.

That's the problem with ruby cgi scripts - they give you no feedback when
they fail.

The python cgi module has a very useful "debug" mode, which can tell you
exactly where your script fails. Of course you only enable this while
developing - you don't want the script to be viewable otherwise.
I don't think there is anything like that for ruby?

Cheers
Jesper
 
J

Jesper Olsen

Sure they do - just not to the browser. It goes to the web server's
error log. If you want errors to go to the browser, you can just
wrap the whole thing in a big begin/rescue block:

begin
... entire CGI goes here
rescue
puts "Content-Type: text/plain"
puts
puts "Error #{$!}: #{$!.backtrace}"
end

cgi.rb or mod_ruby may very well have something to do this for you;
I don't know them well.

-Mark
Thanks - I will try that.
Jesper
 

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

Staff online

Members online

Forum statistics

Threads
474,141
Messages
2,570,817
Members
47,361
Latest member
eitamoro

Latest Threads

Top