Simple Erlang example won't run (error) - linux

Good Afternoon Guys,
I've recently took an interest in Erlang and functional programming. I'm trying to run this simple hello world example without opening the Erlang shell. I'm able to run it successfully in MACOSX (Yosemite) but, I'd like to use my Fedora 20 VM instead. So in Fedora (Linux) (and even Windows 7) I get the following error when trying to run the compiled beam:
{"init terminating in do_boot",{undef,[{heythere,start,[],[]},{init,start_it,1,[]},{init,start_em,1,[]}]}}
Crash dump was written to: erl_crash.dump
init terminating in do_boot ()
These are the switches I use to run the file:
erl -noshell -start -s heythere -init -stop
I even substituted the "-s" switch and used "-run" to no avail. I'm able to run the modules within the shell but NOT outside of it. Is there something I'm doing wrong?
Code:
-module(heythere).
-export([hello_world/0, this_function/0, both/0]).
hello_world() ->
io:fwrite("hello, world\n").
this_function() ->
io:fwrite("This is another function...ok~n").
both() ->
hello_world(),
this_function().
I tried looking in the erl_crash.dump but it's over 1000+ lines long and I can't make heads or tails of it. :-(
Thank you guys so much in advance.

In the -s flag, you specified a module heythere, but no function to use. erl defaults to using start as the function, but you do not specify a start function in your module, so erl doesn't know how to run your program.

Related

Make chosen version of Elasticsearch run as a service in Linux

I have an issue with later versions of ES, so have to use 7.10.2 currently.
This means that the previous method I used to install ES as a service, i.e. apt-get, doesn't work You can't choose an older version this way: it currently installs 7.16.3.
So I followed the procedure on this page for 7.10: everything worked: I was able to run ES as an app and also as a "daemon". Clearly I could simply put the "daemon" startup line in a script which runs on boot.
But what's the optimum way of turning this "daemon arrangement" into a service which you can control with systemctl, and which starts automatically when the machine boots?
PS I don't want to get involved with Docker. I'm sure that's a useful thing but I'm convinced there is a simpler way of doing it, using available Linux sys tools.
I found a workaround... this doesn't in fact create a service of the "systemd" type which can be controlled by systemctl. There seem to be one or two problems which make this non-trivial.
1) You can't start ES as root! I assume (not sure) that most services are being run by root. Anyway this was something I couldn't find a solution to.
2) I am not sure whether a shell script file called by a service is allowed to end... or should continue endlessly: initially I thought this would be sufficient. This is a shell script (run_es_daemon.sh) which does indeed start up ES (as a daemon process) when run by manually in a terminal. There is no issue to do with the fact that the script ends and you then close the terminal: the daemon process continues to run:
#!/bin/bash
# start ES as a daemon...
cd /home/mike/Elasticsearch/elasticsearch-7.10.2
./bin/elasticsearch -d -p pid
... but it never worked using a xxx.service file in /etc/systemd/system/ (maybe because of 1) above). So I also tried adding these lines under the above ones:
while true
do
echo "bubbles"
sleep 60
done
... didn't work either.
In the end I found a simple workaround solution was to start up the daemon process by using crontab:
#reboot /home/mike/sysadmin/run_es_daemon.sh
... but I'd still like to know how to set it up as a true service, which starts at boot...

Is there a way to isolate an application installation from the system?

