Bundle Expect with shell script to bypass installation of Expect - linux

I want to create a shell script that uses the Expect library however Expect is not installed on any of the systems where I want to run the script. I also cannot install the library on these systems either. Can I build Expect from source and then put in same directory as the script? How would you go about this?

Yes you can, and it's not difficult.
Download Expect sources from https://sourceforge.net/projects/expect/files/latest/download?source=files
Unpack sources
gunzip expect.tar.gz
tar -xvf expect.tar
This will create a directory containing the Expect distribution. Change to that directory and
Configure sources for compilation:
./configure --prefix=~/
With --prefix parameter you specify where Expect should be installed. ~/ in my example is a shortcut for current user home directory, so it will be installed locally for your user only and you don't need root privileges this way to install it. In case you have root privileges and want to install it system-wide, you can omit --prefix parameter.
Compile Expect:
make
And install it:
make install
And that's it :)

Related

Error when running emacs make install on remote machine

I am trying to install emacs on a machine that I'm accessing through ssh.
I downloaded the emacs-24.5.tar.gz which I transferred to the root directory of my remote machine.
I ran the ./configure command and then navigated to the emacs-24.5 folder and ran the make install command
I unfortunately ran into this error
/bin/mkdir: cannot create directory `/usr/local/share/icons': Permission denied
/usr/bin/install: cannot create regular file `/usr/local/share/icons/hicolor/128x128/apps/emacs.png': No such file or directory
make: *** [install-etc] Error 1
How do I get emacs working on the remote machine now?
Your description of what steps you took make it a little difficult to know if you missed anything. For example, I'm assuming you ran tar on the tarball before you ran configure or make? Also, little concerned when you say you ran configure and THEN navigated to the 24.5 directory? You should be running make install from the same directory/folder where you ran configure. You also didn't indicate you had run make bootstrap.
The steps should be
scp emacs-24.5.tar.gz user#remote-host:~
ssh user#remote-host
tar xzf emacs-24.5.tar.gz
cd emacs-24.5
./configure
make bootstrap
sudo make install
Notice in the output from the make install there are directions on an additional command you need to run to set movemail permissions. This command also needs to be run under sudo
I'm assuming your not ssh'ing intot the remote host as root as this would be a bad practice. This means that when you do the make install, you need to run the process with root privileges, so you need to use sudo.
You should also check the output from configure and make sure there are no errors. Configure will also list emacs features which are turned on/off depending on whether you have various supporting libraries installed. If you scroll the terminal output from configure up a couple of pages, you will see the printout. If there are features listed with a 'no' which you want/expect, you will need to go through the documentation and work out which additional supporting libraries you need. However, most of the time, with modern linux distros setup for desktop use, everything will likely already be there. Might be different on a server and I can't speak about Windows and what it might require.

How do I "install" a program once I compile it, so I can run it from the command line?

Archlinux.
I downloaded mtools, which includes mcopy, which is what I'm after. The instructions in the INSTALL file say do this:
# ./configure
# make
These worked fine, now I have a bunch of .o files and of course executables.
What do I need to do, so I can just type
# mcopy
and have it run? Since I don't have it "installed" right now, doing that just says
-bash: mcopy: command not found
The usual linux build sequence is
./configure
make
make check
sudo make install
make check attempts to validate if the build took place correctly; not all Makefiles have it but many do. Note you will need sudo make install to do the install in the usual system directories if you are not root.
You can determine which of these options is available for your particular Makefile by
cat Makefile
and reading the labels on the left of the file.
You could create a symbolic link to the application in your /usr/bin folder like
ln -s /fullpath/to/app /usr/bin/aliasnameforapp
Then you can simple call aliasnameforapp from anywhere.

How to create a "configure" file?

Recently I downloaded a file using the following link
git clone git://github.com/mapserver/mapcache.git
Inside the downloaded mapcache folder I can not find a configure file to do "./configure". But the installation help file tell:
Unix compilation instructions
If you are using a git clone rather than a tarball distribution, you
must first run autoconf in the root directory, to create the configure
file from configure.in:
$ autoconf
For unix users, the compilation process should resume to:
$ ./configure
$ make
(as root)
make install-module
The installation script takes care of putting the built module in the
apache module directory.
To do ./configure there should be a configure file isn't it? Please show me how to make one to get rid of this problem.
maintainer speaking ...
mapcache and mapserver are switching to cmake for the next release and the docs for the master branch need updating. You can either use the branch-1-0 branch to continue using autoconf builds, or use cmake with master:
$ mkdir build
$ cd build
$ cmake ..
$ make
$ sudo make install
The help file tells you exactly what you need to do
If you are using a git clone rather than a tarball distribution, you must first run autoconf in the root directory, to create the configure file from configure.in
If you don't already have autoconf installed you'll need to install it in the normal way for your distribution.
The repository seems out of sync with the documentation
there is no configure.in as mentioned in the INSTALL file (nowhere not only in the root directory)
there is just a Makefile.vc file for MSVC++
You should contact the maintainer

Manual install of Vim

I have downloaded the source for VIM (7.3) and compiled it successfully with a make command on a Linux platform. I do not want to run make install though as I think this will overwrite the current version of VIM already installed which will cause problems for other users on the server using VIM 7.0. I would just like to run the newly compiled VIM binary for my user account by putting it in my home bin folder but cannot find it in the VIM folder
Is it possible to do this and if yes, where is the binary after running make?
Thanks!
You should provide the prefix option for the configure script to set the installation directory:
Example:
mkdir /home/john/vim/ && ./configure --prefix /home/john/vim/ && make && make install
Then it will install the vim to /home/john/vim/ and won't write anything over.

Make install, but not to default directories?

I want to run 'make install' so I have everything I need, but I'd like it to install the things in their own folder as opposed to the system's /usr/bin etc. is that possible? even if it references tools in the /usr/bin etc.?
It depends on the package. If the Makefile is generated by GNU autotools (./configure) you can usually set the target location like so:
./configure --prefix=/somewhere/else/than/usr/local
If the Makefile is not generated by autotools, but distributed along with the software, simply open it up in an editor and change it. The install target directory is probably defined in a variable somewhere.
Since don't know which version of automake you can use DESTDIR environment variable.
See Makefile to be sure.
For example:
export DESTDIR="$HOME/Software/LocalInstall" && make -j4 install
make DESTDIR=./new/customized/path install
This quick command worked for me for opencv release 3.2.0 installation on Ubuntu 16. DESTDIR path can be relative as well as absolute.
Such redirection can also be useful in case user does not have admin privileges as long as DESTDIR location has right access for the user. e.g /home//
It could be dependent upon what is supported by the module you are trying to compile. If your makefile is generated by using autotools, use:
--prefix=<myinstalldir>
when running the ./configure
some packages allow you to also override when running:
make prefix=<myinstalldir>
however, if your not using ./configure, only way to know for sure is to open up the makefile and check. It should be one of the first few variables at the top.
If the package provides a Makefile.PL - one can use:
perl Makefile.PL PREFIX=/home/my/local/lib LIB=/home/my/local/lib
make
make test
make install
* further explanation: https://www.perlmonks.org/?node_id=564720
I tried the above solutions. None worked.
In the end I opened Makefile file and manually changed prefix path to desired installation path like below.
PREFIX ?= "installation path"
When I tried --prefix, "make" complained that there is not such command input. However, perhaps some packages accepts --prefix which is of course a cleaner solution.
try using INSTALL_ROOT.
make install INSTALL_ROOT=$INSTALL_DIRECTORY

Resources