Sophie

Sophie

distrib > Mageia > 6 > armv5tl > by-pkgid > 9e9fbbefd2001d780f31040381fe729b > files > 36

bsh-manual-1.3.0-37.mga6.noarch.rpm

<html><head><META http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>Executable scripts under Unix</title></head><body bgcolor="ffffff"><table cellspacing="10"><tr><td align="center"><a href="http://www.beanshell.org/"><img src="../images/homebutton.gif"><br>Home</a></td><td><a href="reflectivestyle.html#Reflective_Style_Access_to_Scripted_Methods"><img src="../images/backbutton.gif"><br>Back
			</a></td><td align="center"><a href="contents.html"><img src="../images/upbutton.gif"><br>Contents</a></td><td align="center"><a href="bsf.html#BSF_Bean_Scripting_Framework"><img src="../images/forwardbutton.gif"><br>Next
			</a></td></tr></table><h1>Executable scripts under Unix</h1>


You can use BeanShell for writing scripts as you would any other shell 
under many Unixs:

<p></p><center><table width="100%" cellpadding="5" border="1"><tr><td bgcolor="#dfdfdc"><pre>
#!/usr/java/bin/java bsh.Interpreter 

print("foo");
</pre></td></tr></table></center><p></p>

However some flavors of Unix are more picky about what they will allow
as a shell program.  For those you can use the following hack to make
your BeanShell scripts executable.

<p></p><center><table width="100%" cellpadding="5" border="1"><tr><td bgcolor="#dfdfdc"><pre>
#!/bin/sh
# The following hack allows java to reside anywhere in the PATH.
//bin/true; exec java bsh.Interpreter "$0" "$@"

print("foo");
</pre></td></tr></table></center><p></p>

The above trick presumes that /bin/true exists on your system and that //bin is
the same as /bin.  The // causes BeanShell to ignore the line.
<p CLEAR="ALL"></p>

The above has been tested on Solaris.  It does not seem to work under Cygwin.

<h3>OSX</h3>

For OSX the path is a bit different:

<p></p><center><table width="100%" cellpadding="5" border="1"><tr><td bgcolor="#dfdfdc"><pre>
#!/Library/Java/home/bin/java bsh.Interpreter

print("foo");
</pre></td></tr></table></center><p></p>

On OSX /usr/bin/java is itself a shell script, which unfortunately won't
work out-of-the-box.

<table cellspacing="10"><tr><td align="center"><a href="http://www.beanshell.org/"><img src="../images/homebutton.gif"><br>Home</a></td><td><a href="reflectivestyle.html#Reflective_Style_Access_to_Scripted_Methods"><img src="../images/backbutton.gif"><br>Back
			</a></td><td align="center"><a href="contents.html"><img src="../images/upbutton.gif"><br>Contents</a></td><td align="center"><a href="bsf.html#BSF_Bean_Scripting_Framework"><img src="../images/forwardbutton.gif"><br>Next
			</a></td></tr></table></body></html>