2013-10-13 194 views
1

我想加载一个sage文件并从该文件运行一个函数,全部来自bash。python sage从命令行附加并运行另一个命令

attach命令给我找麻烦...

这工作:

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

这也适用于:

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

但是,这并不工作:

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我可以得到这个工作吗,或者我能做些什么呢?

回答

0

我认为最简单的方法就是调用函数作为实际Sage文件的最后一行:也就是说,例如,“somefile.sage”将具有最后一行print 3

+0

这是一个错误的圣人,正在追踪http://trac.sagemath.org/ticket/15275。 –

+0

不错的发现:) ... no..short..comments..allowed ... – frnhr

1

如果帮助别人......

我最终使用这个畸形:

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

确定,rm部分是不是真的那么必要:)