Wrapper Scripts

A better solution is to write a wrapper script to set environment variables (e.g. PATH, LD_LIBRARY_PATH, etc) when needed. Most of the applications in the Business, Engineering, Science, and Software menus use wrapper scripts to set the correct environment variable for an application to run.

  1. To create your own wrappers script, create a text file within your Wrappers directory making sure the name of the file is unique so as not to conflict with existing commands unless you intend overwrite one of the wrapper scripts or symbolic links listed at the bottom of this page.
    Note: If your Wrappers directory is missing simply create it, i.e. mkdir Wrappers

For example a wrapper script to set a PYTHONPATH, called my_python_paths would contain something like,

#!/bin/bash
#
# My Python Paths
#

export PYTHONPATH=$HOME/my_py/lib/python3.6/site-packages:$HOME/my_py/lib64/python3.6/site-packages

bash

Note the bash command at the bottom of the script. The will hold the script open so the paths are set. Without the bash you can still run the wrapper script by executing the source command, for the example above,

source my_python_paths

  1. Then set the permissions of the script to be an executable, by running command,
chmod 755 wrapper_script

For the the above example,

chmod 755 my_python_paths
  1. To test your wrapper script open new terminal and execute the wrapper script. For the the above example,
my_python_paths

Then check the wrapper script has set the variable, echo variable name, for the the above example,

echo $PYTHONPATH

It should return the variable value, for the the above example

/home/username/my_py/lib/python3.6/site-packages:/home/username/my_py/lib64/python3.6/site-packages
  1. Another example, create your own PyCharm wrapper script to launch PyCharm IDE to use your own install of Python e.g. Anaconda3
    Create a text file call pycharm within your bin directory that contains the following,
#!/bin/bash
#
# MyPycharm Wrapper Script
#

export PATH=$HOME/anaconda3/bin:$PATH

/usr/local/bin/pycharm

Then set the permissions of the script to be an executable, by running command,

chmod 755 pycharm

Now to launch PyCharm with you own python install, select from the the Applications menu → Software → PyCharm Community Edition.

Modifying an Existing Wrapper Script
As previously mentioned most of the applications in the Business, Engineering, Science, and Software menus use wrapper scripts.

  1. To modify one of these scripts to add additional variables copy the required wrapper script from /usr/local/bin to your bin directory.

    For example you may wish to add an add CUDA paths to PyCharm. Copy the wrapper script pycharm to your bin directory.

  2. Edit the wrapper script and add the desired CUDA, for example, CUDA 9.0

#!/bin/bash
#
# Launch Script For PyCharm
#
#

export PATH=/usr/local/pycharm-community-2018.4/bin:$PATH

export PATH=/usr/local/cuda-9.0/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda-9.0/lib64:/usr/local/cuda-9.0/extras/CUPTI/lib64:$LD_LIBRARY_PATH

# start PyCharm
pycharm.sh

Next time to start PyCharm from the Applications menu it will launch with the CUDA paths added.
Below is list of wrapper scripts and symbolic links present in /usr/local/bin

abaqus_cae
abaqus_doc
abaqusenv
abaqus_viewer
ansysacp
ansys_autodyn
ansysbg
ansysbgsmp
ansyscfdpost
ansyscfx
ansyschoose
ansysemchoose
ansysem_edt
ansysem_siwave
ansysenv
ansysfluent
ansysforte
ansysforte_cmd
ansysgui
ansysgui_lsdyna
ansysicem
ansyspl
ansyspolyflow
ansysturbo
ansyswb
ansysworkdir
arb
blender
bowtie-tophat
CFD-ACE-GUI
CFD-ACE-PLOTTER
cfdbg
cfdchoose
cfdenv
CFD-FASTRAN-GUI
CFD-GEOM
CFD-Toolkit
CFD-VIEW
chimera
cnode
codeblocks-fortran
comsol
comsolcas
cstbg
deploytool
eclipse-cpp
eclipse-java
eclipse-parallel
eeglabbg
eeglab_desktop
fasqc
fiji_setup
fluentbg
gephi
grass
grass74
grass-gui
gromacs_shell
igv
imagej
intel_xe_2016
intel_xe_2016_shell
intel_xe_2018
intel_xe_2018_shell
jmon
jmonitor
loadcheck
lsdynabg
lsdynabgsmp
lsprepost
matbg
matbg2
matchoose
math
mathematica
Mathematica
MathematicaScript
MathKernel
mathmcc
matlab
matnogui
matnojvm
maxquant_gui
maxquant_shell
mbuild
mcc
mex
mono5_shell
monodevelop_shell
nag_shell
ncbi-blast-ihpc_shell
ncbi-blast_shell
netbeans
netlogo
nsight
oligotype_shell
omnetpp-launcher
omnetpp_shell
openfoam-v1712
openfoam-v1712_shell
osg_shell
paraview5
perseus_gui
picrust_shell
ppmtompeg
pycharm
qiime_shell
R352-dyn
R35-dyn
R-dyn
recreate_profile
rh_devtools_shell_31
rh_devtools_shell_41
rh_devtools_shell_61
rh_devtools_shell_71
rh_git_shell
rh_llvm_shell_7
rh_python36_shell
rstudio
runbg
salome
sas94
setpyenv
SimManager
sing_anaconda
sing_biogeme
sing_miniconda
sing_mysql
sing_ns3
sing_pytorch
sing_qiime2
sing_ros
sing_tensorflow
sing_tensorflow_gpu
singularitybg
singularity_shell
Slicer
spssenv
startpyenv
stataenv
stata-gui
stats
tecplot
tecplotenv
vim8
visit
vmd
weka
wolfram
WolframKernel
wolframscript

你可能感兴趣的:(Wrapper Scripts)