Frage

I want to load a sage file and run a function from that file, all from bash.

The attach command is giving me trouble...

This works:

bash-prompt$ sage -c "print 2; print 3"
2
3
bash-prompt$

This also works:

bash-prompt$ sage -c "attach somefile.sage"
some print just to confirm the file is loaded
bash-prompt$

But this doesn't work:

bash-prompt$ sage -c "attach somefile.sage; print 3"
python: can't open file '/path/to/somefile.sage; print Integer(3)': [Errno 2] No such file or directory

How can I get this to work, or what can I do instead?

War es hilfreich?

Lösung 2

I think the easiest thing to do is to call the function as the last line in the actual Sage file: that is, "somefile.sage" will have as its last line print 3, for example.

Andere Tipps

If it helps someone...

I ended up using this monstrosity:

sage somefile.sage && sage -python -c "execfile('somefile.py'); wrapper()" && rm somefile.py

Ok, the rm part is not really all that necessary :)

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top