Installing and running .sh file in linux mint - linux

I'm using Linux mint and I want to install COMSOL. The problem is that, when I run below code in terminal, there is an error which doesn't make sense. Could anyone solve the problem?
The code I wrote:
./COMSOL_Server_Workaround.sh
the error is:
COMSOL Server Installer Work-around Script
2016 TeAM SolidSQUAD-SSQ
./COMSOL_Server_Workaround.sh: 14: [: Linux: unexpected operator
./COMSOL_Server_Workaround.sh: 15: [: Linux: unexpected operator
-e ERROR: This script should be executed
from the COMSOL Server installation directory
(where comsolsetup.log resides)
picture of files
COMSOL_Server_Workaround.sh contains:
#!/bin/sh
echo
echo COMSOL Server Installer Work-around Script
echo 2016 TeAM SolidSQUAD-SSQ
echo
# assume working dir is COMSOL installation root
COMSOLROOT="$PWD"
# check architecture
[ "`uname`" == "Linux" ] && COMSOL_TARS="fl fl_setup_glnxa64 fl_setup_maclnx fl_jvm_glnxa64 fl_glnxa64 mph_maclnx mph_glnxa64"
[ "`uname`" == "Darwin" ] && COMSOL_TARS="fl fl_setup_maclnx fl_maclnx fl_jvm_maci64 fl_maci64 mph_maclnx mph_maci64"
# tell user he has to run the script from COMSOL Server folder
[ ! -e "$COMSOLROOT/comsolsetup.log" ] && echo -e "ERROR: This script should be executed\n from the COMSOL Server installation directory\n (where comsolsetup.log resides)" && exit 1
# check if we can write to folder
[ ! -w "$COMSOLROOT/comsolsetup.log" ] && echo -e "ERROR: Cannot write to folder \"$COMSOLROOT\".\n If COMSOL Server was installed as root, run this script as root too\n otherwise run it as user which made the installation of COMSOL Server!" && exit 2
# let us extract the source location and check if it accessible
COMSOLDVD="`grep "^cs.installroot" "$COMSOLROOT/comsolsetup.log" | awk '{print $3}'`"
echo "COMSOL SERVER Installation Path = $COMSOLROOT"
echo "COMSOL Server Installation Source Path = $COMSOLDVD"
# check if source is accessible
[ ! -r "$COMSOLDVD/setupconfig.ini" ] && echo "The installaton source \"$COMSOLDVD\" id not accessible! Make sure the DVD is mounted" && exit 3
# now start untaring FL archives
for COMSOL_TAR in $COMSOL_TARS
do
tar -xf "$COMSOLDVD/archives/$COMSOL_TAR.isa" -C "$COMSOLROOT"
done
# Null the bin\tomcat\conf\login.properties
echo > "$COMSOLROOT/bin/tomcat/conf/login.properties"
# Mission complete
echo
echo All done! Enjoy!
echo
exit 0

Related

How to install gprbuild on Linux - Centos7

I have recently dowloaded GNAT Community on my Linux machine (Centos7).
Within /home/parallels/opt/GNAT/2019 there is a folder gprbuild, my understanding is that to install this I need to execute the bootstrap.sh script that is located within gprbuild:
/home/parallels/opt/GNAT/2019/gprbuild/bootstrap.sh
I try to execute the bootstrap.sh script like so...
[parallels#localhost gprbuild]$ ./bootstrap.sh
Then I recieve this error message...
./bootstrap.sh: line 87: gnatmake: command not found
Here is the bootstrap.sh script...
# bootstrap.sh - a simple bootstrap for building gprbuild with xmlada
progname=bootstrap
prefix=/usr/local
bindir=/bin
datarootdir=/share
libexecdir=/libexec
srcdir=$PWD
xmlada_src=../xmlada
CC=${CC:-cc}
GNATMAKE=${GNATMAKE:-gnatmake}
CFLAGS=${CFLAGS:-$CFLAGS}
GNATMAKEFLAGS=${GNATMAKEFLAGS:--j0}
usage() {
cat >&2 <<EOF
usage: $progname [options]
Options [defaults in brackets]:
--prefix=DIR installation prefix [$prefix]
--bindir=DIR user executables [PREFIX/bin]
--libexecdir=DIR program executables [PREFIX/libexec]
--datarootdir=DIR read-only arch.-independent data root [PREFIX/share]
--srcdir=DIR source code path [$PWD]
--with-xmlada=DIR xmlada source path [$xmlada_src]
--build build only but do not install
--install install only, skip build steps
Environment variables:
CC specify C compiler [$CC]
CFLAGS set C and Ada compilation flags [$CFLAGS]
DESTDIR optional for staged installs
GNATMAKE specify gnatmake Ada builder [$GNATMAKE]
GNATMAKEFLAGS additional Ada builder flags [$GNATMAKEFLAGS]
EOF
exit 0
}
error() {
printf -- "%s: $1" "$progname" "${#:2}" >&2
exit 1
}
while :; do
case $1 in
--prefix=?*) prefix=${1#*=} ;;
--bindir=?*) bindir=${1#*=} ;;
--libexecdir=?*) libexecdir=${1#*=} ;;
--datarootdir=?*) datarootdir=${1#*=} ;;
--srcdir=?*) srcdir=${1#*=} ;;
--with-xmlada=?*) xmlada_src=${1#*=} ;;
--build) MODE="build";;
--install) MODE="install";;
-h|-\?|--help) usage ;;
*=*) error '%s: Requires a value, try --help\n' "$1" ;;
-?*) error '%s: Unknown option, try --help\n' "$1" ;;
*) break # End of arguments.
esac
shift
done
set -e
inc_flags="-I$srcdir/src -I$srcdir/gpr/src -I$xmlada_src/sax -I$xmlada_src/dom \
-I$xmlada_src/schema -I$xmlada_src/unicode -I$xmlada_src/input_sources"
# Programs to build and install
bin_progs="gprbuild gprconfig gprclean gprinstall gprname gprls"
lib_progs="gprlib gprbind"
# Build
if [ "x"${MODE} == "x" ] || [ ${MODE} == "build" ];
then
command $CC -c $CFLAGS "$srcdir"/gpr/src/gpr_imports.c
for bin in $bin_progs; do
command $GNATMAKE $inc_flags "$bin"-main -o "$bin" $CFLAGS $GNATMAKEFLAGS -largs gpr_imports.o
done
for lib in $lib_progs; do
command $GNATMAKE $inc_flags "$lib" $CFLAGS $GNATMAKEFLAGS -largs gpr_imports.o
done
fi;
# Install
if [ "x"${MODE} == "x" ] || [ ${MODE} == "install" ];
then
mkdir -p "$DESTDIR$prefix$bindir"
mkdir -p "$DESTDIR$prefix$libexecdir"/gprbuild
mkdir -p "$DESTDIR$prefix$datarootdir"/gprconfig
mkdir -p "$DESTDIR$prefix$datarootdir"/gpr
install -m0755 $bin_progs -t "$DESTDIR$prefix$bindir"
install -m0755 $lib_progs -t "$DESTDIR$prefix$libexecdir"/gprbuild
install -m0644 "$srcdir"/share/gprconfig/*.xml -t "$DESTDIR$prefix$datarootdir"/gprconfig
install -m0644 "$srcdir"/share/gprconfig/*.ent -t "$DESTDIR$prefix$datarootdir"/gprconfig
install -m0644 "$srcdir"/share/_default.gpr "$DESTDIR$prefix$datarootdir"/gpr/_default.gpr
fi
I have been told that I need to install xmlada prior to installing gprbuild, then I have read elsewhere that I need to install gprbuild to be able to install xmlada!
I have a similair issue when attempting to install xmlada, the shell script within the xmlada folder is called install-sh, when I attempt to install this I am told there is no input file specified...
[parallels#localhost xmlada]$ ./install-sh
./install-sh: no input file specified.
I apreciate this is really two questions in one, but I felt I had to explain it this way, as I am unsure which library needs to be installed first, and also how do I actually install them.
Any help would be greatly apreciated! I hope you're all having a good weekend... :)
Thanks,
Lloyd
Just install gcc-ada, or search in your package manager for gcc-ada (may change its name), gnat* commands come in this package

Python virtual environment not activating from bash script

Now before you mark this as a duplicate, I have tried the solution posted here and they aren't working for me. I tried making an alias and I tried creating a function as so:
activate () {
echo Activating Virtual Environment...
source alexa/bin/activate
}
activate
But my script just gets run through without a virtual environment getting activated. The script is being run from the same directory as my virtual environment directory, alexa.
For clarity, the other solution I tried was to make an alias:
alias activate="source alexa/bin/activate"
activate
That didn't work and gave me an error that ./alexaEnvSetup.sh: line 43: activate: command not found.
Any thoughts or ideas?
EDIT: I think it is worth mentioning that the echo command does print out when I do this. So the function is getting entered. The virtual environment is just not getting activated.
EDIT: Adding full code:
#!/bin/bash
if [[ "$OSTYPE" == "linux-gnu" ]]; then
echo Operating system: Linux
elif [[ "$OSTYPE" == "darwin"* ]]; then
echo Operating system: Mac OSX
echo
# Install Python 3.6.5 using `curl`
curl -O https://www.python.org/ftp/python/3.6.5/Python-3.6.5.tgz
tar xf Python-3.6.5.tgz
cd Python-3.6.5
./configure
make
make install
echo
echo Python Version 3.6.5 Installed
echo
# Install Pip
curl -O http://bootstrap.pypa.io/get-pip.py
/usr/local/bin/python3.6 get-pip.py
echo
echo Pip Installed
echo
# Install virtualenv
pip install virtualenv
echo
echo Virtual Environment Installed
virtualenv -p python3 alexa
echo Created Virtual Environment, \"alexa\"
activate () {
echo Activating Virtual Environment...
source /Users/XXXX/Auto-Lab/Commerce/alexa/bin/activate
}
export -f activate
activate
echo Virtual Environment, \"alexa\", Created and Activated
echo
# All packages (time, urllib, and json) should come default with Python3
elif [[ "$OSTYPE" == "cygwin" ]]; then
# POSIX compatibility layer and Linux environment emulation for Windows
echo Operating system: Cygwin
elif [[ "$OSTYPE" == "msys" ]]; then
# Lightweight shell and GNU utilities compiled for Windows (part of MinGW)
echo Operating system: Msys
elif [[ "$OSTYPE" == "win32" ]]; then
echo Operating system: Windows32
elif [[ "$OSTYPE" == "freebsd"* ]]; then
echo Operating system: FreeBSD
else
echo Operating system unknown.
fi
use the full path to the activate script in the function: source /path/to/activate
export the function: export -f activate
ensure the script is a bash script: #!/bin/bash
The following works for me using Anaconda virtual env, perhaps it will work with yours also?
#!/usr/bin/env bash
# do bash stuff
# Python env
PATH=/home/username/path/to/activate/bin
python -u /script/to/run

Shell script to verify docker installation on Linux

I want to write a shell script which verifies whether docker is installed or not.
If docker is installed:
$ docker -v
Docker version 1.7.0, build 0baf609
$ echo $?
0
If docker is not installed:
$ docker -v
The program 'docker' is currently not installed. You can install it by typing:
apt-get install docker
$ echo $?
127
Here is my script:
#!/bin/bash
docker -v
if echo $? = 128 ; then
echo "The program 'docker' is currently not installed."
else
echo "Continuing with dockerized way"
fi
here for testing purpose, I ran it on the machine where docker is not installed, I kept 127 = 128, condition is wrong, so it should go in else, but still it prints The program 'docker' is currently not installed. I would like to know what I am missing here.
The correct syntax is:
if [ $? -eq 128 ]; then
...
To make it even more robust, you might want to check:
if [ $? -ne 0 ]; then
...

/usr/local/bin/qtpasswd: No such file or directory

I'm Trying to install Darwin Streaming Server on virtualbox ubuntu desktop amd64.
Running the darwin setup at the end gives this
./Install: line 406: /usr/local/bin/qtpasswd: No such file or directory
./Install: line 406: /usr/local/bin/qtpasswd: No such file or directory
Setup Complete!
And When I hit the url on the browser it says
"Server is not running please start it before attempting to administer it".
you can post your complete installing log.
i run into the same error prompt as yours while i build my Darwin Stream Server-5.5.5 source on centOS6.5 .
you can modify part of the installing script "Install" (about line 191)
# Add the unprivileged user qtss as the server's run user
echo "Creating unprivileged user to run the server = \"qtss\"."
if [ $INSTALL_OS = "Linux" ]; then
/usr/sbin/useradd -M qtss > /dev/null 2>&1
else
/usr/sbin/useradd qtss > /dev/null 2>&1
fi
into
# Add the unprivileged user qtss as the server's run user
echo "Creating unprivileged user to run the server = \"qtss\"."
if [ $INSTALL_OS = "Linux" ]; then
groupadd -r qtss
/usr/sbin/useradd -M -r -g qtss qtss > /dev/null 2>&1
else
/usr/sbin/useradd qtss > /dev/null 2>&1
fi
then try to run ./Install again.
it works for me.
make sure you have installed perl before you run ./Install

Linux Shell commands work when manually typed. Don't work when put in a script file

I have this Linux script called LinuxCommands used to check to make sure that my machine has the pre-requisites that Oracle requires for an install. The script will work if I copy all of the text from a Windows notepad and paste it into my Linux terminal, but don't work when I ftp over the actual .sh file to the Linux terminal and run it by calling bash. The script does not work at all if I use ./ notation. I am using root for both copying the commands and running the file using ./ or bash notation. The Linux script is as follows
#!/bin/bash
#Install packages, upgrade those that already exist
PKG_OK=$(dpkg-query -W --showformat='${Status}\n' binutils-2.17.50.0.6 compat-libstdc++-33-3.2.3 compat-libstdc++-33-3.2.3 elfutils-libelf-0.125 elfutils-libelf-devel-0.125 gcc-4.1.2 gcc-c++-4.1.2 glibc-2.5-24 glibc-common-2.5 glibc-devel-2.5 glibc-headers-2.5 ksh-20060214 libaio-0.3.106 libaio-devel-0.3.106 libgcc-4.1.2 libstdc++-4.1.2 libstdc++-devel make-3.81 sysstat-7.0.2|grep "install ok installed")
echo Checking for libraries: $PKG_OK
if [ "" == "$PKG_OK" ]; then
echo "Not Installed. Installing"
yum -y install binutils-2.17.50.0.6 compat-libstdc++-33-3.2.3 compat-libstdc++-33-3.2.3 elfutils-libelf-0.125 elfutils-libelf-devel-0.125 gcc-4.1.2 gcc-c++-4.1.2 glibc-2.5-24 glibc-common-2.5 glibc-devel-2.5 glibc-headers-2.5 ksh-20060214 libaio-0.3.106 libaio-devel-0.3.106 libgcc-4.1.2 libstdc++-4.1.2 libstdc++-devel make-3.81 sysstat-7.0.2
fi
#Adds oinstall and dba groups
/bin/id -g oinstall 2>/dev/null \
[ $? -eq 0 ] && echo "Group found" || sudo /usr/sbin/groupadd oinstall
/bin/id -g dba 2>/dev/null \
[ $? -eq 0 ] && echo "Group found" || sudo /usr/sbin/groupadd dba
#Adds oracle user in oinstall group
if id -u oracle >/dev/null 2>&1; then
echo "user exists"
else
/usr/sbin/useradd -m -g oinstall -G dba oracle
fi
#Creates installation directory for Oracle
chown -R oracle:oinstall /u00/Oracle12CInstall
chmod -R 775 /u00/Oracle12CInstall
#Adds Oracle variables to the Oracle User's profile.
cat <<EOF > /home/oracle/.bash_profile
ORACLE_BASE=/u00/Oracle12cInstall
ORACLE_HOME=$ORACLE_BASE/test2/product/121
LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/lib
export ORACLE_BASE
PATH=$PATH:$HOME/bin:$ORACLE_HOME/bin:/usr/X11R6/bin:/usr/lib
export PATH
export ORACLE_BASE ORACLE_HOME LD_LIBRARY_PATH
umask 022
EOF
The error I get when I run it on a Linux terminal is
bash LinuxCommands
: command not found 3:
LinuxCommands: line 4: dpkg-query: command not found
Checking for libraries:
LinuxCommands: line 47: syntax error: unexpected end of file
This question was solved by running
dos2unix LinuxCommands
Command above removed DOS line endings from my file snd it was able to run sucessfully.

Resources