R
rob
Hello, I'm curious if anyone knows of a way to generate an HTML
document based on information gathered on a windows network share?
document based on information gathered on a windows network share?
rob said:Hello, I'm curious if anyone knows of a way to generate an HTML
document based on information gathered on a windows network share?
something like this (if I'm not totally mistaken ..... which is veryFrom my understanding, the code for gathering the data would be
$path "\\network_share\"
opendir($path) \ die "Can't open $path";
@dirs=["other"];
closedir(dir)
print "<a href="\"$path">Test</a>
Am I looking at this in the right direction?
rob said:I'm mostly investigating the possible viability of doing this.
Please
bear with me as I am very much a newbie when it comes to perl.
^^$path "\\network_share\"
Am I looking at this in the right direction?
Ian said:I'd start with
#!perl
use strict;
use warnings;
$path "\\network_share\"
I'm probably over simplifying but ...
1. To assign a value to a variable use the equals sign.
2. Use single quotes unless interpolating variables into text.
3. It is usually prudent to use forward slashes not back slashes.
4. Terminate a statement with a semi-colon.
opendir($path) \ die "Can't open $path";
1. Use the vertical bar for a high precendence "or".
2. For this circumstance, I prefer the word "or" instead.
(there are precedence pitfalls for the unwary)
@dirs=["other"];
You probably need to use the readdir() function here.
closedir(dir)
Missing semi-colon.
print "<a href="\"$path">Test</a>
1. Unescaped superfluous quote after href=.
2. You didn't escape the other quote after the path.
3. No terminating quote.
4. No semi-colon.
You probably want to print the filenames you just read.
Am I looking at this in the right direction?
Yes, but you might need to consult an optician
You might find it helpful to start by writing a tiny program and
actually try seeing what Perl tells you about syntax errors!
There are CPAN modules that simplify reading filenames from a directory.
rob said:That was incredibly helpful.
I do have one more question thought..
I've now got the program reading a specified directory, gathering the
data from the directory and then outputting it to an html file just
fine ... however, I'd like to include the subdirectories that are
located in that directory .... is there a way to do this? Or will I
simply have to write a new section of code for each subdirectory that I
want to include in this report?
rob said:I've now got the program reading a specified directory, gathering the
data from the directory and then outputting it to an html file just
fine ... however, I'd like to include the subdirectories that are
located in that directory .... is there a way to do this? Or will I
simply have to write a new section of code for each subdirectory that I
want to include in this report?
Here's an example of my code ::
my($my_path) = ('c:\\other\\');
opendir (DIR, $my_path) or die "Can't open $my_path";
my(@files) = grep {/.+\.\w{3}$/i} readdir(DIR);
closedir(DIR);
open (MYFILE, '>data.html');
foreach my $filename (files){print MYFILE "$filename\n";}
Michele said:That would be *bitwise* "or". ITYM C<||>.
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.