Can Execute Commands in Terminal But Not from Text File - linux

I'm running code using Ubuntu on a WSL. Every time I edit some C files I need to execute a makefile and run an installer to ensure that the changes are reflected in the python package that I am using. The set of commands I need to execute is
make clean
make
cd python
python setup.py install --user
This works perfectly when I execute them in the terminal. In order to make my life easier, I decided to put these commands in a text file Compile.txt to be executed whenever I need to compile the relevant files. I found this question and tried to replicate its solution. However, whenever I type ./Compile.txt into the terminal I get the error
'. Stop. No rule to make target 'clean
gcc -o .o
gcc: fatal error: no input files
compilation terminated.
make: *** [<builtin>: .o] Error 1
./Compile.txt: line 7: cd: $'python\r': No such file or directory
python: can't open file 'setup.py': [Errno 2] No such file or directory
Can anyone explain what I've done wrong? I apologise for any misuse of terminology as I'm still quite new to Linux.
Thanks in advance.

Related

How to read errors when compiling from source code

Goal:
Compile multiple libraries from source code to ultimately install a fully compiled version of FFmpeg with desirable libraries attached.
Problem:
During the compilation, all libraries (seemingly) are successful until liblv2 is reached.
Error output via terminal:
building lv2 - version 1.18.10
=======================
Downloading https://lv2plug.in/spec/lv2-1.18.10.tar.xz as lv2-1.18.10.tar.bz2
... Done
Extracted lv2-1.18.10.tar.bz2
$ python3 ./waf configure --prefix=/home/jman/tmp/ffmpeg/ffmpeg-build/workspace --lv2-user
python3: can't open file '/home/jman/tmp/ffmpeg/ffmpeg-build/packages/lv2-1.18.10/./waf': [Errno 2] No such file or directory
Failed to Execute python3 ./waf configure --prefix=/home/jman/tmp/ffmpeg/ffmpeg-build/workspace --lv2-user
Where I need guidance:
python3: can't open file '/home/jman/tmp/ffmpeg/ffmpeg-build/packages/lv2-1.18.10/./waf': [Errno 2] No such file or directory
My question:
What does this part mean?
lv2-1.18.10/./waf'
specifically the part /./
My best guess so far is it:
obviously is looking for a directory it can't find (perhaps because it truly doesn't exist)
The missing 'waf' directory should be located inside either the "${PACKAGES}" or "${WORKSPACE}" directory.
The ${PACKAGES}" path in this script should = /home/jman/tmp/ffmpeg/ffmpeg-build/packages
The ${WORKSPACE}" path in this script should = /home/jman/tmp/ffmpeg/ffmpeg-build/workspace
The full build script:
https://github.com/slyfox1186/ffmpeg-build-script/blob/master/scripts/build-ffmpeg
I tried my best to make this worth sometimes time without giving too much info... sorry if I don't meet the expectations of this forum.
Am I even close?

Make Install gives an error after properly cleaned and readied

I have been working on a project that requires me to use make clean, make ready, then make install to get files to run a simulation. I got make clean and make ready to work on the same area but as soon as I try to run a make install it won't work and gives this error:
ifort -w -O -tpp7 -c main.f
make: ifort: Command not found
make: *** [makefile:640: main.o] Error 127
this makes no sense to me as I don't have a Linux system and I'm running on a windows system with WSL and Ubuntu. There is a makefile if that is helpful but I don't really know what to look for in that file. Thanks in advance.

Compiling mex files fails using shell script

I have some mex files, which until recently were working perfectly. They require some compiler flags which matlab won't pass using the ordinary mex command, so I've been using a shell script to compile them, accomplished from within matlab using !sh mexfile_compile.sh. This has worked fine for about a year.
I've recently found (with no change to the version of GCC or g++ I have installed), that my files won't compile any more; I get the error sh: 0: Can't open mexfile_compile.sh, even if I run matlab as root.
Interestingly, if I run !ls | grep mexfile_compile.sh on the active directory from the matlab prompt, I get a single result: mexfile_compile.sh.save, though if I run the same command (without the !) in a normal terminal window, I don't get the .save at the end. It's worth pointing out that the script runs perfectly well from the terminal using sh mexfile_compile.sh.
Does anyone know what's going on here or how I can fix it?

cygwin binary exec format error

