Reading only files within a dir

Discussion in 'Ruby' started by Tristan Knowles, Jul 16, 2005.

  1. I am trying to create two html drop downs in a ruby
    script. The first to select a /var/log directory, and
    the second to view a specific file within that
    directory.

    I'm just unsure of how to pass a post variable back
    into the ruby script, or whether there is another way
    to do this?

    My current code is like this:

    =3D=3D=3D=3D=3D=3D=3D=3D
    # List dir names
    puts "<tr><td colspan=3D\"2\"><form action=3D\"\"
    name=3D\"select_dir\" id=3D\"select_dir\" method\"post\">"
    puts "<select name=3D\"select_dir\">"
    Dir.entries(Log_Location).each do |logdir|
    puts "<option>#{logdir}</option>"
    end
    puts "</select>\n<input type=3D\"submit\"
    name=3D\"Submit_Dir\" id=3D\"Submit_Dir\" value=3D\"Change
    Directory\">"
    puts "</form></td></tr>"

    # List File names
    puts "<tr><td colspan=3D\"2\"><form action=3D\"\"
    name=3D\"select_log\" id=3D\"select_log\" method=3D\post\">"
    puts "<select name=3D\"select_log\">"
    logfiles =3D Dir.foreach(Log_Dir) do |logfile|
    puts "<option>#{logfile}</option>"
    end
    puts "</select>\n<input type=3D\"submit\"
    name=3D\"Submit_Log\" id=3D\"Submit_Log\" value=3D\"Select
    Log\">"
    puts "</form></td></tr>"
    =3D=3D=3D=3D=3D=3D=3D=3D

    So, i need to pass the post variable from the select
    box for the dir to the select box below, and from
    there onto my script below to actually view the
    contents (already have the last part working, using a
    normal variable).

    Also, is there any different between Dir.entries and
    Dir.foreach? Isn't Dir.foreach the same as
    Dir.entries("/dir").each?


    Thanks.
    Tristan


    =09
    ___________________________________________________________=20
    How much free photo storage do you get? Store your holiday=20
    snaps for FREE with Yahoo! Photos http://uk.photos.yahoo.com
    Tristan Knowles, Jul 16, 2005
    #1
    1. Advertising

  2. Re: Reading only files. Renamed => Passing/reading POST variables

    Sorry, terrible subject description, I was thinking of
    something different and then realised what my main
    problem actually was, but forgot to change the subject :p.


    =09
    =09
    =09
    ___________________________________________________________=20
    Yahoo! Messenger - NEW crystal clear PC to PC calling worldwide with voic=
    email http://uk.messenger.yahoo.com
    Tristan Knowles, Jul 16, 2005
    #2
    1. Advertising

  3. Passing/reading POST variables

    Ahh. So this one needs CGI.

    I will have a play with cgi then and see how things
    go.



    =09
    =09
    =09
    ___________________________________________________________=20
    Yahoo! Messenger - NEW crystal clear PC to PC calling worldwide with voic=
    email http://uk.messenger.yahoo.com
    Tristan Knowles, Jul 16, 2005
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?UnVkeQ==?=

    Sub Dir, Virtual dir, what do I use?

    =?Utf-8?B?UnVkeQ==?=, Jun 12, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    411
    =?Utf-8?B?UnVkeQ==?=
    Jun 12, 2005
  2. Matthew Denner
    Replies:
    1
    Views:
    158
  3. Kga Agk
    Replies:
    2
    Views:
    138
    Kga Agk
    Jun 29, 2009
  4. Nick Gnedin
    Replies:
    2
    Views:
    148
  5. MRAB
    Replies:
    0
    Views:
    112
Loading...

Share This Page