cgi/session , deleting old sessions.



  • 1. Disregard POST data and mod_ruby
    I think I finally found some info though it might be good to post it again. Eric H. wrote: > Can someone point me to how I can retrieve http POST data that is passed > from Apache/mod_ruby to my script? Everything I've found thusfar has > been on the client side of things like submitting data TO a form instead > of retrieving it from one. I'm sure the info is available but I haven't > managed to find it yet. > > Thanks > > Eric
  • 2. using lambda, binding happens immediately?
    Note: parts of this message were removed by the gateway to make it a legal Usenet post. I have this code: require 'test/unit' require 'leapyear' class LeapYearTest < Test::Unit::TestCase def setup @ly = end def LeapYearTest.generate_tests filename = "testdata.dat" file =, "r") file.each_line do |line| year, is_leap = line.split; code = lambda { assert_equal(is_leap.downcase=="true", @ly.isleap?( year.to_i)) } define_method("test_isleap_" + year, code) end file.close end end What I want to know is why when I use define_method("name") {block;} instead of define_method("name", lambda{block}) the binding seems to happen later (after the each_line loop)? Is there a reason behind that? Thanks, Sammy Larbi
  • 3. xml-mapping lib question?
    Hi all, I got a xml looking like this. <VolPoint Strike="10" OptionType="Rr Mkt" Interp="1">-0.015523356673284</VolPoint> I tried to create a ruby class for it which is used by xml-mapping library. class VolPoint include XML::Mapping text_node :Interp, "@Interp", :default_value=>nil text_node :Strike, "@Strike", :default_value=>nil text_node :OptionType, "@OptionType", :default_value=>nil text_node :VolValue, "text()", :default_value=>nil # Does not work here end But this class could not get the text from VolPoint element(last line of code). Could anyone tell me how to get the value out of the VolPoint? Cheers!

cgi/session , deleting old sessions.

Postby Robert Gleeson » Tue, 16 Sep 2008 08:52:07 GMT


I am wondering how I would go about deleting files created by
CGI::Session, there is a huge build up of files in /tmp(everytime a new
session is initiated a new one is created) and I can't think of anyway
(beside a crontab) of deleting them, or I could use the .delete method
supplied by cgi/session but this way i need to count on the user logging
out so i can call .delete, not very efficient either.
I looked into using MemoryStore but the eruby instance doesn't last long

Any help is greatly appreciated,
Posted via  http://www.**--****.com/ 

Similar Threads:

1.[BUG/PATCH] cgi/session.rb, cgi/session/pstore.rb

On Wed, 14 Sep 2005, Ara.T.Howard wrote:

CGI::Session::MemoryStore and CGI::Session::PStore suffer from same issue...
updated patches (in the right order this time):

--- ./cgi/        2005-09-13 20:52:14.000000000 -0600
+++ ./cgi/session.rb    2005-09-13 21:13:22.000000000 -0600
@@ -244,7 +244,7 @@
      #   end
      def initialize(request, option={})
-      @new_session = false
+      @new_session = nil
        session_key = option['session_key'] || '_session_id'
        session_id = option['session_id']
        unless session_id
@@ -381,10 +381,11 @@
          md5 = Digest::MD5.hexdigest(id)[0,16]
         @path = dir+"/"+prefix+md5+suffix
         unless File::exist? @path
-          unless session.new_session
+          unless session.new_session.nil?
              raise CGI::Session::NoSession, "uninitialized session"
           @hash = {}
+          update

@@ -451,7 +452,7 @@
        def initialize(session, option=nil)
         @session_id = session.session_id
          unless GLOBAL_HASH_TABLE.key?(@session_id)
-          unless session.new_session
+          unless session.new_session.nil?
              raise CGI::Session::NoSession, "uninitialized session"
            GLOBAL_HASH_TABLE[@session_id] = {}

--- ./cgi/session/ 2005-09-13 21:07:52.000000000 -0600
+++ ./cgi/session/pstore.rb     2005-09-13 21:18:21.000000000 -0600
@@ -9,7 +9,7 @@
  # persistent of session data on top of the pstore library.  See
  # cgi/session.rb for more details on session storage managers.

-require 'cgi/session'
+require './cgi/session'
  require 'pstore'

  class CGI
@@ -62,7 +62,7 @@
         path = dir+"/"+prefix+md5
         unless File::exist?(path)
-          unless session.new_session
+          unless session.new_session.nil?
              raise CGI::Session::NoSession, "uninitialized session"
           @hash = {}

now i'm noticing that the create of session is not atomic... but that's for
another day.

| email :: ara [dot] t [dot] howard [at] noaa [dot] gov
| phone :: 303.497.6469
| Your life dwells amoung the causes of death
| Like a lamp standing in a strong breeze.  --Nagarjuna

2.Telnet - attempting to initiate a telnet session within an established telnet session

My company builds a product that has a dual slot architecture for
redundancy.  Each slot has 2 significant Ethernet interfaces; one for
network connectivity and one for connectivity between slots.  Only one
of the slots is accessible from the network at a time (the other is
meant to be a backup).  The two slots communicate via a common
Ethernet backplane and each slot has a different IP address (

I am trying to build a script with Ruby that allows me to first telnet
into the active slot using it's network address (easy - mission
accomplished) but then to also telnet into the backup slot over the
Ethernet backplane within the same telnet session.  I want to issue
commands in order to gather data such as uptime, disk usage, etc...

I am getting hung up on the password prompt when trying to connect to
the second slot.  I can't seem to send the password info with carriage
return so I can gain access to the second slot and issue additional

The code I have written is in the testing phase and is clearly not

Here is my code:

require 'net/telnet'

top_node = ARGV[0]

tn = Net::Telnet::new( "Host" => top_node,
                              "Timeout" => 10,
                              "Prompt" => /[$%#>] \z/n)
 tn.login("root", "lab") { |c| print c }
 tn.cmd("date") { |c| print c }
 print ARGV[0]
 print " - "
 tn.cmd("./uptime") { |c| print c }
 test = tn.cmd("ifconfig eth0 | ifconfig eth0 | awk '/inet addr:/
{print $2 }'")

 if test.include?("addr:")
    tnbackup = ""
    tnbackup = ""

 print "\n\nTelnetting to Backup HFM " + "(" + tnbackup + ")\n\n"

 tn.cmd("telnet " + tnbackup + " -l root") { |c| print c }

 tn.waitfor(/Password:\s*/im) { |c| print c }
 tn.cmd("ifconfig eth0 | ifconfig eth0 | awk '/inet addr:/ {print
$2 }'") { |c| print c }
 tn.cmd("exit") { |c| print c }

Has anyone successfully telnet into other devices from within an
established telnet session?  Let me know if I am not clear with my
problem and if I need to clarify it more.

Any help is greatly appreciated.



3.howw to delete session data

4.Help needed with CGI Sessions

5.CGI::Session Question

6. CGI::Session flock still broken?

7. CGI::Session with FastCGI

8. Bug in cgi/session

Return to ruby


Who is online

Users browsing this forum: No registered users and 21 guest