I have a script file that I was given to run in windows using Cygwin. When I try to use this file I get the following error
-bash: /sigdet/filename: cannot execute binary file: Exec format error.
sigdet is the folder within the Cygwin directory that I have the script. Rawdata is the name of the directory with the raw data files that the script is supposed to analyze.
To try and solve this, I have changed the file permissions, I have checked to make sure that it is on a 64 bit machine and the script appears to have compiled on a 64-bit machine. After these steps, I don't know what else the problem could be. Here are the commands I've entered:
I first changed the directory like so:
$ cd /sigdet/
Then I ran the script that is suppsed to work:
$ /sigdet/filename -i rawdata
Does the script file need to have an extension in windows? I've tried changing it to a .sh extension with no luck. I'm told that it just works on other windows machines just how it is.
Thanks to anyone that can help with this.
Your file is not an executable. It most probably contains ELF executable which is designed for Linux operating system, or it's corrupt.
If your file was a shell script, or in fact anything that contained plain text, you'd get different errors (such as, "expected command name" or "unknown command: XYZ" etc.)
Scripts are not supposed to have file extensions, like any executables. On the other hand, they should have shebangs: small text located in the first line that tells the system the path to the interpreter. For example, a Python executable script might be named whatever and have #!/usr/bin/python3 or similar in the first line. When you run it through ./whatever in the shell, it'll look for python3 in /usr/bin and run your file like this: /usr/bin/python3 ./whatever. (In fact, thanks to this you can also specify additional parameters that get passed to the interpreter.)
There is also a chance that your script is valid, but it contains a shebang pointing to bad interpreter. If that is the case, then most likely the path is correct, otherwise you'd get /whatever/interpreter: bad interpreter: no such file or directory error or similar. But then, all the other points apply to the interpreter (which is just another executable...)
If the script and/or interpreter was meant to be executed on Windows or Cygwin at least, it should either contain aforementioned shebang (#!/path in the first name) or it should be Windows executable (in which case the file data should begin with MZ letters, you can inspect it in notepad.) If it isn't, it means the files you were given can't run on Cygwin.
Had this same problem. Added the following at the top of makefile:
export ARCH = CYGNUS
What happened during the make process is that Linux and Windows versions of the executables were created. You just have to use ./.exe versions.
In my case, I got the error when I used a wrong command to compile my C program. When I used the right command:
gcc myprog.c -o myprog.exe
the error was resolved.

How do I get PhantomJS / CasperJS working on Cygwin?

I am having trouble getting PhantomJS and CasperJS working within the cygwin environment. I am very new to cygwin. I was able to download both packages for windows and run them via windows cmd.
To get them to work with Cygwin, I tried the following:
I downloaded the tar/zip files for both PhantomJS and CasperJS, I copied the contents on the "bin" folders into C:\cygwin\bin. But when I type in phantomjs on cygwin I get:
/usr/bin/phantomjs: cannot execute binary file
Then, I tried to do:
pip install git+git://github.com/ariya/phantomjs
but after waiting for a while I get the following response:
Downloading/unpacking git+git://github.com/ariya/phantomjs Cloning
git://github.com/ariya/phantomjs to /tmp/pip-dCF1oZ-build Running
setup.py egg_info for package from
git+git://github.com/ariya/phantomjs
Traceback (most recent call last):
File "", line 16, in
IOError: [Errno 2] No such file or directory: '/tmp/pip-dCF1oZ-build/setup.py'
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "", line 16, in
IOError: [Errno 2] No such file or directory:
'/tmp/pip-dCF1oZ-build/setup.py'
---------------------------------------- Command python setup.py egg_info failed with error code 1 in /tmp/pip-dCF1oZ-build Storing
complete log in /home/tkondapalli/.pip/pip.log
Does any one have any advice on how to get this working? Does anyone use PhantomJS/CasperJS in the cygwin environment?
Also, I thought the .exe I am downloading and copying into the C:\cygwin\bin directory is the one for linux, so maybe that doesn't work? So this means that I need to compile from source on cygwin...
So, I started following directions for building phantomjs: http://phantomjs.org/build.html
The first thing we need to do is build OpenSSL for devel, but again I don't know how to do this for cygwin! So I just skipped this step for now, which is probably not right.
I did download the source from github and tried to build it. It failed with the follow error:
Makefile:217: recipe for target `qtemporaryfile.o' failed make: *
[qtemporaryfile.o] Error 1 make: * Waiting for unfinished jobs....
make: *** No targets specified and no makefile found. Stop.
./build.sh: line 90: src/qt/bin/qmake: No such file or directory
Earlier I had downloaded the executables for Linux, so it was not working. This time I downloaded the executables for windows and put it in C:/cygwin/bin, and it worked!
I don't understand why I would need to download the windows executable, when cygwin is a linux emulator. This confuses me, but at least it works now!
From the Cygwin website:
Cygwin is not: a way to run native Linux apps on Windows. You must rebuild your application from source if you want it to run on Windows.
Every applications needs to be rebuilt in order to be use on Windows (as it does not produce an elf file, but .exe file that requires the cygwin dll).
Nevertheless, the shell in cygwin can execute any windows's .exe file (such as ping, ipconfig, cmd, etc.), which is why you are able to run the windows version of PhantomJS under cygwin.
First, download and install Node.js from http://nodejs.org/download
Close and reopen Cygwin and type:
$ npm install -g phantomjs
$ npm install -g casperjs
Just ran into this issue, placing the phantomjs executable in C:/cygwin/bin solved everything. After that all you need to do is run the command C:/cygwin/bin/phantomjs to initialize the application.
Although Cygwin doesn't replace the standard cmd prompt, it is pretty useful!

Resources