I was wondering if there’s a way to make a web page (generated in Ruby) with
a link which, when clicked, would send itself… not the generated page, but
the actual page-generating Ruby program, the whole .rbx file.
I can’t figure out any easy way to do this… any thoughts?
send the appopriate header and puts script. Theres a variable that contains the
name of the script, but I can recall what it is right now.
···
On Sat, Dec 14, 2002 at 02:27:03AM +0900, Chris Pine wrote:
Hello,
I was wondering if there’s a way to make a web page (generated in Ruby) with
a link which, when clicked, would send itself… not the generated page, but
the actual page-generating Ruby program, the whole .rbx file.
I can’t figure out any easy way to do this… any thoughts?
I was wondering if there’s a way to make a web page (generated in Ruby) with
a link which, when clicked, would send itself… not the generated page, but
the actual page-generating Ruby program, the whole .rbx file.
Is it called via CGI?
puts “Content-type: text/plain”
puts
IO.foreach(ENV[‘SCRIPT_FILENAME’]) do |l|
print l
end
Do that if a certain CGI parameter in the query string is set.
What should I use instead of ENV[‘SCRIPT_FILENAME’] if the script is not
necessarily called via CGI (instead, via the shell or using mod_ruby)?
···
–
“Note that if I can get you to “su and say” something just by asking,
you have a very serious security problem on your system and you should
look into it.”
– (By Paul Vixie, vixie-cron 3.0.1 installation notes)
At Sat, 14 Dec 2002 02:27:03 +0900, Chris Pine wrote:
I was wondering if there’s a way to make a web page (generated in Ruby) with
a link which, when clicked, would send itself… not the generated page, but
the actual page-generating Ruby program, the whole .rbx file.
I can’t figure out any easy way to do this… any thoughts?
I was wondering if there’s a way to make a web page (generated in Ruby) with
a link which, when clicked, would send itself… not the generated page, but
the actual page-generating Ruby program, the whole .rbx file.
goodfiles = [‘scriptone.rbx’,‘foo.rbx’,‘bar.rbx’,‘baz.rbx’]
if goodfiles.index(filename,‘r’)
fd = open(filename)
puts fd.readlines
fd.close
else
puts “You do not have permission to read that file”
end
Then in your scripts
foo.rbx
…
…
puts “<a href="putfile.rbx?filename=$0">Source code to this file”
…
i put this simple test at the front of the main body of the script:
···
On Friday, December 13, 2002, at 12:27 , Chris Pine wrote:
Hello,
I was wondering if there’s a way to make a web page (generated in Ruby)
with
a link which, when clicked, would send itself… not the generated
page, but
the actual page-generating Ruby program, the whole .rbx file.
I can’t figure out any easy way to do this… any thoughts?
Chris
–
cgi = CGI.new ## or whatever CGI library you use
if cgi.has_key? ‘source’
out = Array.new
out << “Content-type: text/plain\n\n”
File.open $0, ‘r’ do |file|
out << file.read
end
puts out
exit
end
when i want to show the source, simply load the page with ‘source’ as
the cgi argument:
At Sat, 14 Dec 2002 02:27:03 +0900, > Chris Pine wrote:
I was wondering if there’s a way to make a web page (generated in Ruby) with
a link which, when clicked, would send itself… not the generated page, but
the actual page-generating Ruby program, the whole .rbx file.
I can’t figure out any easy way to do this… any thoughts?
–
====================================
Ara Howard
NOAA Forecast Systems Laboratory
Information and Technology Services
Data Systems Group
R/FST 325 Broadway
Boulder, CO 80305-3328
Email: ahoward@fsl.noaa.gov
Phone: 303-497-7238
Fax: 303-497-7259
====================================
…
…
puts “<a href="putfile.rbx?filename=$0">Source code to this file”
…
My bad, that should be #{$0} otherwise it won’t get eval’d.
You might want to put that into a variable at the very start of the
filename, as $0 might be overwritten by regexps.
myfilename=$0
…
puts “<a href="putfile.rbx?filename=#{myfilename}">Source code to this
file”
…