如何在Unix Shell中调用八度音阶脚本 [英] How to invoke octave script in unix shell

查看:99
本文介绍了如何在Unix Shell中调用八度音阶脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经编写了一个八度脚本文件(.m)

I have written an octave script file (.m)

如果有人能指出我如何在unix shell上运行八度脚本,那将非常有帮助.我不想通过调用八度程序来执行脚本.

If anyone could point me out on how to run octave scripts on unix shell that would be really helpful. I do not want to execute the script by invoking octave program.

我是unix和octave的新手.

I am new to unix and octave.

预先感谢

推荐答案

是的,您当然可以编写一个Octave程序.像这样:

Yes, of course you can write an Octave program. Like so:

$ 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

对于Octave程序,有几件重要的事情:

There's a couple of things important for an Octave program:

  1. 第一个语句不能是函数声明.在我所有的程序中,第一条语句是加载必要的程序包.如果没有软件包,通常使用1;

a 她爆炸行.那是程序的第一行,告诉您如何运行程序.如果您知道将Octave安装在何处,则可以使用#!/usr/bin/octave,但是使用#!/usr/bin/env octave会更加便携和灵活.

a she-bang line. That's the first line of your program which tells you how to run your program. If you know where Octave will be installed, you can use #!/usr/bin/octave but using #!/usr/bin/env octave will be more portable and flexible.

您的程序需要可执行权限

your program needs executable permissions

这篇关于如何在Unix Shell中调用八度音阶脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