Score:0

Doing simultaneous things in a bash script?

gb flag

I am trying to run this bash script:

source ~/miniconda3/etc/profile.d/conda.sh
gnome-terminal --tab -e "conda activate env_num_1 && jupyter lab"
conda activate env_num_2
cd some_path 
gnome-terminal --tab -e "sleep 5 && firefox myurl" #
bash "command that starts web server" #It takes a few moment to boot up hence the sleep function

For whatever reason gnome-terminal are opening the tabs but neither are executing the commands it has been given. What can I do to fix this?

EDIT: Tried suggestion below (gnome-terminal --tab -- sleep 5 && firefox myurl) in just the terminal, I get

Failed to execute child process “conda activate machine-learning-env & jupyter lab”: Failed to execve: No such file or directory

EDIT 2: Kept on fiddling with it, this gives roughly what I want.

#!/bin/bash
source ~/miniconda3/etc/profile.d/conda.sh

conda activate env1 && jupyter lab &
(conda activate env2
cd mydir
bash webui.sh & (sleep 10 && firefox myurl))

but it seems to do everything in one terminal. I would like to close one program and keep the other at my discretion.But I guess there must be another way?

Amirreza avatar
at flag
the `-e` option is tricky, maybe using `--` instead of -e helps? like: `gnome-terminal --tab -- sleep 5 && firefox myurl`
Hyouin Kyouma avatar
gb flag
Sadly not working :(
cc flag
Your error message does not match what you say you are running. Try removing the quotes around the command. The firefox suggestion example works for me.
Score:0
my flag

I understand, your want to do something like that:

gnome-terminal --tab -- sh -c "conda activate env_num_1 && jupyter lab"

@see warning in man gnome-terminal for --command, -e=COMMAND option

Add a read command for debugging:

gnome-terminal --tab -- sh -c "conda activate env_num_1 && jupyter lab; read -p \"press enter key\""
Hyouin Kyouma avatar
gb flag
"ModuleNotFoundError: No module named 'jupyter_core'". Hm. Jupyter lab is installed and if I just type it manually in console it does work. So I guess somehow the new shell is not seeing it.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.