简体   繁体   中英

How to make a ubuntu executable and run it in my install file

This is the install file below (sandhi-install.sh). Currently after installing it can only be run from the terminal. I want to make it terminal independent. Making a Ubuntu executable explains how to create an executable but where should I put that code. I think it should be in the install file itself because we want the icon to appear on the desktop after installation completes. I have no prior experience in Shell scripting and bash so sorry if i miss any important information. Please ask if you need any other file. My aim is basically to run sandhi independent of the terminal.

#!/bin/bash

echo "Installing the required dependencies"

sudo apt-get -y install git-core autoconf automake make libtool g++ python-dev swig \
pkg-config libboost1.48-all-dev libfftw3-dev libcppunit-dev libgsl0-dev \
libusb-dev sdcc libsdl1.2-dev python-wxgtk2.8 python-numpy \
python-cheetah python-lxml doxygen python-qt4 python-qwt5-qt4 libxi-dev \
libqt4-opengl-dev libqwt5-qt4-dev libfontconfig1-dev libxrender-dev \
python-serial python-matplotlib

echo "Sciscipy installation starting"
git clone https://github.com/manojgudi/sciscipy-1.0.0.git
cd sciscipy-1.0.0/
sudo ./install

echo "Starting Sandhi installation"
cd ../
git clone http://github.com/manojgudi/sandhi.git
cd sandhi/
git submodule init
git submodule update
git pull origin master
git submodule update

mkdir build
cd build/
cmake ../
make -j 2
sudo make install
sudo ldconfig

echo "Sandhi installation complete. Go to command line and type Sandhi to start Sandhi"

Your script already has all the right ingredients for being a *nix executable - a shebang line and what at least looks like valid code for the interpreter ( /bin/bash ). All you need to do is to give the relevant user and/or group (or everybody) execute access on the file. For example, if you're the owner of the file:

sandhi@host$ ls -l sandhi.sh
-rw-r--r--  1 purak users 3.5K Oct 11 16:55 sandhi.sh
sandhi@host$ chmod u+x sandhi.sh

Now you can execute it:

sandhi@host$ ls -l sandhi.sh
-rwxr--r--  1 purak users 3.5K Oct 11 16:55 sandhi.sh
sandhi@host$ ./sandhi.sh

For the rest of the question it's unclear what you're asking. The accepted answer to Making a Ubuntu executable says that if the executable foo.bin is in /usr/local/bin (a sensible destination for custom executables) the line in the desktop entry should be Exec=/usr/local/bin/foo.bin .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM