473,416 Members | 1,806 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,416 software developers and data experts.

Exec() function not doing as I want (OSX)

Howdy,

Recently I switched from a Windows PC to Mac OS-X 10.5 (php v5.2.6) and
I have a little problem with one function within my cd-management script.

For extracting a bit of info from my cd's I have an executable which I
execute with exec():

$discOutput = exec('./discid /dev/rdisk2');

The executable is in the same directory as the php script is in. When I
run the same line from Terminal within that same directory it gives me
the output I want, php doesn't give me any ouput at all.

Asking exec() for output on a basic function like 'ls' does return a
value, so the function is active. I guess somehow I am not pointing to
the discid executable correctly, but I don't see what is wrong.

Can someone tell me what I am doing wrong?

Thanks in advance, Maarten
Sep 19 '08 #1
23 9326
r0g
Maarten wrote:
Howdy,

Recently I switched from a Windows PC to Mac OS-X 10.5 (php v5.2.6) and
I have a little problem with one function within my cd-management script.

For extracting a bit of info from my cd's I have an executable which I
execute with exec():

$discOutput = exec('./discid /dev/rdisk2');

The executable is in the same directory as the php script is in. When I
run the same line from Terminal within that same directory it gives me
the output I want, php doesn't give me any ouput at all.

Asking exec() for output on a basic function like 'ls' does return a
value, so the function is active. I guess somehow I am not pointing to
the discid executable correctly, but I don't see what is wrong.

Can someone tell me what I am doing wrong?

Thanks in advance, Maarten
Well I cant say for sure but I've just switched from Windows to Linux
and had been having some similar problems execing scripts...

Try adding the containing folder to your system path and/or using
absolute path instead of "./" That fixed my problems anyway.

Good luck :-)

Roger.
Sep 19 '08 #2
Maarten wrote:
Howdy,

Recently I switched from a Windows PC to Mac OS-X 10.5 (php v5.2.6) and
I have a little problem with one function within my cd-management script.

For extracting a bit of info from my cd's I have an executable which I
execute with exec():

$discOutput = exec('./discid /dev/rdisk2');

The executable is in the same directory as the php script is in. When I
run the same line from Terminal within that same directory it gives me
the output I want, php doesn't give me any ouput at all.

Asking exec() for output on a basic function like 'ls' does return a
value, so the function is active. I guess somehow I am not pointing to
the discid executable correctly, but I don't see what is wrong.

Can someone tell me what I am doing wrong?

Thanks in advance, Maarten
It could also be a permission problem - is the Apache web server the
owner of the file, or does it have access to the file?

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Sep 19 '08 #3
Well I cant say for sure but I've just switched from Windows to Linux
and had been having some similar problems execing scripts...

Try adding the containing folder to your system path and/or using
absolute path instead of "./" That fixed my problems anyway.
Well, after some technical issues I tried to add the program to the
$PATH so I don't need to specify a location anymore and also I added the
absolute path to the php script.

Both methods work fine in the terminal but within the script nothing is
returned

Maarten
Sep 23 '08 #4
It could also be a permission problem - is the Apache web server the
owner of the file, or does it have access to the file?

Apache is not the owner of the file and as it is located in the same
folder as the php script it, it should have access to it (server is for
localhost use only). According to info of the program provided by osx,
the program can be read by Everyone, Staff, and me. I guess Apache
should have enough privileges to execute the program.

Maarten
Sep 23 '08 #5
Maarten wrote:
It could also be a permission problem - is the Apache web server the
owner of the file, or does it have access to the file?


Apache is not the owner of the file and as it is located in the same
folder as the php script it, it should have access to it (server is for
localhost use only). According to info of the program provided by osx,
the program can be read by Everyone, Staff, and me. I guess Apache
should have enough privileges to execute the program.

Maarten
When I write filesize() and file_exists() it returns the desired values,
so php can get info on the specific executable eventhough it seems to be
invisible to exec().

Maarten
Sep 23 '08 #6
Maarten wrote:
It could also be a permission problem - is the Apache web server the
owner of the file, or does it have access to the file?


