I have a batch file that is an entry point for starting a python program in wsl (since it has to use .so shared library file).
In short
The problem is that the line bash.exe --login ./start_program.sh
doesn't call the .bashrc file.
In more detail:
I use WSL2 and Ubuntu18.04 from the windows store.
As I am using conda as a python environment and added the line "export DISPLAY=localhost:0.0" to the .bashrc file to let python show some data, I need the the .bashrc file to be executed before starting the python program.
I changed the ~/.profile script to contain the lines
if [-f "$HOME/.bashrc" ]; then echo $pwd echo $HOME . "$HOME/.bashr" fi
When I start wsl manually, the .bashrc file is executed and everything is fine and when I run the script start_program.sh the program starts. The output at at the start of wsl was as expected:
<empty line> /home/dries
The problems start when I try to run it from a batch file. When I try either of the two
wsl.exe ./start_program.sh bash.exe ./start_program.sh
It doesn't call the .profile file and it fails. When the .bat file contains
bash.exe --login ./start_program.sh
It executes the ~/.profile script, but this doesn't call the .bashrc script. The output of the .profile file is the same (empty line and /home/dries), but the .bashrc file is not called.
I suspect that it has something to do with looking for the files in windows-style or in Unix-style, but I'm not sure.
I hope someone can help me with this issue!
https://stackoverflow.com/questions/66567287/running-bash-script-with-login-session-from-batch-file-doesnt-execute-bashrc March 10, 2021 at 10:57PM
没有评论:
发表评论