Difference between revisions of "Writing Script"

From DeepSense Docs
Jump to: navigation, search
(Created page with "Bash scripts are used to put multiple commands that you run on command line at one place. Anything you put into bash scripts will work exactly same as they work on command lin...")
 
 
Line 1: Line 1:
Bash scripts are used to put multiple commands that you run on command line at one place. Anything you put into bash scripts will work exactly same as they work on command line. Bash is available by default on Linux and macOS operating systems ,however , for windows you can install Git Bash to work with bash scripts. For creating the bash scripts, save the file with .sh extension. To run this bash script, use keyword bash followed by the name of the file
+
Bash scripts are used to put multiple commands in one place that you run on the command line. Anything you put into bash scripts will work exactly the same as they work on the command line. Bash is available by default on Linux and macOS operating systems, however, for windows, you can install Git Bash to work with bash scripts. For creating the bash scripts, save the file with the .sh extension. To run this bash script, use the keyword bash followed by the name of the file
  
<code> For example : if the File Name is example.sh, run this file by writing “bash example.sh” </code>
+
For example : if the File Name is example.sh, run this file by writing “bash example.sh”  
  
 
== Writing Bash scripts ==
 
== Writing Bash scripts ==
In bash scripts, you can put all the commands which you feel are required to run every time when you start with your project. This will save your time.
+
In bash scripts, you can put all the commands which you feel are required to run every time when you start your project such as activate Conda environment, Job submission, open Jupyter Notebook, etc.. This will save your time. Below is the example of bash script with name "example.sh"
  
<code>For example
+
<b>For example:</b>
example.sh</br>
 
<code>#!/bin/bash</br>
 
source /opt/anaconda2/etc/profile.d/conda.sh</br>
 
conda activate</br>
 
bsub -Is -gpu - bash</br>
 
jupyter notebook --no-browser --ip=0.0.0.0</br></code>
 
  
Above script will execute all the commands
+
example.sh
 +
 
 +
#!/bin/bash</br>
 +
source /opt/anaconda2/etc/profile.d/conda.sh</br>
 +
conda activate</br>
 +
bsub -Is -gpu - bash</br>
 +
jupyter notebook --no-browser --ip=0.0.0.0</br>
 +
 
 +
 
 +
The above script will execute all the commands in bash shell.

Latest revision as of 20:18, 3 December 2020

Bash scripts are used to put multiple commands in one place that you run on the command line. Anything you put into bash scripts will work exactly the same as they work on the command line. Bash is available by default on Linux and macOS operating systems, however, for windows, you can install Git Bash to work with bash scripts. For creating the bash scripts, save the file with the .sh extension. To run this bash script, use the keyword bash followed by the name of the file

For example : if the File Name is example.sh, run this file by writing “bash example.sh” 

Writing Bash scripts

In bash scripts, you can put all the commands which you feel are required to run every time when you start your project such as activate Conda environment, Job submission, open Jupyter Notebook, etc.. This will save your time. Below is the example of bash script with name "example.sh"

For example:

example.sh

#!/bin/bash
source /opt/anaconda2/etc/profile.d/conda.sh
conda activate
bsub -Is -gpu - bash
jupyter notebook --no-browser --ip=0.0.0.0


The above script will execute all the commands in bash shell.