1. Is this a clean, from-source build of sage-2.9.3?
2. What is the output of /usr/bin/env for you? Mine (Intel OS X
10.5.1) doesn't mention sage at all, although mysteriously things are
working for me.
> #!/usr/bin/env sage -python
> import sys
For me, I get
$ ./BMV.sage
$
However, when I run the sage itself, it looks like it's pointing at
some weird version:
$ /usr/bin/env sage
----------------------------------------------------------------------
| SAGE Version 2.9.2, Release Date: 2008-01-05 |
| Type notebook() for the GUI, and license() for information. |
----------------------------------------------------------------------
Loading SAGE library. Current Mercurial branch is: demo
Hopefully this helps, although I have a feeling this thread isn't
over...
I consider all this a bug, and it's definitely a problem on numerous _linux_
systems. This problem doesn't happen at all on OSX. I've made it
http://trac.sagemath.org/sage_trac/ticket/1789
William
I thought I have seen this before and the issue was a buggy env, i.e.
Maybe we can add some
script that does the equivalent of "sage -python", maybe "local/bin/
sage-python" does that job, but I assume the env isn't set up
properly.
Doesno, the output is in both cases (sage -python as well as sage-python):
#!/path/to/sage_root/local/bin/sage-python
work?
This made me curious, becuase I also use Debian (sid) and I get the
exact same behaviour
as you do and I was able to figure out where the problem is in the
last 10 minutes. Need to go now.
But I smell I am going to learn something new here. :)
Ondrej
I mean - I wasn't able to figure it out.
O.
ok, this works:
$ cat t.py
#!/bin/sh /home/ondra/ext/sage/sage
import sys
$ ./t.py
$
And this doesn't:
$ cat t.py
#!/home/ondra/ext/sage/sage
import sys
$ ./t.py
(I get the cross - which means that it's bash, who is executing that file btw)
$ cat t.py
#!/bin/sh /home/ondra/ext/sage/sage -python
import sys
$ ./t.py
/bin/sh: /home/ondra/ext/sage/sage -python: No such file or directory
So I don't know. But it must be something stupid - I bet this used to
work for me before.
Ondrej
Case 2 outputs
./t.py: line 2: import: command not found
Case 3 behaves as yours.
My 2p: My understanding of the #! convention is that the line is split
up into three parts:
#!
<program name>
<argument(s)>
The <program name> must be an executable PROGRAM, not a script.
The <argument(s) gets treated as a single string.
This would explain my behaviour. Don't know what Debian does in case 2,
Ubuntu seems to just ignore the first line if it's not a true executable
and executes the rest of the file with /bin/sh.
Bill
--
+---------------------------------------+
| Bill Purvis, Amateur Mathematician |
| email: b...@beeb.net |
| http://bil.members.beeb.net |
+---------------------------------------+
I just posted a patch related to this discussion here
http://trac.sagemath.org/sage_trac/ticket/1789
I think the upshot of the entire discussion above is (or should be) to use
#!/usr/bin/env sage
instead of
#!/usr/bin/env sage -python
This assumes sage is in your path -- and indeed it should be if you want
to write portable scripts.
The second form above, e.g.,
#!/usr/bin/env sage -python
only works on OS X. The first form, e.g.,
#!/usr/bin/env sage
works on both OS X and linux. Both are equivalent in behavior on OS X.
-- william