如何在unixshell中调用octave脚本
我已经编写了一个八度脚本文件(.m) 如果有人能告诉我如何在unixshell上运行octave脚本,那将非常有帮助。我不想通过调用octave程序来执行脚本 我不熟悉unix和octave如何在unixshell中调用octave脚本,shell,scripting,command-line-interface,sh,octave,Shell,Scripting,Command Line Interface,Sh,Octave,我已经编写了一个八度脚本文件(.m) 如果有人能告诉我如何在unixshell上运行octave脚本,那将非常有帮助。我不想通过调用octave程序来执行脚本 我不熟悉unix和octave 提前谢谢是的,当然你可以写一个八度程序。像这样: $ cat octave_program #!/usr/bin/env octave ## Never forget your licence at the top of the files. 1; function [rv] = main (argv)
提前谢谢是的,当然你可以写一个八度程序。像这样:
$ cat octave_program
#!/usr/bin/env octave
## Never forget your licence at the top of the files.
1;
function [rv] = main (argv)
disp ("hello world");
rv = 0;
return;
endfunction
main (argv);
$ chmod a+x octave_program # add executable permissions
$ ./octave_program
hello world
对于八度音阶的节目来说,有两件事很重要:
1代码>
#/usr/bin/octave
但使用#/usr/bin/env倍频程
将更加便携和灵活您打算如何在不运行octave的情况下运行octave脚本?提示:你不能。但是,您可以调用octave来运行脚本:
octave-q script.m
应该使用“安静”模式,octave不会转储额外的垃圾。@AndrasDeak与从任何其他语言调用脚本的方式相同(可能除了Matlab和R)。如果操作正确,您不需要在命令行上实际指定octave
。它只是不够透明,但仍然是八度音阶调用运行脚本。@AndrasDeak考虑到语言和问题,我认为这正是OP的意思。不必在命令行中指定它。就像从用这些语言编写的/usr/bin
调用东西时,不必在命令行中指定bash、python、perl或ruby一样。@carandraug我想你是对的。公平地说,我总是显式地调用脚本:)