Hey all..I am trying to make as script , which can import one directory called IP , take all the text files one by one from that directory , and then can give me (using pregmatch or something ) Hostname from each file...
Code is below..
The above code gives me all the file names in the directory in which I am writing script (i.e home/ajd/data/ip.php
It gives me list of files and directories in data directory...
Please help out..
Thanks
Code is below..
Code:
<?php
$dirname = "/home/ajd/IP";
if($handle = opendir($dirname))
{
while(false !== ($filename = readdir($handle))){
echo $filename;
$lines = file($filename);
foreach($lines as $line_num)
{
print_r($lines);
//$var = preg_match('/Host Name(.*)/',$matches);
//print_r($matches);
}
}
closedir($handle);
}
?>
It gives me list of files and directories in data directory...
Please help out..
Thanks
Comment