簡體   English   中英

如何在不同的 shell 中執行命令?

[英]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. 問題是在進入莎樂美 shell 后,它不會執行命令,直到我退出莎樂美 shell。 這是我得到的代碼:

#!/bin/bash

cd /opt/salome/appli_V2018.0.1_public
./salome shell
eval "as_run /home/students/gbroilo/Desktop/Script/Template_1_2/exportSalome" 

我應該怎么做才能執行salome shell中的命令?

大多數 shell 實現了一種將命令作為參數傳遞的方法,例如

dash -c 'x=1 ; echo $x'

您需要查閱您的 shell 手冊以查看是否可行。

您也可以嘗試將命令發送到 shell 的標准輸入:

echo 'set x = 1 ; echo $x' | tcsh

在復雜命令的情況下,使用 HERE 文檔可能更具可讀性:

tcsh << 'TCSH'
    set x = 1
    echo $x
TCSH

可能這就是你想要的:

# 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"

或者這可能是你想要的:

# 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

無論如何,你必須閱讀莎樂美指南,了解莎樂美 shell 如何調用它的腳本。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM