简体   繁体   English

使用八度无头

[英]Using octave headless

Is there a possibility to use Octave headless. 是否有可能使用Octave无头。

Something like this octave < "5+4" >result.txt 像这个octave < "5+4" >result.txt

Using 运用

octave --silent --eval 5+4 > result.txt

you'll get 你会得到

ans =  9

in result.txt . result.txt See octave --help for details about command-line arguments. 有关命令行参数的详细信息,请参阅octave --help

Yet, there is this infamous ans = that might be remove using sed , eg 然而,有一个臭名昭着的ans =可能会被使用sed删除,例如

octave --silent --eval 'x=5+4; y=x+1; disp(y)' | sed -e 's/ans = //' >> result.txt

which add the appropriate result ( 10 ) in result.txt . result.txt添加适当的结果( 10 )。

It should not be too hard to wrap this into a bash script. 将它包装成bash脚本应该不会太难。

Well there is always the option of writing a script file which saves the results of your computations to a text file. 总是可以选择编写脚本文件,将计算结果保存到文本文件中。 Then when invoking octave you just do: 然后在调用八度时你只需:

octave scriptname.m

for example: testfile.m 例如: testfile.m

Return = 5+4;
save('results.txt','Return')

Then from the command line: 然后从命令行:

octave -q testfile.m

and you should get the results you want in a file called results.txt and it will immediately terminate after. 你应该在一个名为results.txt的文件中得到你想要的结果,然后它会立即终止。 Is there some reason why this option wont work? 有什么理由为什么这个选项不起作用?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM