Error "syntax error near unexpected token '&' - trying to run a file from command line within an application - linux

I am a newbie to Linux and I am only really using it to use a program for my final year thesis. I have got to grips with the language for the program but am having issues with actually running it in Linux. The program is called "CACTUS" and all documentation can be found here.
I have extracted the application file and I have made the executable as instructed in the install.txt file:
"Installation of CACTUS for Linux or Mac machines.
Unzip the directory and put in desired location. On terminal cd into the
correct directory (you should be able to see the makefiles).
Create the executable by typing:
$make
or
$make -f Makefile.gfortran
on the terminal. The executable will be called cactus and be located in the
directory one level above.You can add the executable's location to your path
so that you can call it by simple typing cactus on the terminal instead of
the complete path.
cd into the Test/RegTest directory
$cd ./Test/RegTest
and run the RegTest by executing runreg.py with the path to the CACTUS
executable as an argument (or just the name of the executable if you added it
to your path).
$./runreg.py ../../../cactus
or
$./runreg.py cactus
The output should say 'No differences' for all three tests. Note: if you have
Python 3 installed used runreg_p3.py instead.
CONGRATULATIONS! You have successfully installed CACTUS.
I have run this and I didn't get the "No Differences" returned on the runreg.py. I continued anyway as I did not know why or how I could fix this. (This may be a root cause of my overally problem here)
As I progressed I have been trying to open an input file "TestVAWT.in" from TestCase2 with the following command:
./TestVAWT.in ../../../cactus
From this I get the error in the title returned. Am I correct in assuming that it has tried to run the TestVAWT.in file on the command line without referring to the Cactus application which I presume would be able to read the '&' prefix of the code along with the rest of the input file. Or is it something else I am missing here.
I would appreciate any help as I have been banging my head against a wall for some time now.
Note: I am using Ubuntu 14.04 LTS.
Best Regards
Richard

Don't know the application, but looks kind of strange to me.
Please try adding the Input-File as a parameter:
cactus TestVAWT.in

Related

can someone help me get python to run my scripts in CMD in windows 10 without having to cd to exact path each time.?

I'm trying to get python to run my scripts via CMD line.
note: idr if the book said where (a specific place to store my files for) python to access them but scanning back over the beginning I didn't find any relation to it.
According to this book https://automatetheboringstuff.com/2e/appendixb/ I am supposed to be able to type python (script.py) in command line just like this and it should run the script:
Here's the error I am getting upon execution, compared to the example from the book below it to show that this is supposed to work.
CMD LINE OUTPUT :
Microsoft Windows [Version 10.0.18362.1016]
(c) 2019 Microsoft Corporation. All rights reserved.
C:\Users\Armagon>python conway.py
python: can't open file 'conway.py': [Errno 2] No such file or directory
C:\Users\Armagon>
As you can see I get a python Error and researching this has given me nothing I found useful.
Here is the exact sample quoted from the book:
Microsoft Windows [Version 10.0.17134.648]
(c) 2018 Microsoft Corporation. All rights reserved.
C:\Users\Al>python hello.py
Hello, world!
C:\Users\Al>
First off, doing some research I have found a way to make it work, by cd(change directory) to the direct path of the folder containing the scripts C:\Users\Armagon\Desktop\mystuff. This helps to verify that the script I am trying to run is in fact located there and I've spelled it correctly.
But, according to everything I've followed up to this point I shouldn't have to do it this way.
The scripts are on my desktop all in the same folder called mystuff.
Following this link as well as a video Add a directory to Python sys.path so that it's included each time I use Python
I added the mystuff folder to PYTHONPATH in environment variables exactly as suggested. Here is a partial output of the sys.path (ran from IDLE) that shows mystuff filepath is added, so I'm pretty sure I did that part right.
['', 'C:\\Program Files\\Python38\\Lib\\idlelib', 'C:\\Users\\Armagon\\Desktop\\mystuff']
Maybe I've confused what is supposed to be happening here
I am operating under the assumption (based off what I've learned so far) that when CMD executes the line: python (script).py
It's supposed to run python.
Which in turn python is supposed to find my scripts on desktop (by the PYTHONPATH environment variable I created) and execute the script typed in CMD.
I've tried a lot of things in the process of getting just this far. I'd really appreciate if someone could point out what it is I'm overlooking to run python scripts from my desktop just like the book. I'm not very skilled at present and will gladly add any information as needed if I have excluded pertinent info I apologize in advance.
You should be able to do this as long as the script is in the module search path, for example, the PYTHONPATH environment variable. You should then be able to run the script like this:
python -m script
Well, the cd way is the way to go to run a python file via the command prompt. There is no other way I can think of.
Follow these steps or this link -> https://www.wikihow.com/Use-Windows-Command-Prompt-to-Run-a-Python-File to do it:
1)Open command prompt. type cmd or command prompt in search bar or run and press enter key.
2)In command prompt, given that the folder you are trying to access is in desktop, type-> cd desktop\myStuff.. Press enter.
3)Just write- python filename.py and enter.
4)It should run automatically.

Cannot find script files with OpenOCD

I'm trying to use OpenOCD together with my ST discovery board, following this tutorial: https://japaric.github.io/discovery/README.html. When verifying the OpenOCD installation I get the following error:
I've tried providing absolute paths to all files, it does not work. I also tried using the script files found in the scripts/board folder. They showed similar issues, the files cannot be found. Any pointers on solving this would be great.
My host computer is running Windows 10.
cd to /cygdrive/c/OpenOCD/share/openocd/scripts and then execute openocd -f file1 -f file2.
Alternatively, command shown in the picture of the question seems to work in the normal windows command prompt no matter the current working directory.

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.

julia: system image file "sys.ji" not found

I am using the IDE Netbeans to code a project c++ under Linux(red hat 7). As I need to use some math functions, I try to embed the julia language into my c++ project.
Here is what I have done:
Download the Julia from here (I choose this: Generic Linux binaries)
Set project properties: build-->C++ Complier-->Include Directories, add the include of Julia, something like this: ../myjulia/include/julia
Add the libraries: open a terminal and type the command line: sudo ln -s ../myjulia/lib/julia/libjulia.so /usr/lib/libjulia.so
Now if I run my project, I will get this error: System image file "../myproject/dist/Debug/GNU-Linux-x86/../lib/julia/sys.ji" not found
I hve checked this file: ../myjulia/lib/julia, in this file, there are all of the lib files (libjulia.so etc) and a file named "sys.ji".
I ran into this issue after installing Julia v0.3.10 on a Windows machine and thought I'd post it in case it can help someone else.
When I ran julia.exe it gave me the error message listed above.
Problem:
I had created a system environment variable called JULIA_HOME and pointed it to the directory where Julia was installed. Then, I added %JULIA_HOME%\bin to my PATH.
Solution:
I pointed JULIA_HOME to the \bin directory under the Julia install directory. Then, I added %JULIA_HOME% to my PATH
A "hello world" example from here
Now we know that we need to setup the julia context with this code:
jl_init(NULL);
In fact this code may not setup a good context because the project can't find the system image file "sys.ji". So what we need to do is using another function instead of jl_init: jl_init_with_image. This function accept two parameters: the first is the path of the image file, the second is the name of the image file. So we should use it like this: jl_init_with_image("/thePathOfSys.ji", "sys.ji"); One more thing: the path of sys.ji must be the absolute path.

Cygwin - Error Running Program on Windows 8.1

Operating System: Windows 8.1
Cygwin Version: Latest version, as of Sept. 9, 2014.
Guile Version: 1.8
Background:
My overall goal is to install a program called "MIT Photonics Band (MPB)" on Windows 8.1 using Cygwin. I am a new user, as I started using Cygwin a few days ago. I was able to install all required packages successfully after some troubleshooting. Eventually, I installed the MPB program using the generic ./configure, make, make install commands with slight modifications. All of this appeared to be successful.
The Problem:
When I try to run the executable program, I get the following error:
ERROR: In procedure primitive-load-path:
ERROR: Unable to find file "ice-9/boot-9.scm" in load path
Attempt At Solution:
The following is a page of the MPB installation manual:
MPB Installation Manual - Shared Libraries.
It appears to address my issue. Note that it mentions LIBDIR and foobar. For my operating system, foobar is PATH. The LIBDIR, however, I do not know explicitly because my "make install" output did not indicate it, as the manual suggests it should have. Anyhow, I found the location of ice-9/boot-9.scm through a computer search and its directory happens to be here:
C:\cygwin64\usr\share\guile\1.8\ice-9
Hence, I ran the following command (again, for a Windows 8.1 operating system) in bash:
$ export PATH="/usr/share/guile/1.8/ice-9:$PATH"
However, note that when I run $PATH, I get this message:
-bash: /usr/share/guile/1.8/ice-9:/usr/local/bin:/usr/bin:/cygdrive/c/Program: No such file or directory
I also tried:
$ export GUILE_LOAD_PATH="/usr/share/guile/1.8/ice-9:$GUILE_LOAD_PATH"
That yielded:
-bash: /usr/share/guile/1.8/ice-9:: No such file or directory
Furthermore, I tried to copy and paste the "ice-9" folder in various locations for a quick and sloppy solution, but it was to no avail. I searched online for answers as some users have had an issue with the program not finding the ice-9/boot-9.scm file in the past. I could not get my problem solved.
Please let me know if I need to provide more information. I appreciate the help!
EDIT: In response to the first user's post, I used the command echo $PATH and the following was the output:
/usr/share/guile/1.8:/usr/local/bin:/usr/bin:/cygdrive/c/Program Files (x86)/NVIDIA Corporation/PhysX/Common:/cygdrive/c/Program Files (x86)/AMD APP/bin/x86_64:/cygdrive/c/Program Files (x86)/AMD APP/bin/x86:/cygdrive/c/Windows/system32:/cygdrive/c/Windows:/cygdrive/c/Windows/System32/Wbem:/cygdrive/c/Windows/System32/WindowsPowerShell/v1.0:/cygdrive/c/Program Files (x86)/Windows Live/Shared:/cygdrive/c/Program Files (x86)/ATI Technologies/ATI.ACE/Core-Static:/cygdrive/c/Program Files/MATLAB/R2013a/runtime/win64:/cygdrive/c/Program Files/MATLAB/R2013a/bin:/cygdrive/c/Program Files (x86)/Windows Kits/8.1/Windows Performance Toolkit:/cygdrive/c/Program Files/Microsoft SQL Server/110/Tools/Binn:/cygdrive/c/WINDOWS/system32:/cygdrive/c/WINDOWS:/cygdrive/c/WINDOWS/System32/Wbem:/cygdrive/c/WINDOWS/System32/WindowsPowerShell/v1.0:/cygdrive/c/Program Files/MATLAB/MATLAB Compiler Runtime/v81/runtime/win64:/usr/lib/lapack
Note that the problem still persists.
EDIT 2:
So I opened the "load.scm" file for GUILE and I found this line:
(define load-path '("/usr/share/emacs/20.7/lisp/"
"/usr/share/emacs/20.7/lisp/emacs-lisp/"))
I tried to add /usr/share/guile/1.8/ to these directories, but that didn't do anything either. Can't tell what's wrong.

Resources