Build an iTunes Remote Control
Subject:   Doesn't work
Date:   2005-03-19 09:56:20
From:   ptwobrussell
Response to: Doesn't work

I'd like to help you this working, but need some more information. If you will provide answers to the following questions, I think that'll be a good start.

Specifically, in your directory containing all of the perl scripts, type "ls -al" and paste the output into "pre" tags in your follow up. That provides full information about file permissions.

If you type http://localhost in your browser, do you get the default apache page?

If you type http://YOUR-IP-ADDRESS in your browser, do you get the same default page?

If you try to run a very simple Perl script like the one below, do you get it to display the text you expect from the command line?

When you try it in your browser, what happens?
What is the exact URL you're using to try and access in it?
What directory are you storing the file into on your local disk (should probably be /Library/WebServer/CGI-Executables/)?


print "Content-type: text/vnd.wap.wml\n\n";
print "<html><head><title>hello there</title></head>\n";
print "<body>how are ya doin'?</body></html>\n";

I'll check back here periodically. Keep me updated; let's get it working.

Full Threads Oldest First

Showing messages 1 through 12 of 12.

  • Doesn't work
    2005-03-19 10:31:40  Cool6324 [View]

     total 200
    drwxrwxr-x 23 parisbut www 782 19 Mar 12:25 .
    drwxrwxr-x 5 root admin 170 18 Mar 19:43 ..
    -rw-rw-rw- 1 parisbut admin 12292 19 Mar 12:25 .DS_Store
    -rwxr-xr-x 1 parisbut parisbut 265 28 Feb 20:08
    -rwxr-xr-x 1 parisbut parisbut 980 25 Feb 22:31 FastForward.scpt
    -rwxr-xr-x 1 parisbut parisbut 263 28 Feb 20:08
    -rwxr-xr-x 1 parisbut parisbut 1018 25 Feb 22:41 MuteUnMute.scpt
    -rwxr-xr-x 1 parisbut parisbut 265 28 Feb 20:08
    -rwxr-xr-x 1 parisbut parisbut 984 25 Feb 22:30 PlayPause.scpt
    -rw-r--r-- 1 parisbut parisbut 1137 27 Feb 19:18 README
    -rwxr-xr-x 1 parisbut parisbut 264 28 Feb 20:08
    -rwxr-xr-x 1 parisbut parisbut 5794 27 Feb 20:37 RandomTrack.scpt
    -rwxr-xr-x 1 parisbut parisbut 259 28 Feb 20:09
    -rwxr-xr-x 1 parisbut parisbut 974 25 Feb 22:31 Rewind.scpt
    -rwxr-xr-x 1 parisbut parisbut 263 28 Feb 20:09
    -rwxr-xr-x 1 parisbut parisbut 1038 25 Feb 22:36 VolumeDown.scpt
    -rwxr-xr-x 1 parisbut parisbut 261 28 Feb 20:09
    -rwxr-xr-x 1 parisbut parisbut 1036 26 Feb 00:30 VolumeUp.scpt
    -rwxr-xr-x 1 parisbut parisbut 217 27 Feb 19:19 hello.wml
    -rwxr--r-- 1 parisbut parisbut 1027 27 Feb 19:17 iTunesRemoteControlDaemon.scr
    -rwxr-xr-x 1 parisbut parisbut 159 26 Feb 01:29
    -rwxr--r-- 1 parisbut parisbut 909 27 Feb 19:19 killRemoteControlDaemon.scr
    -rw-r--r-- 1 parisbut parisbut
    625 27 Feb 20:36 menu

    Local host works, file is promted to download in webrowser. I'm running it from /Library/WebServer/CGI-Executables/. When I use my IP I get the same defualt page. Thank you For Your Help
    • Matthew Russell photo Doesn't work
      2005-03-19 10:45:43  Matthew Russell | O'Reilly AuthorO'Reilly Blogger [View]

      So to clarify, when you say "file is promted to download in webrowser", you are referring to the simple perl file I pasted in to my previous reply? i.e. you get a prompt to download the actual perl file?

      What URL are you typing in exactly? Is it http://localhost/cgi-bin/ ? (The cgi-bin part is important).

      If you have modified /etc/httpd/httpd.conf recently, did you remember to stop and restart apache via your System Preferences/Sharing/Personal Web Sharing? If not, your changes weren't updated despite what it may appear. Stop and restart to be sure.

      We're narrowing it down. Don't give up!

      • Doesn't work
        2005-03-19 13:14:52  Cool6324 [View]

        Yes I am prompted to download the actual perl file.

        I'm accessing the files http://localhost(or IP):81/cgi-bin/

        :81 because my ISP blocks 80, and I have edited the httpd.conf to use 81. Not using a router either.

        I'm also using my phone, as well as Opera(WAP). The Page with the links for or to commands does show. When I press a command it doesn't work. ie. Play doesn't work

        I have retarted apache over and over. Still nothing.
        • Matthew Russell photo Doesn't work
          2005-03-19 13:47:11  Matthew Russell | O'Reilly AuthorO'Reilly Blogger [View]

          So when you type http://localhost:81/cgi-bin/ into your web browser (for the simple perl file I pasted in earlier that simply printed a line of text, you get a download option instead of getting a simple webpage? This is expected because the content type is specified to be "Content-type: text/vnd.wap.wml"--which your browser on your computer can't understand (but your phone or a WAP emulator can understand; see page one of the article). Try replacing that line with "Content-type: text/html\n\n" and your browser should then be able to display it. If this checks out, CGI is working.

          So the first step thing to do is to use a wap emulator and get your file to display for you...but based on your comment that "The Page with the links for or to commands does show", this is already happening? (Otherwise, you wouldn't be getting that menu.) If this is the case, the page containing the menu is WAP content served with perl.

          Once your server is configured to process the perl scripts and serve you wap content (which it appears to be), you can then start up the background daemon and try to get the iTunes stuff working. Given that the CGI is working, the only other thing that wouldn't be is your background daemon.

          You are firing up the background daemon, and have verified that the file it expects to read ( /tmp/iTunesRemoteControl) does exist? If perl is rendering the menu for you, it should also be writing that file to the /tmp directory.

          If I've misunderstood anything you've said, clear it up and let's go from there.

          • Doesn't work
            2005-03-19 14:50:19  Cool6324 [View]

            I am able to see the text in my regular web broswer when I chanhe the content type.

            I am able to see the page with WAP.

            How do I start the backrond daemon? I dropped file into terninmal and the scripts started working, but now it just stoped. I'm not sure what command I used if any to get it to start.

            and tmp/itunesRemoteControl does exist, the file s their.
            • Matthew Russell photo Doesn't work
              2005-03-19 14:59:57  Matthew Russell | O'Reilly AuthorO'Reilly Blogger [View]

              This might be a good time to review the usage header in the daemon script and walk through it once or twice to understand how it does its business. You just start it like any other script only you might find it convenient to end it with an ampersand so it doesn't lock your terminal and so you don't have to keep an extra window open.

              If you type "ps -aux" in a terminal, you'll get a list of everything running, and the daemon should be there if it's running. This is the same technique that the kill script uses to find it and kill it whenever you want to shut it down or restart it. Take a look at the latter part of page 2 in the article and checkout the README file included with the scripts.

              I think you should be up and running now. Thanks for sticking with it.

              • Doesn't work
                2005-03-19 15:15:19  Cool6324 [View]

                It still isn't working. Should I place a command before the file in terinmal before running, I dont see it in the lists of running items.
                • Matthew Russell photo Doesn't work
                  2005-03-19 15:22:22  Matthew Russell | O'Reilly AuthorO'Reilly Blogger [View]

                  From the header of the daemon script:

                  Usage: prompt$./iTunesRemoteControlDaemon.scr &

                  So what this assumes is that you're in the same directory as this script (and that you've set it to be executable with "chmod u+x"). Just like any other script, when you type in ./someScriptName, it will execute if it's executable. Placing the ampersand should return your prompt to you. At that point, if you type in "ps -aux | grep iTunesRemoteControlDaemon.scr", you should see it without having to filter through anything.

                  Does that work for you?


                  • Doesn't work
                    2005-03-19 15:31:10  Cool6324 [View]

                    Sorry for the noob questions what's ampersand and where should I write that? Do you have AIM? If so mines is AIM: Seanpaul316
                    • Matthew Russell photo Doesn't work
                      2005-03-19 15:36:44  Matthew Russell | O'Reilly AuthorO'Reilly Blogger [View]

                      Ampersand is "&" --the thing that's in the usage line that sets the script to run in the background. It's a standard terminal thing.

                      Try skipping the ampersand for now. Just get the script to run. If you run the script and it keeps your prompt, it's running. Open up another terminal window and go about doing other things. When you're satisfied that things are running, you can use the ampersand and have one less window open.

                      • Doesn't work
                        2005-03-19 15:58:12  Cool6324 [View]

                        Works great, I just restarted and it ran script again, works good. Will this automatically work after a restart?

                        BTW, I'm using a Motorola i730, Nextel, with basic WAP service. Works nice.

                        TIP: When you want to use the same command more than once, ie. Fast Foward it's better to use the reload button.

                        And last, THANKZ!!! I also learned alot about the way the terinmal works.