简体   繁体   中英

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?

Most shells implement a way to pass the commands as parameters, eg

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

You'll need to consult your shell's manual to see if it's possible.

You can also try sending the commands to the standard input of the shell:

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

Using a HERE doc might be a bit more readable in case of complex commands:

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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