简体   繁体   English

如何在启动时从 shell 运行八度脚本

[英]How to run octave script from shell at launch

I'm using Ubuntu system.我正在使用 Ubuntu 系统。 To run MATLAB script at launch, I can type matlab -nodesktop -r "run./my_program.m" .要在启动时运行 MATLAB 脚本,我可以输入matlab -nodesktop -r "run./my_program.m"

How can I achieve the same function on Octave, like octave --no-gui -some_command ?如何在 Octave 上实现相同的 function,如octave --no-gui -some_command

I've read this post and this post.我已经阅读了这篇文章和这篇文章。 They did not answer my question.他们没有回答我的问题。

如评论之一所述,一种解决方案是:

octave --persist my_program.m

For Windows users:对于 Windows 用户:

I see it's a bit harder, since there's no "octave.exe" file.我发现它有点难,因为没有“octave.exe”文件。

I do have: "C:\Program Files\GNU Octave\Octave-6.4.0\mingw64\bin\octave-cli-6.4.0.exe" which works after adding both parent directories "C:\Program Files\GNU Octave\Octave-6.4.0\mingw64\bin" and "C:\Program Files\GNU Octave\Octave-6.4.0\mingw64" to PATH.我确实有:“C:\Program Files\GNU Octave\Octave-6.4.0\mingw64\bin\octave-cli-6.4.0.exe”,它在添加两个父目录“C:\Program Files\GNU Octave”后起作用\Octave-6.4.0\mingw64\bin" 和 "C:\Program Files\GNU Octave\Octave-6.4.0\mingw64" 到 PATH。

All this happens automatically in the startup script which is the normal entry point of the SW:所有这些都在启动脚本中自动发生,启动脚本是 SW 的正常入口点:

"C:\Program Files\GNU Octave\Octave-6.4.0\octave.vbs" “C:\Program Files\GNU Octave\Octave-6.4.0\octave.vbs”

Finaly, after adding all to path I run it like this:最后,在将所有内容添加到路径后,我像这样运行它:

"C:\Program Files\GNU Octave\Octave-6.4.0\mingw64\bin\octave-cli-6.4.0.exe" "C:\MatlabScripts\matlabScript1.m" c:\temp\myCuteImage [example for prm] "C:\Program Files\GNU Octave\Octave-6.4.0\mingw64\bin\octave-cli-6.4.0.exe" "C:\MatlabScripts\matlabScript1.m" c:\temp\myCuteImage [prm 示例]

Currently looks like it is enough to say for script (not plain function)目前看起来足以说明脚本(不是普通功能)

octave my_program.m

Also if you have octave installed in your path you could and in the beginning of script as the first line the desired interpreter (works for python, bash, whatever), for example for default location :此外,如果您在路径中安装了八度音程,则可以在脚本的开头将所需的解释器作为第一行(适用于 python、bash 等),例如默认位置:

#!/usr/bin/octave

and you can run them without even adding the octave in front... just the script name....您甚至可以在不添加八度音程的情况下运行它们...只是脚本名称....

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

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