Xrns-php Using Bash On Os X

EDIT: MAC OS X Leopard (10.5) has PHP 5.2.x out of the box. If you are using Leopard you can download the scripts (or do a CVS checkout) and ignore the PHP advice below.

Members of the Renoise community are writing some pretty cool PHP scripts that do awesome stuff with the XRNS file format.


Unfortunately, there is no GUI for XRNS-PHP on the mac at this time. XRNS-PHP requires PHP 5.2.3 or higher. This is currently not included on OS X 10.4, the default in /usr/bin/php is version 4 which is too old.

All of these factors make it difficult to use for people not familiar with the command prompt. That being said, it’s very easy to learn the command prompt. The amount of time spent making and maintaining the scripts is far greater than the amount of time it takes to learn the command prompt. Blah blah blah, command prompt.

1) OS X 10.4 Tiger users and below, get a PHP5 package:

2) download xrns-scripts (Edit: Currently at version 1.06) and extract in a new folder. Optionally if you have terminal rocking (see below) you can:

cd ~  
mkdir xrns-php  
cd xrns-php  
cvs -z9 -d:pserver:anonymous@xrns-php.cvs.sourceforge.net:/cvsroot/xrns-php co -P xrns-php/scripts/  

The first three lines make a folder in your home dir named xrns-php, the fourth line downloads the scripts from CVS. Warning! These are work in progress and probably unstable, use at your own risk. But if you want the latest and greatest, cvs is the way to go.

3) Download the missing third party tools.

4) Make a directory in your home dir named “bin”, put the files in there, here’s my bin:

[13:46:07]$ pwd  
[13:46:08]$ ls -al  
total 7664  
drwxr-xr-x 12 dac514 dac514 408 Aug 26 11:27 .  
drwxr-xr-x 25 dac514 dac514 850 Oct 18 18:37 ..  
-rw-r--r-- 1 dac514 dac514 12292 Aug 26 11:27 .DS_Store  
-rwxr-xr-x 1 dac514 dac514 352348 Feb 14 2007 flac  
-rwxr-xr-x 1 dac514 dac514 233376 Feb 14 2007 metaflac  
-rwxr-xr-x 1 dac514 dac514 215796 Nov 19 2005 oggdec  
-rwxr-xr-x 1 dac514 dac514 1319344 Nov 19 2005 oggenc  
-rwxr-xr-x 1 dac514 dac514 199240 Nov 19 2005 ogginfo  
-rwxr-xr-x 1 dac514 dac514 727464 Jul 6 00:19 rar  
-rwxr-xr-x 1 dac514 dac514 440100 Jul 6 00:19 unrar  
-rwxr-xr-x 1 dac514 dac514 182716 Nov 19 2005 vcut  
-rwxr-xr-x 1 dac514 dac514 220824 Nov 19 2005 vorbiscomment  



Find the Terminal application, this is your command prompt.

Desktop -> Hard Drive -> Applications -> Utilites -> Terminal

Change the preferences so that you are using bash:

Terminal -> Windows Settings

Shell: Should be bash
Color: Change to white on black for 3l1t3 k00l factor
Change the other stuff if you want, too
Click “Use Settings as Defaults”
Click “X”

In Terminal, type:

cd ~  
pico -w .bash_profile  

Pay attention to the dot at the start of the file name, this means “hidden file”. If not already there, paste the following into pico.

if [-f ~/.bashrc]; then  
source ~/.bashrc  

Press CTRL-X, look at the bottom, agree to save.

In Terminal, type:


Remember this value, write it down somewhere if you have poor memory.

cd ~  
pico -w .bashrc  

Again, pay attention to the dot at the start of the file name, this still means “hidden file”. Paste the following into pico:

export PATH="$PATH:/Users/dac514/bin/:/Applications/MAMP/bin/php5/bin/"  
alias "ls"="ls -G"  
alias "dir"="ls -alG"  
# OS X 10.4 Tiger and below  
alias php=/Applications/MAMP/bin/php5/bin/php  
alias pear=/Applications/MAMP/bin/php5/bin/pear  

Look above, replace all the “dac514” with the result you got when you did whoami just before. Replace the paths with the whatever version of PHP you downloaded.

Exit terminal.

Start terminal again.


6) go to command line and navigate to the xrns-scripts folder i.e. cd ~/xrns-php without the backticks.

7) launch script with

(/path/to)php -n script_name.php /path/to/input.ext (/path/to/)output.ext  

Where (/path/to) is optional i.e. you don’t have to type it and if you do lose the parenthesis. Where script_name.php is the actual file name of a script. Some scripts have extra options. Open the script in a text editor to read which parameters it expects when running it from the command-line.

Cool OS X text editors:


Command prompt tutorials:


Although I’m snarky and sardonic, provided you actually made some effort and aren’t a lazy pile of tard, I’m more than willing to help, so post questions here. Who knows, maybe you could start writing your own scripts and be part of the kingdom of nerds!


It has come to my attention that MAC OS X Leopard (10.5.X) has PHP 5.2.x with the SimpleXML extension out of the box. So, if you are using Leopard you can download the scripts (or do a CVS checkout) and ignore most of the advice above. Can someone confirm this?

Sorry, no OS X Script Frontend as of yet.

I can verify this works. I’m particularly fond of piping the output (not literally, I’m not an ultra power user yet) from xrns2midi to midi2ly to lilypond…typeset scores from what i input with tracker notation = wonderful. unfortunately, the midis that xrns2midi generates do not seem to work with sibelius 4, which i fired up so i could check for the sorts of silly mistakes that it is good at showing. it still works out fine at the end of the day, but i’d really like to get sibelius working with xrns2midi output…that would just about do it for me.

Oh, by the way, to anyone who wants to try to get lilypond working: go to http://hans.fugal.net/blog/articles/2008/0…pond-on-leopard and create the shell launcher script as it advises. Then, download and install the intel version of leopard to a separate directory, and create another launcher script in the same manner as the last one, but pointing to the intel version of lilypond. Why should you do this? Well, it seems to be broken right now. I can use lilypond but not midi2ly with the ppc(g4, etc) version. I can use midi2ly but not lilypond with the intel version. Because i need to use both, I just installed both and made a script that launches xrns2midi then each respective part of the lilypond and midi2ly chain. It is very hacky, but it works. The end result is something like this (note, this is not universal and you should use common sense and change filenames as is necessary):

#! /bin/sh  
php -n ~/xrns-scripts-1.06/xrns2midi.php ee.xrns ee.mid; change as necessary for your xrns file  
sh ly2 midi2ly ee.mid; again change as is necessary  
sh ly lilypond ee-midi.ly; and again change as is necessary, appending '-midi.ly' to whatever you named your file  

Thanks for sharing names of software I had never heard of before. Good stuff.

I Googled for “sibelius 4” since this was the first time I heard of it, and I ended up on this page, which is sibelius 5. I won’t be buying this software anytime soon, so before I download the trial and debug the scripts in a time limited trial window of time, can you also confirm it’s not working in sibelius 5?

Cool, thanks for the tip.

hi there,
are these directions suitable for linux operation also?
thanks in advance!
These scripts are very useful and offer a lot of creativity.
Many thanks for the work of all involved.

Yes, I would assume the directions are suitable for linux too.

Get back to me/us if they aren’t?