Page 1 of 1

[Solved] Define path to cat.exe ?

Posted: Sat Dec 13, 2003 1:47 pm
by fredk
As an exersize in learning I've installed Apache 2, perl, MYSql and PHP on my win XP platform.

I'm having a problem understanding how to get PHP to make use of cat.exe.

Apache error log reports the following:
[Sat Dec 13 12:15:35 2003] [error] [client 127.0.0.1] 'cat' is not recognized as an internal or external command,
[Sat Dec 13 12:15:36 2003] [error] [client 127.0.0.1] operable program or batch file.

I'm gussing that PHP dosen't know that cat.exe is located in:
C://cygwin/bin and I don't know how to define that path or where to do so.

I've searched high and low and most of the documentation I've found relates to specific applications. I think my problem is more configuration related.

Any ideas?

TIA,
Fred K

Posted: Sat Dec 13, 2003 3:36 pm
by volka
you're using exec() or similar?
exec('C:/cygwin/bin/cat.exe path/to/file');

Posted: Sat Dec 13, 2003 4:55 pm
by fredk
Volka, that seems to be the case.
I'm trying to get a script to run. It's called phpgraphy. The portion of the script that seems to be causing the problem follows:

// display .welcome message if it exists

if(is_file($root_dir.$dir.".welcome") && !$display) {
echo "<font color=".$welcomecolor."><pre>";
system("cat \"".$root_dir.$dir.".welcome\"");
/* exec("cat ".$root_dir.$dir.".welcome",$welcome);
for($i=0;$i<sizeof($welcome);$i++)
echo $welcome[$i]."<br>";*/
echo "</pre></font>";
// echo "<br>";
}

It is the first referance to 'cat' in the script.

I suspect that the path to cat.exe is some kind of global value and does not necessarily need to be defined in the script.

Can that be?

Regards,
Fred

Posted: Sat Dec 13, 2003 5:22 pm
by volka
you can either use the absolute path

Code: Select all

system("C:/cygwin/bin/cat.exe "".$root_dir.$dir.".welcome"");
or append C:\cygwin\bin to the enviroment variable PATH
Not quite sure wether it's the same for xp as for w2k but try
right click "my computer" -> properties -> advanced -> environment
then add the path to the systemwide setting of PATH (separated from the others by ; )

Posted: Sun Dec 14, 2003 6:50 am
by fredk
I tried appending C:/cygwin/bin to the path and it didn't work.
Perhaps I should have rebooted?

Putting the full path to cat.exe in the script worked just fine!

Thanks volka.

Posted: Sun Dec 14, 2003 7:39 am
by volka
hm, not sure wether C:/cygwin/bin works
better try C:\cygwin\bin and make sure it's not in your own personal settings but the systemwide. The webserver usually does not run on your account.
Maybe the webserver software must be restarted

Posted: Sun Dec 14, 2003 1:11 pm
by fredk
oops the / was a typo here on the BB. When I appended the path I used \

Just for grins I rebooted and removed the full path from the script and that worked too. I guess XP requires a reboot if you modiify the PATH.

Now I'm having a similar problem with a perl script that makes a call to grep inorder to add the date and time to the bottom of a html page. Seems perl can't find cygwin either.

Fred