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?
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 :)
我认为最简单的方法是在实际的Sage文件的最后一行调用该函数:例如,“ somefile.sage”的最后一行print 3
。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.