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.
Related
I am looking for a way to upgrade my dumb reverse-shell to an interactive shell. I want to upgrade it with Method 3, which can be found here:
https://blog.ropnop.com/upgrading-simple-shells-to-fully-interactive-ttys/
The commands work properly until I try to foreground my shell. 'fg' is working like it is described in the guide but after my shell is foregrounded I am not anymore able to type in commands. It seems like my Shell is frozen. 'reset' would follow now which is necessary to proceed but since I can't type in anything, I cant proceed
Any Suggestions are very welcome
Thanks in advance
Okay, I found it out myself:
First of all I upgraded my dumb shell into a python shell which provides more feature than the original shell but is not completely interactive. Afterwards I used the method above to upgrade the python shell to a TTY shell.
I used:
which Python, Python2, Python3
to check my Python Version.
The command 'which' shows the complete Path and says not found if python is not installed.
Afterwards I have been running the following command (in my case was python3 installed):
python3 -c 'import pty; pty.spawn("/bin/bash")'
If you have another version installed than I had, you need to change python3 to python or python2.
I guess the problem was a bug with the dumb shell but this should fix it.
With the python shell you can follow the instructions I posted above :)
I think the problem occurs when you try to foreground the shell in a different line. If you are having a zsh shell you have to make sure to run the command as stty raw -echo;fg. For other shells you can run it in separate line.enter image description here
[enter image description here][2]
I've been writing a Tkinter program and I don't want the console to show, so I used a .pyw file. However the program ran with an error that said the program could run usr/bin/python3, so I removed the shebang line, and it worked, but do I need a shebang line? Or should I keep it as is.
If it works without the shebang line:
Your computer found a version of Python to run it (likely in your "PATH" environment variables).
If it didn't work with the shebang line, either:
You made a typo, or
You gave it an incorrect path to your version of Python
Make sure you know exactly where Python is installed on your device:
Mac/Linux
Windows
(To anyone simply copy-pasting what you see in tutorials - without a good grasp of what it's doing: Try googling terms like "shebang line" and figure out what they might be doing behind the scenes)
In advance, sorry if this is question ought be on SuperUser or another site
The python3 shebang doesn't seem to work on win10. (I cant check right now, but I believe the analogous approach worked on MacOS for me last night). Consider the following
#!/usr/bin/env python3
print("hello world")
Leads to the error 'python' is not recognized as an internal or external command,
operable program or batch file. This makes sense because I only have a python3 distro on my machine (which can only be called like python3). However, Atom seems to be ignoring the shebang altogether. FYI, I'm running the script with the popular "script" atom package.
I've tried the permutation, #!/usr/bin python3, but this doesn't work either.
I've tried permutations
I'm still interested in how shebangs work within the Atom environment, but as far as getting python3 up and running, you dont need a shebang. You can simply change a config file (python.coffee) from within Atom, then relaunch. See Daniel Chamorro's excellent answer here: How to setup Atom's script to run Python 3.x scripts? May the combination with Windows 7 Pro x64 be the issue?
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?
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.