image
image

Go Back   macosx.com > Mac Help Forums > Mac OS X Server

Reply
 
Thread Tools
  #1  
Old July 26th, 2007, 02:53 PM
Registered User
 
Join Date: Jan 2006
Posts: 121
Thanks: 0
Thanked 0 Times in 0 Posts
Moptop is on a distinguished road
Php, Exec();, and iTunes.

Im looking for a terminal command that will return the current song / artist playing on my computer's iTunes. I intend to use it with Php.
Reply With Quote
  #2  
Old July 26th, 2007, 04:01 PM
macbri's Avatar
Mac (r)evolution
 
Join Date: Jun 2005
Location: Ireland
Posts: 251
Thanks: 1
Thanked 0 Times in 0 Posts
macbri is on a distinguished road
tuaw.com has exactly what you're looking for. Rather than put the command in a an executable script as they demonstrate, you could just use the "osascript" command directly in an exec() call. See:

http://www.tuaw.com/2007/04/02/termi...-command-line/
Reply With Quote
  #3  
Old July 26th, 2007, 04:17 PM
Giaguara's Avatar
Chmod 760
 
Join Date: Nov 2002
Location: ~
Posts: 7,543
Thanks: 0
Thanked 8 Times in 8 Posts
Giaguara has a spectacular aura aboutGiaguara has a spectacular aura about
Or iTunes info to Terminal as Applescript
http://dougscripts.com/itunes/script...page=1#iscroll
This might be useful too
http://www.bombaydigital.com/arenared/2003/10/11/1
__________________
MacBook Pro + Mac mini | Newton 2000 | @Work : Dell D620 & 2x20" + a lot of Macs | Workstation, VC & Fusion
Twenty years from now you will be more disappointed by the things that you didn't do than by the ones you did do.
~ Samuel Clemens | Rants | Photos
Reply With Quote
  #4  
Old July 26th, 2007, 05:08 PM
Registered User
 
Join Date: Jan 2006
Posts: 121
Thanks: 0
Thanked 0 Times in 0 Posts
Moptop is on a distinguished road
Hm, it works in the terminal (Thanks!) but doesn't work in php..

Im doing - <?php exec("./nowplaying"); ?> and have tried <?php echo exec("./nowplaying"); ?>

(Exec has worked for other commands.)



Edit: Nvm, got it working. Had to put the nowplaying file in my sites folder. Thanks!

Last edited by Moptop; July 26th, 2007 at 05:17 PM.
Reply With Quote
  #5  
Old July 27th, 2007, 12:39 PM
Registered User
 
Join Date: Jan 2006
Posts: 121
Thanks: 0
Thanked 0 Times in 0 Posts
Moptop is on a distinguished road
Ok, Im back. It stopped working after I messed with httpd.conf. What could I of screwed up? Everything else in PHP still works... Other commands still work in exe() too...

I had removed some virtual hosts stuff I had added in awhile ago, I even tried using the default httpd.conf, but no luck...

Last edited by Moptop; July 27th, 2007 at 02:03 PM.
Reply With Quote
  #6  
Old July 28th, 2007, 09:14 AM
macbri's Avatar
Mac (r)evolution
 
Join Date: Jun 2005
Location: Ireland
Posts: 251
Thanks: 1
Thanked 0 Times in 0 Posts
macbri is on a distinguished road
Have you altered your php.ini file also? Try having PHP report everything (notices and warnings as well as errors) by setting error_reporting in your php.ini file:

Code:
error_reporting = E_ALL
then restart the web server.

Note that you can also test PHP scripts with the "php" command. Say your script is "run.php", you could do:

Code:
php run.php
You might find it easier to track down errors, warnings etc. this way.
Reply With Quote
  #7  
Old July 28th, 2007, 09:51 AM
Registered User
 
Join Date: Jan 2006
Posts: 121
Thanks: 0
Thanked 0 Times in 0 Posts
Moptop is on a distinguished road
No, I haven't altered my php.ini. I checked it now, error reporting is already at that.

I tried that in the terminal, and got this...

39:44: syntax error: Expected “then”, etc. but found identifier. (-2741)

But my php script doesn't have nearly 39 lines? Could it be referring to the other thingy (nowplaying) ?
Edit: Never mind about that, I didn't open itunes. (the nowplaying script requires that.)


So, its working fine in the terminal, but not apache? Does the terminal php use mac's default php? Because I have php5.2.2 from Here.
Reply With Quote
  #8  
Old July 28th, 2007, 10:03 AM
macbri's Avatar
Mac (r)evolution
 
Join Date: Jun 2005
Location: Ireland
Posts: 251
Thanks: 1
Thanked 0 Times in 0 Posts
macbri is on a distinguished road
Quote:
Originally Posted by Moptop View Post
So, its working fine in the terminal, but not apache? Does the terminal php use mac's default php? Because I have php5.2.2 from Here.
Yes, /usr/bin/php is the default PHP. You'd have to invoke php from the command line as follows:

Code:
/usr/local/php5/bin/php somescript.php
Reply With Quote
Reply

Thread Tools

Posting 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
Trackbacks are Off
Pingbacks are Off
Refbacks are Off
Forum Jump


All times are GMT -5. The time now is 06:32 PM.


Mac Support® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0
Copyright 2000-2008 DigitalCrowd, Inc.