Apache is not the owner of the file and as it is located in the same
folder as the php script it, it should have access to it (server is for
localhost use only). According to info of the program provided by osx,
the program can be read by Everyone, Staff, and me. I guess Apache
should have enough privileges to execute the program.

Maarten
Readable and executable are two different things.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Sep 23 '08 #7
Jerry Stuckle wrote:
Maarten wrote:
> It could also be a permission problem - is the Apache web server the
owner of the file, or does it have access to the file?


Apache is not the owner of the file and as it is located in the same
folder as the php script it, it should have access to it (server is
for localhost use only). According to info of the program provided by
osx, the program can be read by Everyone, Staff, and me. I guess
Apache should have enough privileges to execute the program.

Maarten

Readable and executable are two different things.
True, but my knowledge on the permission thing is a bit limited.
However, the permission for the specific file are:
-rwxrwxrwx 1 maarten staff 18176 Sep 19 15:11 discid

I guess this should allow the server to execute the program.

Maarten
Sep 23 '08 #8
>Readable and executable are two different things.

And writable is another different thing.
>True, but my knowledge on the permission thing is a bit limited.
However, the permission for the specific file are:
-rwxrwxrwx 1 maarten staff 18176 Sep 19 15:11 discid

I guess this should allow the server to execute the program.
It is my experience that Apache will refuse to execute any file
that it can write. Excessive (write) permissions are just
as bad as insufficient (execute) permissions.
Sep 23 '08 #9
On Sep 19, 3:35*pm, Maarten <b...@blah.comwrote:
Howdy,

Recently I switched from a Windows PC to Mac OS-X 10.5 (php v5.2.6) and
I have a little problem with one function within my cd-management script.

For extracting a bit of info from my cd's I have an executable which I
execute with exec():

* * *$discOutput = exec('./discid /dev/rdisk2');

The executable is in the same directory as the php script is in. When I
run the same line from Terminal within that same directory it gives me
the output I want, php doesn't give me any ouput at all.

Asking exec() for output on a basic function like 'ls' does return a
value, so the function is active. I guess somehow I am not pointing to
the discid executable correctly, but I don't see what is wrong.

Can someone tell me what I am doing wrong?

Thanks in advance, Maarten
I had a similar issue when runnning a script in linux under apache. It
took awhile for me to figure out I had to "cd" to the directory I
wanted to work in and use an absolute path to the exe that is being
executed. You may want to try something like this:

$discOutput = exec('cd /dev/rdisk2;[fullpathto discid]/discid');

Bill H
Sep 23 '08 #10
Gordon Burditt wrote:
>>Readable and executable are two different things.

And writable is another different thing.
>True, but my knowledge on the permission thing is a bit limited.
However, the permission for the specific file are:
-rwxrwxrwx 1 maarten staff 18176 Sep 19 15:11 discid

I guess this should allow the server to execute the program.

It is my experience that Apache will refuse to execute any file
that it can write. Excessive (write) permissions are just
as bad as insufficient (execute) permissions.


I've just changed the permission of the program to 111. Still, the
program is not executed.

Maarten
Sep 23 '08 #11
Maarten wrote:
Gordon Burditt wrote:
>>>Readable and executable are two different things.

And writable is another different thing.
>>True, but my knowledge on the permission thing is a bit limited.
However, the permission for the specific file are:
-rwxrwxrwx 1 maarten staff 18176 Sep 19 15:11 discid

I guess this should allow the server to execute the program.

It is my experience that Apache will refuse to execute any file
that it can write. Excessive (write) permissions are just
as bad as insufficient (execute) permissions.



I've just changed the permission of the program to 111. Still, the
program is not executed.

Maarten
IIRC, it has to be readable, also. I always use 550 or 555 for executables.

How do you know it's not being executed? Are you displaying errors in
your browser - in your php.ini file you should have:

error_reporting=E_ALL
display_errors=on

And what is the returned value from exec()?

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Sep 23 '08 #12
Jerry Stuckle wrote:
Maarten wrote:
>Gordon Burditt wrote:
>>>>Readable and executable are two different things.

And writable is another different thing.

True, but my knowledge on the permission thing is a bit limited.
However, the permission for the specific file are:
-rwxrwxrwx 1 maarten staff 18176 Sep 19 15:11 discid

