help-octave
[Top][All Lists]
Advanced

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

Re: Octave scripts in Mac OSX


From: Daryl Lee
Subject: Re: Octave scripts in Mac OSX
Date: Wed, 29 Jun 2011 11:52:06 -0600
User-agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.18) Gecko/20110616 Lightning/1.0b2 Thunderbird/3.1.11

On 6/29/2011 9:20 AM, John W. Eaton wrote:
On 29-Jun-2011, Daryl Lee wrote:

| I'm plowing my way through the newly released "GNU Octave for Beginners"
| book, and I have run into a question that I think this group should be able
| to answer.  I got to Chapter 4 and the section telling "GNU/Linux and MacOS
| X users" how to add the shebang line to their script so it can be executed
| from the bash shell.
|
| In Mac OSX, from the shell I type ($ is shell prompt)
|
| $ /Applications/Octave.app/Contents/Resources/bin/octave
|
| and get an Octave environment, as expected.  But when I write a script with
| this as the first line:
|
| #! /Applications/Octave.app/Contents/Resources/bin/octave -qf
|
| set the permissions, and execute the script, I get a bash syntax error on
| the first line of Octave script following the shebang line.  I've tried it
| with and without the -qf.  It works as advertised on Linux, so I'm sure it's
| a Mac OSX issue.
|
| What would be an effective way to launch Octave scripts from the Mac OS X
| terminal command line?

What's the error?

The error is simply "syntax error near unexpected '('" in the first line after the shebang line:

A = rand(3,4);

Some systems have a too-small limit (like 16 or 32) on the number of
characters that can be used in the name of the command.

Since Mac OS X terminal uses Bash as its shell, I'd not expect that.

One workaround is to create a symbolic link or shell script somewhere
else in the filesystem that will allow you to bypass the limit.

I had already tried the symlink idea. So just typing "octave" at the command prompt brings up the octave environment. But putting
/usr/local/bin/octave in the shebang line still fails.

Another is to put Octave in your PATH and use something like

   #! /usr/bin/env octave

Ta-da!  Thanks.

except then you probably won't be able to pass options in addition to
the command name.  If you need to do that, then you can use a wrapper
shell script that calls Octave with the options.

BTW, I don't think Octave can fix any of these problems.  They are all
limitations of the OS.

I was pretty sure it isn't Octave's problem. But I was also pretty sure that I'm not the first person on the mailing list to want to do this. Maybe I am!


jwe



--
Daryl Lee
www.daryllee.com
The unexamined life is not worth living. -- Socrates
The unlived life is not worth examining. -- Unknown



reply via email to

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