I'm working on the sources of an application an have the release version of the application installed on the system.
How can i test the modified (and possibly buggy) application without conflicting with the version installed ?
What I want is basically virtual env but for generic applications.
I tried Docker but this has several issues :
I can't get the X11 redirection working. I tried commands like docker run -ti --net=host -e DISPLAY=:0.0 test-docker-geany or docker run -ti -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix test-docker-geany according to some forum threads.
The docker build involves copying the whole codebase to the image as well as installing all the tools and libraries needed to compile which some are not stored in cache and installed each time. So the script takes several minutes each time you want to compile and run.
So my questions are :
Is docker the best solution for such task ? I'm sure this is a problem a lot open source contributors faces but I couldn't find other cases on the net.
If it is not the best solution what are the alternatives ?
Detailed error :
I ran the commands xhost + and the first one I gave in my first issue and I got :
The program 'geany' received an X Window System error.
This probably reflects a bug in the program.
The error was 'BadValue (integer parameter out of range for operation)'.
(Details: serial 173 error_code 2 request_code 130 minor_code 3)
(Note to programmers: normally, X errors are reported asynchronously;
that is, you will receive the error a while after causing it.
To debug your program, run it with the --sync command line
option to change this behavior. You can then get a meaningful
backtrace from your debugger if you break on the gdk_x_error() function.)
The Dockerfile : https://pastebin.com/p03vaWbU
The warning was finally the cause : i just had to install gtk2-engines-pixbuf according to this thread
EDIT : I misunderstood the success. I get it to work that time because I ran an other GUI program in the docker before. In fact, I finally discovered that trying geany a second time just works although the first try give the error.

Cannot run julia file - syntax error close to the unexpected token

Well, i wrote a simple "hello world" in julia, but i cannot figure out on how to run the code. I've tried to run by ./nameOfMyFile.jl and the terminal returned to me that I have syntax errors.
My code is just:
println("hello world")
Wich works perfectly if i run julia on the terminal and write the code after that...
The error is something like( I am translating it from portuguese):
./hello_world.jl: line 1:syntax error close to the unexpected token `"hello world"
./hello_world.jl: line 1: `println("hello world")'
I'm using vim, debian 8 and julia 0.3.2
If you want to execute it directly from the terminal you can add a shebang to the beggining of your script i.e.
#!/usr/bin/env julia
println("hello world")
and then make it executable using chmod
[user#computer]$ chmod +x hello
then it should run as expected :)
./hello
will print "hello world" to your terminal :)
Two ways I can think of to achieve what you want
Open a terminal and do either one of the following
Inside the julia relp, that is, if you run julia in the terminal by running
julia
and when you're in, do
include("nameoffile.jl")
if you simple want to run the file, in the terminal do
julia nameoffile.jl
Based on discussions on GitHub like this one it sounds like this issue is more due to the shell than to Julia. Nevertheless, I would strongly recommend upgrading to the latest version of Julia, 0.4.6. The version that you are using is quite old and lacks a lot of improvements, including ones addressing issues at least similar to what you are experiencing.

Program not running in Cygwin64

I'm trying to run a program (Exonerate : http://www.ebi.ac.uk/~guy/exonerate/) using Cygwin64.
But for some reason the program doesn't run when I try to execute it using the Cygwin shell and produces no error message either. I've added the C:\Cygwin64\bin to the DOS PATH
The program runs fine in some other comp. which runs Cygwin32.
Can anybody please help to sort it out.
Thanks in advance
I met the same situation in Cygwin64 on Windows 10. The solution is add ./ before the file name.
So that is when I want to run test.exe after I made it by running gcc test.c -o test, I need to run ./test.exe instead of text.exe.

Using script to automatically start program when the system boot up (linux, shell)

Here is the situation, I'm planning to use a simple script to start a program call "STAF", when the Suse system is fully booted. I have achieved this by putting it in the "/etc/init.d/", but this script is basically executed at the background, which means that I cannot see its progress.
When the "STAF" is started this way it works but it doesn't show any working progress when its running service (for example ping, or system backup), instead if I start the "STAF" manually by running the same script whit a terminal, the working progress of "STAF" can be seen on the terminal. Its sort of like the program needs to be started with a interactive terminal, but how can I make this starting process automatic and it should imitate human opening a terminal and run the script?
Sorry if I explained it poorly because its a confusing situation. Thanks.
First, go to the KDE Startup and Shutdown options under System Settings. Then add this command as a new startup script:
konsole -e bash nameofyourscript.sh
I believe the screen utility can do what you describe. Instead of running STAF on startup, you would run screen STAF. To open that terminal, you would run screen -ls to get the screen ID, and screen -r ... to open it.
(Disclaimer: I have not tried this.)

Resources