I'm being asked to automate a task which creates a backup. In order to do this one of the steps is to enter into the Amster tool, which itself enters its own shell where I then execute more commands until I exit out of it. In order to successfully enter Amster I need to provide credentials, once inside Amster I also need to execute a connect command providing credentials and then execute more commands.

Is there a way to accomplish all of this from a single sh script? Or is it not possible to drill down into shells within shells?

This would be the beginning of the sh script, although more commands would be added after, it illustrates what I'm trying to ask. So after the ./amster line it enters its own shell where the connect command should be executed and prompt for credentials (which is part of the problem I'm trying to solve, enter the credentials in a line of the script maybe?)

```
[Access-Manager]:/mnt/forgerock/amster> tail autoback.sh
cd /mnt/forgerock/amste
export JAVA_HOME=/usr/
./amster
connect -i http://xxxxxxxx.com:8080/auth

```

If I execute that script as is, it will take me into amster and get me into the amster prompt, but the connect command will not execute.

```
[Access-Manager]:/mnt/forgerock/amster> ./autoback.sh
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.codehaus.groovy.reflection.CachedClass (file:/mnt/forgerock/amster/amster-6.5.2.3.jar) to method java.lang.Object.finalize()
WARNING: Please consider reporting this to the maintainers of org.codehaus.groovy.reflection.CachedClass
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
Amster OpenAM Shell (6.5.2.3 build 4ed586d624, JVM: 11.0.7)
Type ':help' or ':h' for help.
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
am>

```

So this just leaves me at the amster prompt, ready for the next command. This is where I don't know how to make it execute the following command.

Any ideas??

If you need more details please let me know.

Thanks.