Hey guys,
Ok, all I want to be able to do is go to a directory on my server, using a cgi script, to search a list of files.
The dir is determined by a form the user fills out. I wat to search the files and then return data. What command will open the dir?
Here is some of my code:
#!/usr/bin/perl print "Content-type: text/html\n\n"; require("cgi-lib.cgi"); &ReadParse; @stuff = ""; $i = 0; foreach $key (keys %in) { @stuff[$i] = "$in{$key}"; $i = $i + 1; } chomp @stuff; $site = @stuff[4]; $year = @stuff[1]; $month = @stuff[5]; $day = @stuff[6]; $star = @stuff[2]; $var = @stuff[0]; $date = $year . $month . $day; $dir = $site . $date; #opendir DIR, "/www2/hardwiredsolutions.com/concam/$site/$dir" or die +"\nError opening directory"; @filecheck = <*.txt>; foreach $file (@filecheck) { open FILE, "$file" or die "\nError reading file(1)"; @lines = <FILE>; close FILE; open FILE, "$file" or die "\nError reading file(2)"; foreach $line (@lines) { @time = unpack "a26a4a2a*", $line; @words = unpack "a6a7a5a4a4a3a6a6a10a9a10a*", $line; s/^\s+// for @time; s/^\s+// for @words; if (@time[1] eq "GST") { chomp @time[3]; print "@time[3]"; } if (@words[1] eq $star) { print "@words[$var+1]<br>"; } } } print <<WEB_PAGE; <html> <title>Graph the Night Sky!</title><h1>Graph:</h1><hr> You researched $star, on $date, at $site, for $var. </html> WEB_PAGE
The files I need to access are in a directory like this: kp/kp021020/files_to_search. The dir depends on which file the user enters in the form.
Thanx as always,
Dushu

In reply to open dir by dushu

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.