简体   繁体   English

shell 脚本在 bash -l 后停止运行

[英]shell script stops running after bash -l

I am new to shell scripting and I have created a run_all.sh file with the following content,我是 shell 脚本的新手,我创建了一个包含以下内容的run_all.sh文件,

cd directory1/folder1
bash -l
conda activate py38
poetry install 
./scripts/run_myscript.sh

If I execute these line one by one in terminal I have no issues but when I put all in run_all.sh file and execute ( bash run_all.sh ), only the first two lines gets executed and then it stops without printing any error code.如果我在终端中逐行执行这些行,我没有问题,但是当我将所有内容放入run_all.sh文件并执行( bash run_all.sh )时,只有前两行被执行,然后它停止而不打印任何错误代码。

Note: I am using Sagemaker which uses sh as the default shell and not bash so in manual run I start new shell ( bash -l ) to activate py38 through conda ( conda activate py38 ) and install the requirements... Note: I am using Sagemaker which uses sh as the default shell and not bash so in manual run I start new shell ( bash -l ) to activate py38 through conda ( conda conda activate py38 ) and install the requirements...

Please let me know if you see what I am missing here.如果您看到我在这里缺少的东西,请告诉我。

Man oh man.男人哦男人。

#!/bin/sh
cd directory1/folder1 && conda activate py38 && poetry install && ./scripts/run_myscript.sh

If sh is your default shell and you want bash, change your script like so:如果sh是您的默认 shell 并且您想要 bash,请像这样更改您的脚本:

#!/bin/bash -l
cd directory1/folder1
conda activate py38
poetry install 
./scripts/run_myscript.sh

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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