How to run a shell script in Jupyter Notebook?
10,195
Solution 1
You can also simply run any script by typing in a jupyter notebook cell:
%%sh
cat myscript.sh
./myscript.sh
Solution 2
chmod +x Heasoft.sh
should fix this. If not, add #!/bin/bash
at top of the shell script.
Author by
becky.rrr
Updated on June 04, 2022Comments
-
becky.rrr 7 months
So I have this shell script that runs a program that I'll be using in Jupyter, but is bash-oriented, and I tried using the subprocess module,and I get the
error: OSError: [Errno 13] Permission denied
. However, the script is in my directory with the ipynb file, so I should have permission.import subprocess subprocess.call(['./Heasoft.sh'])
That's literally all I have; it works in the terminal but not in the Notebook. Is there something I'm doing wrong?
-
Sha about 3 yearstry like
subprocess.call('./Heasoft.sh', shell=True)
-
becky.rrr about 3 yearsI did that, and it ran! But I got an output of a number, is that normal?
-
Sha about 3 yearsit's better you put expected output from the script and put some code to reproduce the error. then it's easy anyone to help you out. Also do your script file have enough permissions? do
chmod u+x Heasoft.sh
-