运行 调用奇点后脚本中的下一个命令 shell

Run next command in script after invoking singularity shell

我有一个 shell 脚本,里面有多个奇点命令 myscript.sh

#!/bin/sh/

singularity shell -B /home/user/Desktop/ /home/user/image/some_image.simg
/home/user/miniconda/activate my_env
cd /app/app_folder/scripts
ls -ash

当我 运行 脚本在调用 shell 后卡住。

singularity>

但是我希望在调用的 shell 中对 运行 执行后续命令。我该怎么做?

您正在连接到 shell 脚本中的交互式命令 shell,您只需要执行命令即可。

singularity exec ...

https://sylabs.io/guides/3.7/user-guide/cli/singularity_exec.html

所以基本上我不得不用 exec 替换 shell 并将后续命令保存在不同的可执行文件 bash 脚本 newscript.sh 中,其中包含

#!/bin/sh

/home/user/miniconda/activate my_env
cd /app/app_folder/scripts
ls -ash

然后是运行myscript.sh

#!/bin/sh

singularity exec -B /home/user/Desktop/ /home/user/image/some_image.simg bash newscript.sh

此方法将运行newscript.sh在奇点shell中调用奇点shell后myscript.sh