Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

shell command not working

Status
Not open for further replies.

georgeocrawford

Technical User
Aug 12, 2002
111
GB
Hi,

In my PHP script, I want to call a shell function I have added to /bin. It's called 'aliascheck', and simply checks if a given file is an OS X format alias.

If I type this in the terminal:

Code:
shell>aliascheck /path/to/the/file

the Terminal prints this:

Code:
/path/to/the/file -> /where/the/alias/points/to

However, in my php script, when I run:

Code:
$path = '/path/to/the/file';
$is_alias = shell_exec('aliascheck ' . $path);
echo $is_alias;

I get no output.

Strange, as I get outputs from other functions.

The end of the shell script reads as follows:

Code:
    if [ $? -eq 0 ]; then
      if [ ! -z "$linksource" ]; then
        echo "\"${1}\" -> \"${linksource}\""
      fi
    fi

Do I need to modify this to get an output to shell_exec?

Thanks

______________________

George
 
If I run:

Code:
die(shell_exec('aliascheck /path/to/an/alias/file 2>&1'));

in a php script, it prints:

Code:
INIT_Processeses(), could not establish the default connection to the WindowServer.

I'm running OS X 10.3.

Can someone please help me???????

______________________

George
 
Im afraid I dont know enough about shell scripting or OS X.
There doesn't seem to be a problem, that I can see, with your php code.
Try putting an echo statement in so that you know that the php code is being executed properly
eg:
Code:
$path = '/path/to/the/file';
$is_alias = shell_exec('aliascheck ' . $path);
echo "Shell exec returned: $is_alias";

 
tried that - sorry.

It's a UNIX thing I think.
Code:
 INIT_Processeses(), could not establish the default connection to the WindowServer.
is an error to do with which user I run the shell script as, I think.

Thanks anyway!

______________________

George
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top