[英]Problems with calling bash scritpt from octave in ubuntu
I trying to run a script which invokes a program outside octave.我试图运行一个调用八度之外的程序的脚本。 The script works fine when called from terminal.从终端调用该脚本时工作正常。 My problem is that the shebang part of the script doesnt seems to invoke bash.我的问题是脚本的 shebang 部分似乎没有调用 bash。 For example, if I write the following script:例如,如果我编写以下脚本:
#! /bin/bash
echo $SHELL
whoami
When I call this script fom octave当我从八度调用这个脚本时
system('bash myscript.bash')
I got:我有:
>> /bin/sh
>> user
So when I try to run the actual script from octave (not the one above), I get "command not found" errors.因此,当我尝试从八度(不是上面的那个)运行实际脚本时,我得到“找不到命令”错误。 Any idea what im doing wrong here?知道我在这里做错了什么吗?
Found out the issue was that I installed Octave with flatpack, which creates its own environment or something, hence cant really see the functions in /bin.发现问题是我用 flatpack 安装了 Octave,它创建了自己的环境或其他东西,因此无法真正看到 /bin 中的功能。 So if you having similar issues, like not having the same functions in Octave command line and Terminal:所以如果你有类似的问题,比如在 Octave 命令行和终端中没有相同的功能:
flatpak uninstall octave
sudo apt-get install octave
please try请试试
system('./myscript.bash')
or或者
system('/bin/sh /root/path/to/myscript.bash')
and in your bash script use absolute path to your program or you can your program in /bin
directory并在您的 bash 脚本中使用程序的绝对路径,或者您可以将程序放在/bin
目录中
path example: /root/path/to/myscript.bash
路径示例: /root/path/to/myscript.bash
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.