Hi guys!
I have the following Perl script that works fine.
What Id like to do with it is:
By utilizing my current perl code, use PHP to:
1) Build a form somehow where I could manually enter the name of the computer system list (instead of hard coding into my script..currently set to list.xt)
2) Click a Run button to execute the script
3) Write the output to a browser window, maybe in a 3 column window, eg. 1 for notexist.txt, 1 for olderthan2.txt", the other for recent.txt Here is the perl code:
--------------------------
----------
----------
----------
----------
----------
------- script.pl
#!/usr/bin/perl -w
use strict;
use warnings;
open(NOTEXIST, ">notexist.txt") or die "Can not create notexist: $!\n";
open(OLD, ">olderthan2.txt") or die "Can not create olderthan2: $!\n";
open(RECENT, ">recent.txt") or die "Can not create recent: $!\n";
open(LIST,"<list.txt") or die "Can not open list: $!\n";
while (my $server=<LIST>) {
system("net use s: \\$server\ipc\$");
if(!-e 's:\password.txt') {
print NOTEXIST "$server doesnt exist\n";
}
elsif(-M 's:\password.txt' > 2) {
print OLD "$server " . localtime( (stat('s:\password.txt'))[
9] ) . "\n";
}
else {
print RECENT "$server " . localtime( (stat('s:\password.txt'))[
9] ) . "\n";
}
}
close(LIST);
close(RECENT);
close(OLD);
close(NOTEXIST);
--------------------------
----------
----------
----------
----------
----------
----------
-------- End of script.
So, in the above, instead of displaying the results in:
open(NOTEXIST, ">notexist.txt") or die "Can not create notexist: $!\n";
open(OLD, ">olderthan2.txt") or die "Can not create olderthan2: $!\n";
open(RECENT, ">recent.txt") or die "Can not create recent: $!\n";
the results could appear in a browser.
Any help greatly appreciated.
Start Free Trial