Page 1 of 1

Integrating Bash with PHP

Posted: Thu Jan 28, 2010 7:57 am
by james2010
Hi, I'm running php 5.3 on windows. I've recently downloaded the GNU Bash shell for windows. I made an example bash file and can run it through the command prompt. I'm trying to get it to run through a web page using "shell_exec".

The instructions for installing bash tell me to add the bash.exe path to my classpath setting, create a home directory and then set the environmental variable HOME to point to it. I'm already lost at this point. Can someone tell me how you add bash.exe to my classpath setting and the proper way to create a home directory?

I know shell_exec works because I can call windows processing and it works just fine. For example

Code: Select all

 
$result = shell_exec('cmd version');
 
results in:

Code: Select all

 
Microsoft Windows XP [Version 5.1.2600] (C) Copyright 1985-2001 Microsoft Corp. C:\Program Files\Apache Software Foundation\Apache2.2\htdocs>
 
Thanks

James

Re: Integrating Bash with PHP

Posted: Thu Jan 28, 2010 9:48 am
by AbraCadaver
You really shouldn't have to do either one of these. Maybe the home dir, but I don't think so. Just do it like this:

Code: Select all

$result = exec('x:/path/to/bash.exe x:/path/to/your/script.sh', $output);
It is going to be a pain to get shell_exec() to use bash on windows I think.

Re: Integrating Bash with PHP

Posted: Thu Jan 28, 2010 10:04 am
by james2010
Thanks!

Your correct, you don't need either. Your example worked great.

James