I guess this should allow the server to execute the program.

It is my experience that Apache will refuse to execute any file
that it can write. Excessive (write) permissions are just
as bad as insufficient (execute) permissions.



I've just changed the permission of the program to 111. Still, the
program is not executed.

Maarten

IIRC, it has to be readable, also. I always use 550 or 555 for
executables.

How do you know it's not being executed? Are you displaying errors in
your browser - in your php.ini file you should have:

error_reporting=E_ALL
display_errors=on

And what is the returned value from exec()?
Changed the executable's permission to 555, no change

Just double (php.ini and phpinfo() error reporting and display errors
have the correct values. Exec() does not return a value when executed as
below:

$discOutput = exec('/Volumes/Users/maarten/discid dev/rdisk2',
$ooutpuut);

Both $discOutput and $ooutpuut are empty. Same as when I would fill in
some bogus values in the function.

Maarten
Sep 23 '08 #13
Bill H wrote:
On Sep 19, 3:35 pm, Maarten <b...@blah.comwrote:
>Howdy,

Recently I switched from a Windows PC to Mac OS-X 10.5 (php v5.2.6) and
I have a little problem with one function within my cd-management script.

For extracting a bit of info from my cd's I have an executable which I
execute with exec():

$discOutput = exec('./discid /dev/rdisk2');

The executable is in the same directory as the php script is in. When I
run the same line from Terminal within that same directory it gives me
the output I want, php doesn't give me any ouput at all.

Asking exec() for output on a basic function like 'ls' does return a
value, so the function is active. I guess somehow I am not pointing to
the discid executable correctly, but I don't see what is wrong.

Can someone tell me what I am doing wrong?

Thanks in advance, Maarten

I had a similar issue when runnning a script in linux under apache. It
took awhile for me to figure out I had to "cd" to the directory I
wanted to work in and use an absolute path to the exe that is being
executed. You may want to try something like this:

$discOutput = exec('cd /dev/rdisk2;[fullpathto discid]/discid');

Bill H
I changed the code to:

$discOutput = exec('cd /dev/rdisk2; /Volumes/Users/maarten/discid',
$ooutpuut);

Also have I changed the permission of discid to 555. No change, however.
The problem remains. Both returned variable/array are empty.

Maarten
Sep 23 '08 #14
On Sep 23, 3:36*pm, Maarten <b...@blah.comwrote:
Bill H wrote:
On Sep 19, 3:35 pm, Maarten <b...@blah.comwrote:
Howdy,
Recently I switched from a Windows PC to Mac OS-X 10.5 (php v5.2.6) and
I have a little problem with one function within my cd-management script.
For extracting a bit of info from my cd's I have an executable which I
execute with exec():
* * *$discOutput = exec('./discid /dev/rdisk2');
The executable is in the same directory as the php script is in. When I
run the same line from Terminal within that same directory it gives me
the output I want, php doesn't give me any ouput at all.
Asking exec() for output on a basic function like 'ls' does return a
value, so the function is active. I guess somehow I am not pointing to
the discid executable correctly, but I don't see what is wrong.
Can someone tell me what I am doing wrong?
Thanks in advance, Maarten
I had a similar issue when runnning a script in linux under apache. It
took awhile for me to figure out I had to "cd" to the directory I
wanted to work in and use an absolute path to the exe that is being
executed. You may want to try something like this:
$discOutput = exec('cd /dev/rdisk2;[fullpathto discid]/discid');
Bill H

I changed the code to:

* * *$discOutput = exec('cd /dev/rdisk2; /Volumes/Users/maarten/discid',
$ooutpuut);

Also have I changed the permission of discid to 555. No change, however.
The problem remains. Both returned variable/array are empty.

Maarten- Hide quoted text -

- Show quoted text -
Try to go around the problem to narrow it down. Do you have a
different executable that you can put in the same location and use
exec() on it to see if the exec() is working right, if not then you
know that discid should not be the issue, if so then there is
something in discid.

Bill H
Sep 23 '08 #15
On Sep 23, 3:36*pm, Maarten <b...@blah.comwrote:
Bill H wrote:
On Sep 19, 3:35 pm, Maarten <b...@blah.comwrote:
Howdy,
Recently I switched from a Windows PC to Mac OS-X 10.5 (php v5.2.6) and
I have a little problem with one function within my cd-management script.
For extracting a bit of info from my cd's I have an executable which I
execute with exec():
* * *$discOutput = exec('./discid /dev/rdisk2');
The executable is in the same directory as the php script is in. When I
run the same line from Terminal within that same directory it gives me
the output I want, php doesn't give me any ouput at all.
Asking exec() for output on a basic function like 'ls' does return a
value, so the function is active. I guess somehow I am not pointing to
the discid executable correctly, but I don't see what is wrong.
Can someone tell me what I am doing wrong?
Thanks in advance, Maarten
I had a similar issue when runnning a script in linux under apache. It
took awhile for me to figure out I had to "cd" to the directory I
wanted to work in and use an absolute path to the exe that is being
executed. You may want to try something like this:
$discOutput = exec('cd /dev/rdisk2;[fullpathto discid]/discid');
Bill H

I changed the code to:

* * *$discOutput = exec('cd /dev/rdisk2; /Volumes/Users/maarten/discid',
$ooutpuut);

Also have I changed the permission of discid to 555. No change, however.
The problem remains. Both returned variable/array are empty.

Maarten- Hide quoted text -

- Show quoted text -
Also this should not apply to Mac OSX, but on Vista with Xampp, to get
executables to run from the exec() in php, I had to chase down cmd.exe
in the windows\system32 folder and set it to always run as
administrator before any exe's were executable using exec(). Maybe
something similar on the mac?

Bill H
Sep 23 '08 #16
Maarten wrote:
Jerry Stuckle wrote:
>Maarten wrote:
>>Gordon Burditt wrote:
>Readable and executable are two different things.

And writable is another different thing.

True, but my knowledge on the permission thing is a bit limited.
However, the permission for the specific file are:
-rwxrwxrwx 1 maarten staff 18176 Sep 19 15:11 discid
>
I guess this should allow the server to execute the program.

It is my experience that Apache will refuse to execute any file
that it can write. Excessive (write) permissions are just
as bad as insufficient (execute) permissions.


I've just changed the permission of the program to 111. Still, the
program is not executed.

Maarten

IIRC, it has to be readable, also. I always use 550 or 555 for
executables.

How do you know it's not being executed? Are you displaying errors in
your browser - in your php.ini file you should have:

error_reporting=E_ALL
display_errors=on

And what is the returned value from exec()?

Changed the executable's permission to 555, no change

Just double (php.ini and phpinfo() error reporting and display errors
have the correct values. Exec() does not return a value when executed as
below:

$discOutput = exec('/Volumes/Users/maarten/discid dev/rdisk2',
$ooutpuut);

Both $discOutput and $ooutpuut are empty. Same as when I would fill in
some bogus values in the function.

Maarten
Well, if the program can't be executed, you should get an error message
back.

Back to a basic question. How do you know the program is not being
executed?

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Sep 24 '08 #17
Jerry Stuckle wrote:
Maarten wrote:
>Jerry Stuckle wrote:
>>Maarten wrote:
Gordon Burditt wrote:
>>Readable and executable are two different things.
>
And writable is another different thing.
>
>True, but my knowledge on the permission thing is a bit limited.
>However, the permission for the specific file are:
>-rwxrwxrwx 1 maarten staff 18176 Sep 19 15:11 discid
>>
>I guess this should allow the server to execute the program.
>
It is my experience that Apache will refuse to execute any file
that it can write. Excessive (write) permissions are just
as bad as insufficient (execute) permissions.
>
>
I've just changed the permission of the program to 111. Still, the
program is not executed.

Maarten
IIRC, it has to be readable, also. I always use 550 or 555 for
executables.

How do you know it's not being executed? Are you displaying errors
in your browser - in your php.ini file you should have:

error_reporting=E_ALL
display_errors=on

And what is the returned value from exec()?

Changed the executable's permission to 555, no change

Just double (php.ini and phpinfo() error reporting and display errors
have the correct values. Exec() does not return a value when executed
as below:

$discOutput = exec('/Volumes/Users/maarten/discid dev/rdisk2',
$ooutpuut);

Both $discOutput and $ooutpuut are empty. Same as when I would fill in
some bogus values in the function.

Maarten

Well, if the program can't be executed, you should get an error message
back.

Back to a basic question. How do you know the program is not being
executed?
Well, it's hard to be sure since the only thing that it does is reading
the the TOC of a CD an return it. Since it's not enough reading to make
my cd-rom light up and the function returns false, I assume it is not
being executed.

But why it behaves as it does I don't know since other functions such as
ls and the program whois, located in the same directory as discid, are
working fine. Also are the permissions set similar.

Maarten
Sep 24 '08 #18
Bill H wrote:
On Sep 23, 3:36 pm, Maarten <b...@blah.comwrote:
>Bill H wrote:
>>On Sep 19, 3:35 pm, Maarten <b...@blah.comwrote:
Howdy,
Recently I switched from a Windows PC to Mac OS-X 10.5 (php v5.2.6) and
I have a little problem with one function within my cd-management script.
For extracting a bit of info from my cd's I have an executable which I
execute with exec():
$discOutput = exec('./discid /dev/rdisk2');
The executable is in the same directory as the php script is in. When I
run the same line from Terminal within that same directory it gives me
the output I want, php doesn't give me any ouput at all.
Asking exec() for output on a basic function like 'ls' does return a
value, so the function is active. I guess somehow I am not pointing to
the discid executable correctly, but I don't see what is wrong.
Can someone tell me what I am doing wrong?
Thanks in advance, Maarten
I had a similar issue when runnning a script in linux under apache. It
took awhile for me to figure out I had to "cd" to the directory I
wanted to work in and use an absolute path to the exe that is being
executed. You may want to try something like this:
$discOutput = exec('cd /dev/rdisk2;[fullpathto discid]/discid');
Bill H
I changed the code to:

$discOutput = exec('cd /dev/rdisk2; /Volumes/Users/maarten/discid',
$ooutpuut);

Also have I changed the permission of discid to 555. No change, however.
The problem remains. Both returned variable/array are empty.

Maarten- Hide quoted text -

- Show quoted text -

Try to go around the problem to narrow it down. Do you have a
different executable that you can put in the same location and use
exec() on it to see if the exec() is working right, if not then you
know that discid should not be the issue, if so then there is
something in discid.

Bill H
I tried already before to execute the ls command, and that one returns
the directory listings fine. Also did I copy the whois program to the
same directory as discid and that one is also executed nicely from
within php, exec(). Permissions where set the same.

The exec() function is working. But what makes discid different I don't
know. It is working the same as all other programs in the terminal . .
Sep 24 '08 #19
On Sep 24, 10:27*am, Maarten <b...@blah.comwrote:
Bill H wrote:
On Sep 23, 3:36 pm, Maarten <b...@blah.comwrote:
Bill H wrote:
On Sep 19, 3:35 pm, Maarten <b...@blah.comwrote:
Howdy,
Recently I switched from a Windows PC to Mac OS-X 10.5 (php v5.2.6) and
I have a little problem with one function within my cd-management script.
For extracting a bit of info from my cd's I have an executable whichI
execute with exec():
* * *$discOutput = exec('./discid /dev/rdisk2');
The executable is in the same directory as the php script is in. When I
run the same line from Terminal within that same directory it gives me
the output I want, php doesn't give me any ouput at all.
Asking exec() for output on a basic function like 'ls' does return a
value, so the function is active. I guess somehow I am not pointing to
the discid executable correctly, but I don't see what is wrong.
Can someone tell me what I am doing wrong?
Thanks in advance, Maarten
I had a similar issue when runnning a script in linux under apache. It
took awhile for me to figure out I had to "cd" to the directory I
wanted to work in and use an absolute path to the exe that is being
executed. You may want to try something like this:
$discOutput = exec('cd /dev/rdisk2;[fullpathto discid]/discid');
Bill H
I changed the code to:
* * *$discOutput = exec('cd /dev/rdisk2; /Volumes/Users/maarten/discid',
$ooutpuut);
Also have I changed the permission of discid to 555. No change, however.
The problem remains. Both returned variable/array are empty.
Maarten- Hide quoted text -
- Show quoted text -
Try to go around the problem to narrow it down. Do you have a
different executable that you can put in the same location and use
exec() on it to see if the exec() is working right, if not then you
know that discid should not be the issue, if so then there is
something in discid.
Bill H

I tried already before to execute the ls command, and that one returns
the directory listings fine. Also did I copy the whois program to the
same directory as discid and that one is also executed nicely from
within php, exec(). Permissions where set the same.

The exec() function is working. But what makes discid different I don't
know. It is working the same as all other programs in the terminal . .- Hide quoted text -

- Show quoted text -
Is discid sending out the text in a format that the exec() can get
(STDOUT ?)? Can you pipe the results to a text file? In windows I
would use somethign like $this = exec('discid here.txt');

Bill H
Sep 24 '08 #20
Maarten wrote:
Jerry Stuckle wrote:
>Maarten wrote:
>>Jerry Stuckle wrote:
Maarten wrote:
Gordon Burditt wrote:
>>>Readable and executable are two different things.
>>
>And writable is another different thing.
>>
>>True, but my knowledge on the permission thing is a bit limited.
>>However, the permission for the specific file are:
>>-rwxrwxrwx 1 maarten staff 18176 Sep 19 15:11 discid
>>>
>>I guess this should allow the server to execute the program.
>>
>It is my experience that Apache will refuse to execute any file
>that it can write. Excessive (write) permissions are just
>as bad as insufficient (execute) permissions.
>>
>>
>
>
I've just changed the permission of the program to 111. Still, the
program is not executed.
>
Maarten
>

IIRC, it has to be readable, also. I always use 550 or 555 for
executables.

How do you know it's not being executed? Are you displaying errors
in your browser - in your php.ini file you should have:

error_reporting=E_ALL
display_errors=on

And what is the returned value from exec()?
Changed the executable's permission to 555, no change

Just double (php.ini and phpinfo() error reporting and display errors
have the correct values. Exec() does not return a value when executed
as below:

$discOutput = exec('/Volumes/Users/maarten/discid dev/rdisk2',
$ooutpuut);

Both $discOutput and $ooutpuut are empty. Same as when I would fill
in some bogus values in the function.

Maarten

Well, if the program can't be executed, you should get an error
message back.

Back to a basic question. How do you know the program is not being
executed?

Well, it's hard to be sure since the only thing that it does is reading
the the TOC of a CD an return it. Since it's not enough reading to make
my cd-rom light up and the function returns false, I assume it is not
being executed.

But why it behaves as it does I don't know since other functions such as
ls and the program whois, located in the same directory as discid, are
working fine. Also are the permissions set similar.

Maarten
Then I would suspect the program itself is being executed but returning
an invalid return code to exec().

I think you need to look at what the program is doing.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Sep 24 '08 #21
On Sep 24, 10:27*am, Maarten <b...@blah.comwrote:
Bill H wrote:
On Sep 23, 3:36 pm, Maarten <b...@blah.comwrote:
Bill H wrote:
On Sep 19, 3:35 pm, Maarten <b...@blah.comwrote:
Howdy,
Recently I switched from a Windows PC to Mac OS-X 10.5 (php v5.2.6) and
I have a little problem with one function within my cd-management script.
For extracting a bit of info from my cd's I have an executable whichI
execute with exec():
* * *$discOutput = exec('./discid /dev/rdisk2');
The executable is in the same directory as the php script is in. When I
run the same line from Terminal within that same directory it gives me
the output I want, php doesn't give me any ouput at all.
Asking exec() for output on a basic function like 'ls' does return a
value, so the function is active. I guess somehow I am not pointing to
the discid executable correctly, but I don't see what is wrong.
Can someone tell me what I am doing wrong?
Thanks in advance, Maarten
I had a similar issue when runnning a script in linux under apache. It
took awhile for me to figure out I had to "cd" to the directory I
wanted to work in and use an absolute path to the exe that is being
executed. You may want to try something like this:
$discOutput = exec('cd /dev/rdisk2;[fullpathto discid]/discid');
Bill H
I changed the code to:
* * *$discOutput = exec('cd /dev/rdisk2; /Volumes/Users/maarten/discid',
$ooutpuut);
Also have I changed the permission of discid to 555. No change, however.
The problem remains. Both returned variable/array are empty.
Maarten- Hide quoted text -
- Show quoted text -
Try to go around the problem to narrow it down. Do you have a
different executable that you can put in the same location and use
exec() on it to see if the exec() is working right, if not then you
know that discid should not be the issue, if so then there is
something in discid.
Bill H

I tried already before to execute the ls command, and that one returns
the directory listings fine. Also did I copy the whois program to the
same directory as discid and that one is also executed nicely from
within php, exec(). Permissions where set the same.

The exec() function is working. But what makes discid different I don't
know. It is working the same as all other programs in the terminal . .- Hide quoted text -

- Show quoted text -
Google groups ate my reply from earlier it appears. Is that program
sending to STDOUT (I believe that is what exec() looks at)?

How about piping, can you do that in Mac OSX? ( ie $this=exec('discid
here.txt'); ) Does it output to the here.txt?
Bill H
Sep 24 '08 #22
On 24 Sep, 21:50, Bill H <b...@ts1000.uswrote:
On Sep 24, 10:27*am, Maarten <b...@blah.comwrote:
Bill H wrote:
On Sep 23, 3:36 pm, Maarten <b...@blah.comwrote:
>Bill H wrote:
>>On Sep 19, 3:35 pm, Maarten <b...@blah.comwrote:
>>>Howdy,
>>>Recently I switched from a Windows PC to Mac OS-X 10.5 (php v5.2.6) and
>>>I have a little problem with one function within my cd-management script.
>>>For extracting a bit of info from my cd's I have an executable which I
>>>execute with exec():
>>>* * *$discOutput = exec('./discid /dev/rdisk2');
>>>The executable is in the same directory as the php script is in. When I
>>>run the same line from Terminal within that same directory it gives me
>>>the output I want, php doesn't give me any ouput at all.
>>>Asking exec() for output on a basic function like 'ls' does returna
>>>value, so the function is active. I guess somehow I am not pointing to
>>>the discid executable correctly, but I don't see what is wrong.
>>>Can someone tell me what I am doing wrong?
>>>Thanks in advance, Maarten
>>I had a similar issue when runnning a script in linux under apache.It
>>took awhile for me to figure out I had to "cd" to the directory I
>>wanted to work in and use an absolute path to the exe that is being
>>executed. You may want to try something like this:
>>$discOutput = exec('cd /dev/rdisk2;[fullpathto discid]/discid');
>>Bill H
>I changed the code to:
>* * *$discOutput = exec('cd /dev/rdisk2; /Volumes/Users/maarten/discid',
>$ooutpuut);
>Also have I changed the permission of discid to 555. No change, however.
>The problem remains. Both returned variable/array are empty.
>Maarten- Hide quoted text -
>- Show quoted text -
Try to go around the problem to narrow it down. Do you have a
different executable that you can put in the same location and use
exec() on it to see if the exec() is working right, if not then you
know that discid should not be the issue, if so then there is
something in discid.
Bill H
I tried already before to execute the ls command, and that one returns
the directory listings fine. Also did I copy the whois program to the
same directory as discid and that one is also executed nicely from
within php, exec(). Permissions where set the same.
The exec() function is working. But what makes discid different I don't
know. It is working the same as all other programs in the terminal . .-Hide quoted text -
- Show quoted text -

Google groups ate my reply from earlier it appears. Is that program
sending to STDOUT (I believe that is what exec() looks at)?

How about piping, can you do that in Mac OSX? ( ie $this=exec('discid
here.txt'); ) Does it output to the here.txt?

Bill H
| is piping, is redirection.
Sep 25 '08 #23
On Sep 25, 6:31*am, Captain Paralytic <paul_laut...@yahoo.comwrote:
On 24 Sep, 21:50, Bill H <b...@ts1000.uswrote:


On Sep 24, 10:27*am, Maarten <b...@blah.comwrote:
Bill H wrote:
On Sep 23, 3:36 pm, Maarten <b...@blah.comwrote:
Bill H wrote:
>On Sep 19, 3:35 pm, Maarten <b...@blah.comwrote:
>>Howdy,
>>Recently I switched from a Windows PC to Mac OS-X 10.5 (php v5.2..6) and
>>I have a little problem with one function within my cd-management script.
>>For extracting a bit of info from my cd's I have an executable which I
>>execute with exec():
>>* * *$discOutput = exec('./discid /dev/rdisk2');
>>The executable is in the same directory as the php script is in.When I
>>run the same line from Terminal within that same directory it gives me
>>the output I want, php doesn't give me any ouput at all.
>>Asking exec() for output on a basic function like 'ls' does return a
>>value, so the function is active. I guess somehow I am not pointing to
>>the discid executable correctly, but I don't see what is wrong.
>>Can someone tell me what I am doing wrong?
>>Thanks in advance, Maarten
>I had a similar issue when runnning a script in linux under apache. It
>took awhile for me to figure out I had to "cd" to the directory I
>wanted to work in and use an absolute path to the exe that is being
>executed. You may want to try something like this:
>$discOutput = exec('cd /dev/rdisk2;[fullpathto discid]/discid');
>Bill H
I changed the code to:
* * *$discOutput = exec('cd /dev/rdisk2; /Volumes/Users/maarten/discid',
$ooutpuut);
Also have I changed the permission of discid to 555. No change, however.
The problem remains. Both returned variable/array are empty.
Maarten- Hide quoted text -
- Show quoted text -
Try to go around the problem to narrow it down. Do you have a
different executable that you can put in the same location and use
exec() on it to see if the exec() is working right, if not then you
know that discid should not be the issue, if so then there is
something in discid.
Bill H
I tried already before to execute the ls command, and that one returns
the directory listings fine. Also did I copy the whois program to the
same directory as discid and that one is also executed nicely from
within php, exec(). Permissions where set the same.
The exec() function is working. But what makes discid different I don't
know. It is working the same as all other programs in the terminal . ..- Hide quoted text -
- Show quoted text -
Google groups ate my reply from earlier it appears. Is that program
sending to STDOUT (I believe that is what exec() looks at)?
How about piping, can you do that in Mac OSX? ( ie $this=exec('discid
here.txt'); ) Does it output to the here.txt?
Bill H

| is piping, is redirection.- Hide quoted text -

- Show quoted text -
You are right - I meant redirection

Bill H
Sep 25 '08 #24

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Weapons of Mass Destruction | last post by:
Are there any tricks to getting the exec() function to work under Windows 2000 with IIS? PHP v4.0.2 is installed on the server. Thanks, WOMD
3
by: scottmallory | last post by:
I'm a newbie to pthyon and I am creating an app with wxPython. I have 7 tables (more on the way... they are feed from a database) that need to be formatted in a certain way (DataTable() does this)...
1
by: Mosas | last post by:
Dear All, Php has exec function to run system commands and this function return last line of system command result. But in Python I can see only os.system() function to run system command but it...
3
by: henryrhenryr | last post by:
I'm trying to get exec() to work. It's a completely backend system so no security concerns. I want a button in my page to launch a programme on my windows system (for example notepad.exe) really...
9
by: melmack3 | last post by:
Hi I have a big problem with shell commands execution via PHP. I have written a very short PHP script ilustrating the problem: <?php for($i=0;$i<1000;$i++) { exec("test.bat");
1
by: shara | last post by:
Hello there, I am using a code in which i send a variable to a webpage and want to redirect the output to an array.I am using the following code: exec("http:page address?id...
1
by: ryanmhuc | last post by:
I am running PHP 5.1.6 (cli) on Linux. When i use the exec($cmd, $output, $return) command the $output array is always blank if the command had an error in it. There are only values if the command...
0
by: ryanmhuc | last post by:
I have a php script that runs perfect from the command line but when run over the web through apache the exec function has a return status of 1. Safe mode is turned off, the command can be...
3
by: dinek | last post by:
I am trying to call a Matlab file from PHP. I beleive that using exec() I can call the matlab file. But this does not work I tried exec('matlab -r sample'); I also tried the same with the...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.