I want to use the script command to see my output both in the command line and also store it at the same time, as suggested here.
Now, I can do in my command line:
script
source activate foo
python my_file.py
exit
Quite a hassle if I have to do this often, so I thought I would write a bash script that automatizes this. I tried to literally paste these commands into a command line file, but it would wait for input after script
.
Instead, here's how I thought of implementing this in a bash script (such that I would just run the script and it would do it all:
#!/bin/bash
script ../output.txt -c ' /home/foo/anaconda3/condabin/conda activate myenv3 && python myfile.py'
And this gives me a CommandNotFoundError: Your shell has not been properly configured to use 'conda activate'.
Why am I not using directly "source activate foo" or ". activate foo" as I would usually do? Well, if I try that, I get bash: activate: No such file or directory
I understand that /bin/bash
apparently is not configured to do this in Ubuntu -- what should be my way forward?
conda
, there are variables that have to be set in your~/.bashrc
(should be near the end of the file?). So, you need tosource
that first, before you runconda
. When you start a newbash
shell, it runs it for you.~/.bashrc
that include anaconda paths. So youre suggesting adding ". ~/.bashrc &&" at the beginning of the-c ' /home/....
sequence? Because I tried that and it didn't change the outpuscript
command that you're running is something that perhaps someone else can fill in for you -- I've never done that myself. Maybe try this...in your installation, there is a file. Mine is at:/opt/miniconda3/etc/profile.d/conda.sh
(i.e., fill in the beginning for your system). Try sourcing this instead of.~/bashrc
first?