Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run bash script in Anaconda prompt

Perhaps this is me being an absolute newby with bash, but I can't find anywhere how to accomplish this. I have a python program which needs to run simultaneosly 3 scripts. So far, I just opened 3 spyder Ipython terminals and run each script on them.

I came across something called bash scripts which could easily run the 3 of them at the same time, so I decided to give it a go. I created a file like this in spyder

# -*- coding: utf-8 -*-
"""
Created on Sat Nov 30 14:56:08 2019

@author: Usuario
"""

#!/usr/bin/env bash

python Cornerbot.py &
python Betcornerbot.py &
python Cornerfixture.py &

and saved it as Initializer.sh

From what I gather, to open it on Windows in an anaconda prompt, I need to go to the folder, and tipe sh Initializer.sh but doing so Anaconda just tells me sh is not a command it recognizes

So, obviosly I'm doing something wrong. Am I creating the file in a wrong way (probably)? Is it hte way it is been called from anaconda prompt? I would really appreciate any input as so far what I've looked on the Internet assummes I have a knowledge in bash I actually don't.

like image 324
puppet Avatar asked Oct 27 '25 05:10

puppet


2 Answers

The code to run your Initializer.sh is:

bash  Initializer.sh

Also, the characters of &, I think they are abundant. Since & is used for the Command-line terminal.

While your Initializer.sh is a bash script, which is a programming language like other Python, Java. It needn't & to combine code in different lines.

like image 154
Mai Hai Avatar answered Oct 28 '25 17:10

Mai Hai


If python is your language, why not something like this

#! /usr/bin/env python

import sys
import subprocess

for cmd in ['Cornerbot.py', 'Betcornerbot.py', 'Cornerfixture.py']:
    subprocess.Popen([sys.executable, cmd], shell=False)

Also, regarding your question, perhaps you have to type bash Initializer.sh instead of sh.

like image 41
Diego Torres Milano Avatar answered Oct 28 '25 19:10

Diego Torres Milano