Computing.Net > Forums > Programming > PHP scripting (not on a webserver)

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

PHP scripting (not on a webserver)

Reply to Message Icon

Name: Shr0Om
Date: March 28, 2006 at 02:10:34 Pacific
OS: Win Xp
CPU/Ram: amd 64 3200
Product: custom
Comment:

Hi,

i have a php script that is supposed to check for duplicate values in a txt/delimited file.
I run the script from console (i have the php.exe and php.dll file in the windows dir).
What i would like to to if possible, is that instead of specifying what file i want to check in the script (tmp.txt), i would like the script to take any file of the format csv, sdv, skv or txt. So, if i paste 10 files in the same dir of the script, it should work on all files 1 after 1. If any errors, it should output the values to "Filename"-Error-Log.xls.
Hope anyone can help.

Copy of source code:

<?
$myFile = "Error-Log.xls";
$fh = fopen($myFile, 'w') or die("can't open file");

$a = file("tmp.txt");
for ($b=0; $b<count($a); $b++)
{
$a[$b] = (int)$a[$b];
}
sort($a);
$old='novalue';
for ($b=0; $b<count($a); $b++)
{
if ($a[$b]===$old)
{
fwrite($fh, "Duplicate value ".$a[$b]."\n");

}
$old=$a[$b];
}
fclose($fh);
?>



Sponsored Link
Ads by Google

Response Number 1
Name: Shr0Om
Date: March 28, 2006 at 04:26:30 Pacific
Reply:

Ok, i made a workaround running the php script withing a batch script..

But if its possible, i still would like to know:]


0

Response Number 2
Name: Michael J (by mjdamato)
Date: March 28, 2006 at 08:28:58 Pacific
Reply:

I usually prefer vbscript for windows based scripts since it is handled natively and has some good file structure controls.

However, there is a PHP script on this page on how to return the contents of a directory as an array (which would be the first step): http://us3.php.net/dir

The script is at the very bottom of the page

Michael J


0

Response Number 3
Name: Shr0Om
Date: March 30, 2006 at 00:42:25 Pacific
Reply:

Thnx:) I'll have a looksie


0

Response Number 4
Name: Michael J (by mjdamato)
Date: March 30, 2006 at 07:35:18 Pacific
Reply:

The following page has an example script (that you can download) which recurses through the C drive and creates a report of all .bat files. You could easily modify it to look only in a certain directory (and subdirectories if you wish) for mutiple file extensions.

Michael J


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: PHP scripting (not on a webserver)

PHP Script and HTML Forms www.computing.net/answers/programming/php-script-and-html-forms/7635.html

Problem running scripts on xp. www.computing.net/answers/programming/problem-running-scripts-on-xp/10796.html

how to search on a site? www.computing.net/answers/programming/how-to-search-on-a-site/8369.html