Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Simple PHP problem?

Simple PHP problem?
Thread Tools
genevish
Mac Enthusiast
Join Date: Jan 1999
Location: Marietta, GA, USA
Status: Offline
Reply With Quote
Apr 24, 2004, 12:35 AM
 
I have a line in my PHP script:

exec('osascript /Library/Scripts/Info\ Scripts/Current\ iTunes\ Song.scpt');

It seemed to work once, but it hasn't since. Any ideas? I can run this same command from the terminal just fine...
Scott Genevish
scott AT genevish DOT org
     
Diggory Laycock
Professional Poster
Join Date: Oct 2001
Location: London
Status: Offline
Reply With Quote
Apr 24, 2004, 05:27 AM
 
PHP is being run by the user WWW - not you - so it fails when it is run - WWW is not logged in through LoginWindow - and therefore cannot use AppleScript.

(as far as I remember)
     
genevish  (op)
Mac Enthusiast
Join Date: Jan 1999
Location: Marietta, GA, USA
Status: Offline
Reply With Quote
Apr 24, 2004, 11:06 AM
 
Originally posted by Diggory Laycock:
PHP is being run by the user WWW - not you - so it fails when it is run - WWW is not logged in through LoginWindow - and therefore cannot use AppleScript.

(as far as I remember)
Good thinking, but I tried:

sudo -u www osascript /Library/Scripts/Info\ Scripts/Current\ iTunes\ Song.scpt

...from the command line, which runs the command as the www user and it worked. I'll try turning on error checking...
Scott Genevish
scott AT genevish DOT org
     
genevish  (op)
Mac Enthusiast
Join Date: Jan 1999
Location: Marietta, GA, USA
Status: Offline
Reply With Quote
Apr 24, 2004, 11:52 AM
 
OK Diggory, you were essentailly right. The error is:

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

It's related to the fact that the user that Apache runs as, www, does not have a windowserver running, which Applescript needs. Any workaround for this?

Thanks,

-Scott
Scott Genevish
scott AT genevish DOT org
     
Chris O'Brien
Grizzled Veteran
Join Date: Nov 2003
Location: Hebburn, UK
Status: Offline
Reply With Quote
Apr 24, 2004, 02:05 PM
 
what does osascript -l AppleScript -e 'whatever the script is' do?

Just wondering if it's because it can't execute an already written script or because osascript can't function....
Just who are Britain? What do they? Who is them? And why?

Formerly Black Book
     
genevish  (op)
Mac Enthusiast
Join Date: Jan 1999
Location: Marietta, GA, USA
Status: Offline
Reply With Quote
Apr 24, 2004, 02:43 PM
 
It's a simple script that gets the current track from iTunes and saves it t a text file. PHP then parses that text file and displays the result on the page.

I found a workaround by using Recent Tunes, although I'd prefer not to have to run another application...
Scott Genevish
scott AT genevish DOT org
     
philzilla
Occasionally Useful
Join Date: Jun 2001
Location: Liverpool, UK
Status: Offline
Reply With Quote
Apr 24, 2004, 04:23 PM
 
just run the headless version of Kung-Tunes and worry about other things in life.
"Have sharp knives. Be creative. Cook to music" ~ maxelson
     
   
Thread Tools
 
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Top
Privacy Policy
All times are GMT -4. The time now is 10:45 AM.
All contents of these forums © 1995-2017 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.8 © 2000-2017, Jelsoft Enterprises Ltd.,