I’m trying to create project that runs in raspberry pi and windows and I want that Julia works as a bridge between both platforms.
I will try to explain.
I run Julia in my raspberry pi in order to process some data and create some particular files. This part is ok.
Now, I want to from my windows machine get those files to be treated using for that julia.
I already created an ssh connection between raspberry and windows but what i need, and what i don’t know how to do, is a piece of code in julia that allows me to go to the location of my files in my raspberry pi and copy them to a specific location in my windows machine.
Do you have any idea how this can be done?
Thanks in advance.
It sounds like you have an ssh connection setup, so I think you continue to use that. The key command line tool to use is either sftp or scp. I recommend scp.
Installing OpenSSH for Windows is pretty easy. Microsoft has OpenSSH as an Optional Feature of Windows now:
Once you have that you can run scp from julia as follows.
If you wanted to do this on hard mode, you could use LibSSH2_jll and call the libssh2 API. Here’s an example for the C function libssh2_version: https://www.libssh2.org/libssh2_version.html
julia> using Pkg
julia> pkg"activate --temp"
Activating new project at `C:\Users\username\AppData\Local\Temp\jl_0N2fUl`
julia> pkg"add LibSSH2_jll"
Updating registry at `C:\Users\kittisopikulm\.julia\registries\General.toml`
Resolving package versions...
Updating `C:\Users\username\AppData\Local\Temp\jl_0N2fUl\Project.toml`
[29816b5a] + LibSSH2_jll v1.10.2+0
Updating `C:\Users\username\AppData\Local\Temp\jl_0N2fUl\Manifest.toml`
[56f22d72] + Artifacts
[8f399da3] + Libdl
[29816b5a] + LibSSH2_jll v1.10.2+0
[c8ffd9c3] + MbedTLS_jll v2.28.2+0
julia> using LibSSH2_jll
julia> version = ccall((:libssh2_version,LibSSH2_jll.libssh2_path), Cstring, (Cint,), 0)
Cstring(0x000000006eabc3a0)
julia> unsafe_string(version)
"1.10.0"
See the following documentation about how to call C from Julia.
Hello @mkitti
I tried already without space and I get the same error.
To do: ssh my.raspberypi.ip.adress -l rduarte
I installed windows server through the following link:
For the scp I just typed the lines you wrote in the first post.
I’m really new on this, sorry if I miss some point.
Thanks
If you want to have a shared filesystem between a R PI (Linux) and Windows you have many choices.
A very easy one is to use MobaXterm which has a built in graphical SFTP browser/transport utility
Other choices are creating an NFS share on the RPI and mounting that on Windows
Or you could use a CIFS share on either Windows or RPI and use Samba on RPI
Thank you @johnh but this is not the kind of solution i’m looking for.
I what to pass files between raspberry and windows. Let’s say, when using windows, through an ssh connection I want to open julia in raspberrypi and then copy some files to my windows.
Thanks anyway.
Hello @mkitti,
Still not working.
Can you describe me what should I do to have a succefull scp connection between both os?
Maybe is there the error.
Thank you
Is it important that this should happen from inside Julia, and from running a single command, perhaps inside a larger workflow? Or is it okay if the file transfer happens in the end, possibly requiring user input, more like a seperate step?
I would first try do debug this outside of julia. You say that you have ssh working. I assume that is from powershell or something like that. So go to powershell:
ssh <username>@<raspberrypi>
should get you into the raspberry pi (with <username> and <raspberrypi> of course replaced by the appropriate values). There running touch somefile will create a file on your pi. Exiting the raspberry pi, you should then be able to do:
scp <username>@<raspberrypi>:somefile ./
If not then there is something wrong. If it works, but asks for a password, you will probably first have to set up loging in using keys; as typing in passwords from julia will be impractical. For that see, for example, How To Configure SSH Key-Based Authentication on a Linux Server | DigitalOcean. If that works, then running the same commands from julia should also work.
Hello @djvanderlaan
I was able to connect to raspberry and create the “somefile” on it. However, when I try to do the scp (outside julia) i get the following message:
scp: .:not a regular file
Thanks