[英]How to execute a command in a different shell?
I have a bash script that opens up a shell called salome shell and it should execute a command called as_run in that shell. I have a bash script that opens up a shell called salome shell and it should execute a command called as_run in that shell. The thing is that after entering the salome shell it doesn't execute the command until I exit the salome shell.
问题是在进入莎乐美 shell 后,它不会执行命令,直到我退出莎乐美 shell。 This is the code that i got:
这是我得到的代码:
#!/bin/bash
cd /opt/salome/appli_V2018.0.1_public
./salome shell
eval "as_run /home/students/gbroilo/Desktop/Script/Template_1_2/exportSalome"
What should I do in order to execute the command in the salome shell?我应该怎么做才能执行salome shell中的命令?
Most shells implement a way to pass the commands as parameters, eg大多数 shell 实现了一种将命令作为参数传递的方法,例如
dash -c 'x=1 ; echo $x'
You'll need to consult your shell's manual to see if it's possible.您需要查阅您的 shell 手册以查看是否可行。
You can also try sending the commands to the standard input of the shell:您也可以尝试将命令发送到 shell 的标准输入:
echo 'set x = 1 ; echo $x' | tcsh
Using a HERE doc might be a bit more readable in case of complex commands:在复杂命令的情况下,使用 HERE 文档可能更具可读性:
tcsh << 'TCSH'
set x = 1
echo $x
TCSH
Might be this is what you want:可能这就是你想要的:
# call salome shell with commands in a specified script file
cd /opt/salome/appli_V2018.0.1_public
./salome shell <"/home/students/gbroilo/Desktop/Script/Template_1_2/exportSalome"
Or might be this is what you want:或者这可能是你想要的:
# pipe a command as_run... to salome shell
cd /opt/salome/appli_V2018.0.1_public
echo "as_run /home/students/gbroilo/Desktop/Script/Template_1_2/exportSalome" | ./salome shell
Anyway, you have to read the salome guide about how salome shell call it's script.无论如何,你必须阅读莎乐美指南,了解莎乐美 shell 如何调用它的脚本。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.