Search code examples
bashshellecho

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. The thing is that after entering the salome shell it doesn't execute the command until I exit the salome 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?


Solution

  • 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.