Csound Csound-dev Csound-tekno Search About

[Csnd] Stoopid shell trick - #!/usr/local/bin/csound

Date2009-06-19 22:51
FromJacob Joaquin
Subject[Csnd] Stoopid shell trick - #!/usr/local/bin/csound
This is probably obvious to some of you, but I just personally discovered a
shell trick.  I added "#!/usr/local/bin/csound" to the top of a csd file, a
"chmod 775 test.csd", and type "./test.csd" in the terminal, and it played
the file.  I was kinda surprised it worked.

Furthermore, when I tried "./test.csd -A -otest.aif" it overrode the
CsOptions and generated a file instead.  This makes me really happy.  Here's
my test code:

----
#!/usr/local/bin/csound



-g -odac


sr     = 44100
kr     = 4410
ksmps  = 10
nchnls = 1

instr 1
	kenv line 32768, p3, 0
	a1 oscil kenv, 440, 1
	out a1 
endin


f 1 0 8192 10 1
i 1 0 1


----

Best,
Jake


-- 
View this message in context: http://www.nabble.com/Stoopid-shell-trick----%21-usr-local-bin-csound-tp24119341p24119341.html
Sent from the Csound - General mailing list archive at Nabble.com.


Date2009-06-19 23:07
FromAtte Andre Jensen
Subject[Csnd] Re: Stoopid shell trick - #!/usr/local/bin/csound
Jacob Joaquin wrote:

> This is probably obvious to some of you, but I just personally discovered a
> shell trick.  I added "#!/usr/local/bin/csound" to the top of a csd file, a
> "chmod 775 test.csd", and type "./test.csd" in the terminal, and it played
> the file.  I was kinda surprised it worked.

I didn't know about that, cool. Unfortunately this depends on a unified 
location of the executable, mine is in /usr/bin/csound. Not like 
/bin/bash which always sits exactly there...

-- 
Atte

http://atte.dk   http://modlys.dk   http://virb.com/atte

Date2009-06-20 00:46
FromErik de Castro Lopo
Subject[Csnd] Re: Re: Stoopid shell trick - #!/usr/local/bin/csound
Atte Andre Jensen wrote:

> Jacob Joaquin wrote:
> 
> > This is probably obvious to some of you, but I just personally discovered a
> > shell trick.  I added "#!/usr/local/bin/csound" to the top of a csd file, a
> > "chmod 775 test.csd", and type "./test.csd" in the terminal, and it played
> > the file.  I was kinda surprised it worked.
> 
> I didn't know about that, cool. Unfortunately this depends on a unified 
> location of the executable, mine is in /usr/bin/csound. Not like 
> /bin/bash which always sits exactly there...

Try:

   #!/usr/bin/env csound

The /usr/bin/env executable should *always* be in the same place and
it will find the csound executable as  long as it is on your $PATH.

Erik
-- 
----------------------------------------------------------------------
Erik de Castro Lopo
http://www.mega-nerd.com/