[Solved] Define path to cat.exe ?

XML, Perl, Python, and other languages can be discussed here, even if it isn't PHP (We might forgive you).

Moderator: General Moderators

Post Reply
fredk
Forum Newbie
Posts: 4
Joined: Sat Dec 13, 2003 1:47 pm

[Solved] Define path to cat.exe ?

Post 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
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

you're using exec() or similar?
exec('C:/cygwin/bin/cat.exe path/to/file');
fredk
Forum Newbie
Posts: 4
Joined: Sat Dec 13, 2003 1:47 pm

Post 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
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post 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 ; )
fredk
Forum Newbie
Posts: 4
Joined: Sat Dec 13, 2003 1:47 pm

Post 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.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post 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
fredk
Forum Newbie
Posts: 4
Joined: Sat Dec 13, 2003 1:47 pm

Post 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
Post Reply