lilypond-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Lilypond & Ubuntu Help


From: Jonathan Kulp
Subject: Re: Lilypond & Ubuntu Help
Date: Sun, 17 Aug 2008 21:03:40 -0500
User-agent: Thunderbird 2.0.0.16 (X11/20080724)

Ok I've come up with a completely different script that does what I *thought* the original one was supposed to do. Searching around I found a couple of commands that make the entire thing simpler and easier for me to understand. I don't really understand how to use sed and only used it b/c I grabbed a snippet of code from an unrelated script. I've run this one from many different directories on many different files and it has worked perfectly each time. I'm glad this thread started b/c it taught me that I'm not as smart as I thought I was, but also demonstrates the amazing flexibility of unix-like scripts--there's more than one way to do stuff. (The fact that my script and Jay's below essentially do the same thing is astonishing to me. Jay's looks so much more impressive!) OK here's the script, which I save as "lily" in my ~/bin directory and run as "lily filename.ly"

#!/bin/bash

#************************************************************#
# This script runs lilypond on a specified file, keeping all #
# output files in the same directory as the source file      #
#************************************************************#

# determines the source filename
srcfile="`basename $1`"

# removes the extension from source filename
FILENOEXTENSION="`basename $1 .ly`"

# determines directory
OUTDIR="`dirname $1`"

# closes current Acrobat Reader window
wmctrl -c "Adobe Reader"

# changes to correct directory
cd $OUTDIR

# runs lilypond on file
lilypond  $srcfile

# opens pdf and returns to command prompt
acroread $FILENOEXTENSION.pdf &

#***********END OF SCRIPT**************

Best,

Jonathan

Jay Anderson wrote:
Jonathan Kulp <jonlancekulp <at> gmail.com> writes:
Well, my face is red. Just tried my script from a different directory and it doesn't put the output in the right place. I guess I've always just cd'd to the right dir before running the script. Sorry about that! I'll see if I can make it work right. Just have to figure out how to capture the path of the first argument. I'm new at scripting so this could take a while :)


The script below doesn't open up a pdf viewer (that can be added from your
script), but it does make sure all the output is in the same directory as the
source file.

-----Jay

#!/bin/sh

#last argument
for LY; do :; done

#All but last argument
ARGS=`echo $@ | sed -e 's_^\s*\(\(\S\S*\s\s*\)*\)\S\S*\s*$_\1_'`

#Run lilypond from the directory where the file lives
cd `dirname $LY`
CMD="lilypond $ARGS $(basename $LY)"
echo $CMD
eval $CMD



_______________________________________________
lilypond-user mailing list
address@hidden
http://lists.gnu.org/mailman/listinfo/lilypond-user


--
Jonathan Kulp
http://www.jonathankulp.com




reply via email to

[Prev in Thread] Current Thread [Next in Thread]