How to run shell commands from the Julia REPL? - julia

In the Julia REPL, I would like to run some terminal commands but don't necessarily want to do those commands via a pipe or other syntax which wraps around a system call. Is there a more native way of running terminal commands from the REPL?

Julia's REPL has what is referred to as a Shell mode. You can access the Shell mode via typing in a ; into the terminal which will result in:
_
_ _ _(_)_ | Documentation: https://docs.julialang.org
(_) | (_) (_) |
_ _ _| |_ __ _ | Type "?" for help, "]?" for Pkg help.
| | | | | | |/ _` | |
| | |_| | | | (_| | | Version 1.6.0 (2021-03-24)
_/ |\__'_|_|_|\__'_| | Official https://julialang.org/ release
|__/ |
shell>
you can then run commands like:
shell> pwd
/Users/my_username
shell>
Read more about the Shell mode here: https://docs.julialang.org/en/v1/stdlib/REPL/#man-shell-mode

Related

How to update Julia from command line?

Is there a way to update Julia from the command line? I looked through the documentation, but I couldn't find anything.
I would suggest trying asdf if you are on MacOS, Linux, or Windows Subsystem for Linux (it does not have support for Windows proper, since it works in Linux-type shells). It's a generic tool for handling versions and has a Julia plugin. Once asdf is installed, just do
asdf plugin add julia
to add the julia plugin. Then it's very easy to add a new version of Julia. I don't have 1.4.0 installed on this computer (I do have 1.5.1 installed, which I will switch to later), so I will demonstrate by installing that:
$ asdf install julia 1.4.0
Downloading from:
https://julialang-s3.julialang.org/bin/linux/x64/1.4/julia-1.4.0-linux-x86_64.tar.gz
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 94.3M 100 94.3M 0 0 5241k 0 0:00:18 0:00:18 --:--:-- 5932k
Now that it's installed, I can set it to be the default version:
$ asdf global julia 1.4.0
Then I just run julia:
$ julia
_
_ _ _(_)_ | Documentation: https://docs.julialang.org
(_) | (_) (_) |
_ _ _| |_ __ _ | Type "?" for help, "]?" for Pkg help.
| | | | | | |/ _` | |
| | |_| | | | (_| | | Version 1.4.0 (2020-03-21)
_/ |\__'_|_|_|\__'_| | Official https://julialang.org/ release
Now, if I want to change the version back to 1.5.1, it's very easy:
$ asdf global julia 1.5.1
$ julia
_
_ _ _(_)_ | Documentation: https://docs.julialang.org
(_) | (_) (_) |
_ _ _| |_ __ _ | Type "?" for help, "]?" for Pkg help.
| | | | | | |/ _` | |
| | |_| | | | (_| | | Version 1.5.1 (2020-08-25)
_/ |\__'_|_|_|\__'_| | Official https://julialang.org/ release
|__/ |
If you want the latest version, just do asdf install julia latest. And to see all available versions, asdf list all julia. Note that you seem to need to type the patch version number, e.g. asdf install julia 1.5.1, not asdf install julia 1.5.

I'm unable to install IJulia

ijulia installation is stuck at 100%
I'm beginner need help.:
_
_ _ _(_)_ | Documentation: https://docs.julialang.org
(_) | (_) (_) |
_ _ _| |_ __ _ | Type "?" for help, "]?" for Pkg help.
| | | | | | |/ _` | |
| | |_| | | | (_| | | Version 1.4.1 (2020-04-14)
_/ |\__'_|_|_|\__'_| | Official https://julialang.org/ release
|__/ |
julia> using Pkg
julia> Pkg.add("IJulia")
Cloning default registries into `c:\Users\xxxx\.julia`
Cloning registry from "https://github.com/JuliaRegistries/General.git"
Fetching: [========================================>] 100.0 %
It takes some time to install packages for the first time (e.g. 4mins machine with good internet) - you need just wait.
Sometimes this also might happen when you loose internet connection during the install or it is unstable. In that case you can just press Ctrl+C and try again. After pressing Ctrl+C on rare occasions something might be partially installed - in that case you might end up removing the c:\Users\xxxx\.julia folder. Good luck!

What is the replacement for connect in Julia?

julia> conn = connect(1234)
ERROR: UndefVarError: connect not defined
Stacktrace:
[1] top-level scope at REPL[1]:1
It's not working after update so is there any new keyword by which it's been replaced?
help?> connect
search: continue countlines count_ones
Couldn't find connect
Perhaps you meant convert, collect, const, count or conj
No documentation found.
Binding connect does not exist.
Julia version 0.7 is a handy tool when trying to port pre-existing code to julia 1.x: for all functions that have been deprecated in Julia 1.0.0, a warning is shown in julia 0.7.
In the specific case of connect:
shell$ julia-0.7.0 _
_ _ _(_)_ | A fresh approach to technical computing
(_) | (_) (_) | Documentation: https://docs.julialang.org
_ _ _| |_ __ _ | Type "?" for help, "]?" for Pkg help.
| | | | | | |/ _ | |
| | |_| | | | (_| | | Version 0.7.0 (2018-08-08 06:46 UTC)
_/ |\__'_|_|_|\__'_| | Official http://julialang.org/ release
|__/ | x86_64-pc-linux-gnu
julia> connect
WARNING: Base.connect is deprecated: it has been moved to the standard library package `Sockets`.
Add `using Sockets` to your imports.
in module Main
connect (generic function with 8 methods)
Following the information given in this message, connect should now be used as:
using Sockets
socket = connect(1234)
This is working with Package Sockets
so just use following to install this package:-
import Pkg;
Pkg.add("Sockets")
Now use it as follows
julia> using Sockets
julia> Sockets.connect(1234)
TCPSocket(RawFD(0x00000014) open, 0 bytes waiting)
Whenever you encounter this kind of issues, I recommend using the docker images to quickly find the deprecation warnings (this is of course a general advise and not only applicable to Julia ;)
You can install Docker easily on any Linux distribution and for Mac and Windows there are even GUI versions called Docker Desktop
If you have Docker installed, you can use the docker command in the terminal to create containers from images, which are e.g. hosted on DockerHub.
Here is a small example, first launching a Julia 1.0 container to check for connect and then trying Julia 0.7:
░ tgal#staticbox:~
░ 08:58:01 > docker run -it julia:1.0
_
_ _ _(_)_ | Documentation: https://docs.julialang.org
(_) | (_) (_) |
_ _ _| |_ __ _ | Type "?" for help, "]?" for Pkg help.
| | | | | | |/ _` | |
| | |_| | | | (_| | | Version 1.0.5 (2019-09-09)
_/ |\__'_|_|_|\__'_| | Official https://julialang.org/ release
|__/ |
julia> connect
ERROR: UndefVarError: connect not defined
julia>
░ tgal#staticbox:~ took 10s
░ 08:58:18 > docker run -it julia:0.7
_
_ _ _(_)_ | A fresh approach to technical computing
(_) | (_) (_) | Documentation: https://docs.julialang.org
_ _ _| |_ __ _ | Type "?" for help, "]?" for Pkg help.
| | | | | | |/ _` | |
| | |_| | | | (_| | | Version 0.7.0 (2018-08-08 06:46 UTC)
_/ |\__'_|_|_|\__'_| | Official http://julialang.org/ release
|__/ | x86_64-pc-linux-gnu
julia> connect
WARNING: Base.connect is deprecated: it has been moved to the standard library package `Sockets`.
Add `using Sockets` to your imports.
in module Main
connect (generic function with 8 methods)

flywaydb baseline baselineVersion parameter is being ignored

I am trying to impelment flywaydb in our process. In our env each client has their own instance of the DB.
I have a bash that loops through the clients to run migrate. So the command looks like
flyway -url=jdbc:jtds:sqlserver://localhost:1434/main_client_$ID migrate
This all works when all the clients start from the baseline. But as we add new customers their DB will reflect the newest code. Now we have older clients started with V1(and all the migration scripts to V2) and new clients with the latest DB V2.
I thought i could do something like :::
flyway baseline -url=jdbc:jtds:sqlserver://localhost:1434/main_client_3
--baselineVersion=2 --baselineDescription="Base 2 version"
but when i do it this way then call info i see something like :
+---------+-----------------------+---------------------+---------+
| Version | Description | Installed on | State |
+---------+-----------------------+---------------------+---------+
| 1 | << Flyway Baseline >> | 2015-06-08 22:07:54 | Success |
| 1.1 | update | | Pending |
| 1.2.0 | update | | Pending |
| 1.2.1 | update | | Pending |
+---------+-----------------------+---------------------+---------+
if i look in the DB i see the version value of schema_version set to 1.
if via the DB i force schema_version column value to 1.2.0 i see
+---------+-----------------------+---------------------+---------+
| Version | Description | Installed on | State |
+---------+-----------------------+---------------------+---------+
| 1 | Base version initial | | <Baseln |
| 1.1 | update | | <Baseln |
| 1.2.0 | << Flyway Baseline >> | 2015-06-08 22:07:54 | Success |
| 1.2.1 | update | | Pending |
+---------+-----------------------+---------------------+---------+
This is what i want.
But i can not figure out how to set the value via the baseline command
Thanks for any help
All parameters should be passed in with - not --

How to change the startup screen of Servicemix

I want to change the startup screen of servicemix which is as below,
____ _ __ __ _
/ ___| ___ _ ____ _(_) ___ ___| \/ (_)_ __
\___ \ / _ \ '__\ \ / / |/ __/ _ \ |\/| | \ \/ /
___) | __/ | \ V /| | (_| __/ | | | |> <
|____/ \___|_| \_/ |_|\___\___|_| |_|_/_/\_\
Apache ServiceMix (4.4.1-fuse-01-13)
karaf#root>
to my custom name.
If its possible may I know the procedure
Regards,
Bharani
ServiceMix 4.4.1 uses Karaf 2.2.x. You can find a branding how-to for Karaf 2.2.x here http://karaf.apache.org/manual/latest-2.2.x/developers-guide/branding-console.html.
ServiceMix is a custom distribution of Karaf and the branding used in ServiceMix is a customized Karaf branding. You can find the branding module for ServiceMix 4.4.x here https://github.com/apache/servicemix4-features/tree/features-4.4.x/branding. This is what you exactly need. You can use this project as a template and implement your branding in the same way. The how-to mentioned above should help you to install the bundle in the correct location.

Resources