# Julia as a bridge between windows and raspberry pi

**URL:** <https://discourse.julialang.org/t/julia-as-a-bridge-between-windows-and-raspberry-pi/99748>\
**Category:** General Usage\
**Created:** [June 1, 2023, 11:40pm UTC](https://discourse.julialang.org/t/julia-as-a-bridge-between-windows-and-raspberry-pi/99748 "2023-06-01T23:40:51Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![RDuarte](https://avatars.discourse-cdn.com/v4/letter/r/a183cd/32.png) [@RDuarte](https://discourse.julialang.org/u/RDuarte)\
**Post date:** [June 1, 2023, 11:40pm UTC](https://discourse.julialang.org/t/julia-as-a-bridge-between-windows-and-raspberry-pi/99748/1 "2023-06-01T23:40:51Z")

</div>

Hello everyone,

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.

---

<div class="post-metadata">

**Author:** ![mkitti](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkitti/32/12459_2.png) [@mkitti](https://discourse.julialang.org/u/mkitti)\
**Post date:** [June 2, 2023, 12:02am UTC](https://discourse.julialang.org/t/julia-as-a-bridge-between-windows-and-raspberry-pi/99748/2 "2023-06-02T00:02:50Z")

</div>

# OpenSSH for Windows

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:

> **[Get started with OpenSSH Server for Windows](https://learn.microsoft.com/en-us/windows-server/administration/openssh/openssh_install_firstuse?tabs=gui)**
>
> Learn how to install and connect to remote machines using the OpenSSH Client and Server for Windows.

Once you have that you can run `scp` from `julia` as follows.

```julia-auto
julia> run(`scp`)
usage: scp [-346BCpqrTv] [-c cipher] [-F ssh_config] [-i identity_file]
            [-J destination] [-l limit] [-o ssh_option] [-P port]
            [-S program] source ... target
ERROR: failed process: Process(`scp`, ProcessExited(1)) [1]

```

Above you can see `scp` printed some help messages. What you want to do is something like

```julia-auto
run(`scp username@raspberry_pi.host.name:/path/on/rpi C:\\path\\to\\local\\windows\\folder`)

```

# LibSSH2\_jll

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`:

> **[libssh2\_version()](https://libssh2.org/libssh2_version.html)**

```julia-auto
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.

> **[Calling C and Fortran Code · The Julia Language](https://docs.julialang.org/en/v1/manual/calling-c-and-fortran-code/)**
>
> Documentation for The Julia Language.

---

<div class="post-metadata">

**Author:** ![RDuarte](https://avatars.discourse-cdn.com/v4/letter/r/a183cd/32.png) [@RDuarte](https://discourse.julialang.org/u/RDuarte)\
**Post date:** [June 2, 2023, 1:36pm UTC](https://discourse.julialang.org/t/julia-as-a-bridge-between-windows-and-raspberry-pi/99748/3 "2023-06-02T13:36:20Z")

</div>

Hello @mkitti ,  
I tryied the first option but Im getting the following error:

 ![error](https://global.discourse-cdn.com/julialang/original/3X/8/a/8a5da0e46c1b85710e3bb79f53d74e834f2e7a78.jpeg)  
What am I doing wrong?  
Thank you in advance.

---

<div class="post-metadata">

**Author:** ![mkitti](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkitti/32/12459_2.png) [@mkitti](https://discourse.julialang.org/u/mkitti)\
**Post date:** [June 2, 2023, 4:33pm UTC](https://discourse.julialang.org/t/julia-as-a-bridge-between-windows-and-raspberry-pi/99748/4 "2023-06-02T16:33:15Z")

</div>

Note how I have `\\` instead of `\`. This is because Julia regards the `\` as an escape character.

Alternatively, you might consider using raw strings.

```julia
raw_str_path = raw"C:\Users\Username\Documents"
run(`scp rduarte@raspberrypi:/media $raw_str_path`)

```

---

<div class="post-metadata">

**Author:** ![RDuarte](https://avatars.discourse-cdn.com/v4/letter/r/a183cd/32.png) [@RDuarte](https://discourse.julialang.org/u/RDuarte)\
**Post date:** [June 2, 2023, 10:24pm UTC](https://discourse.julialang.org/t/julia-as-a-bridge-between-windows-and-raspberry-pi/99748/5 "2023-06-02T22:24:44Z")

</div>

Hi @mkitti  
I just tried but the result remains

 ![erro2](https://global.discourse-cdn.com/julialang/original/3X/1/a/1a436f8db7b0198da5a70c6c35eaa7c6ea7b041a.jpeg)  
Do you have any idea why?  
Thanks

---

<div class="post-metadata">

**Author:** ![mkitti](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkitti/32/12459_2.png) [@mkitti](https://discourse.julialang.org/u/mkitti)\
**Post date:** [June 2, 2023, 11:11pm UTC](https://discourse.julialang.org/t/julia-as-a-bridge-between-windows-and-raspberry-pi/99748/6 "2023-06-02T23:11:59Z")

</div>

It looks like you have a space in your folder name. This is a common cause for headaches and why I usually avoid spaces in file or directory names.

Try putting quotes around the paths.

Scp seems to think C is a host. I’m not sure why.

Can you confirm where you got ssh and scp from?

---

<div class="post-metadata">

**Author:** ![RDuarte](https://avatars.discourse-cdn.com/v4/letter/r/a183cd/32.png) [@RDuarte](https://discourse.julialang.org/u/RDuarte)\
**Post date:** [June 3, 2023, 12:10am UTC](https://discourse.julialang.org/t/julia-as-a-bridge-between-windows-and-raspberry-pi/99748/7 "2023-06-03T00:10:43Z")

</div>

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:

> **[Get started with OpenSSH for Windows](https://learn.microsoft.com/en-us/windows-server/administration/openssh/openssh_install_firstuse?tabs=gui#prerequisites)**
>
> Learn how to install and connect to remote machines using the OpenSSH Client and Server for Windows.

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

---

<div class="post-metadata">

**Author:** ![mkitti](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkitti/32/12459_2.png) [@mkitti](https://discourse.julialang.org/u/mkitti)\
**Post date:** [June 4, 2023, 4:12am UTC](https://discourse.julialang.org/t/julia-as-a-bridge-between-windows-and-raspberry-pi/99748/8 "2023-06-04T04:12:55Z")

</div>

The problem is that `scp` is confused by `C:\...`. It thinks anything before the colon should be a hostname and it cannot find a host called `C`.

You might need to use quotes or d  
or some alternative way to provide the path.

Try some variants of the following:

- `scp rduarte@rapsberrypi:/some/path "C:\\User\\Duarte\\Desktop"`
- `scp rduarte@rapsberrypi:/some/path "C:/User/Duarte/Desktop"`
- `scp rduarte@rapsberrypi:/some/path "C/User/Duarte/Desktop"`

Maybe `cd` first and then try the following. The `.` means to copy it to the current directory.

```julia
cd(raw"C:\User\Duarte\Desktop")
run(`scp rduarte@rapsberrypi:/some/path .`)

```

---

<div class="post-metadata">

**Author:** ![johnh](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/johnh/32/3615_2.png) [@johnh](https://discourse.julialang.org/u/johnh)\
**Post date:** [June 4, 2023, 7:12am UTC](https://discourse.julialang.org/t/julia-as-a-bridge-between-windows-and-raspberry-pi/99748/9 "2023-06-04T07:12:25Z")

</div>

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

> **[MobaXterm free Xserver and tabbed SSH client for Windows](https://mobaxterm.mobatek.net/features.html)**
>
> The ultimate toolbox for remote computing - includes X server, enhanced SSH client and much more!

---

<div class="post-metadata">

**Author:** ![johnh](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/johnh/32/3615_2.png) [@johnh](https://discourse.julialang.org/u/johnh)\
**Post date:** [June 4, 2023, 7:17am UTC](https://discourse.julialang.org/t/julia-as-a-bridge-between-windows-and-raspberry-pi/99748/10 "2023-06-04T07:17:18Z")

</div>

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

You say you have an ssh connection availalbe. There are ssh based filesystems  
[SSHFS: How to Mount Remote File Systems Over SSH | phoenixNAP KB](https://phoenixnap.com/kb/sshfs#:~:text=To%20use%20SSHFS%20on%20Windows,interface%20is%20available%20as%20well).

Please contact me if you want some help setting this up.

---

<div class="post-metadata">

**Author:** ![RDuarte](https://avatars.discourse-cdn.com/v4/letter/r/a183cd/32.png) [@RDuarte](https://discourse.julialang.org/u/RDuarte)\
**Post date:** [June 4, 2023, 10:03pm UTC](https://discourse.julialang.org/t/julia-as-a-bridge-between-windows-and-raspberry-pi/99748/11 "2023-06-04T22:03:40Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![RDuarte](https://avatars.discourse-cdn.com/v4/letter/r/a183cd/32.png) [@RDuarte](https://discourse.julialang.org/u/RDuarte)\
**Post date:** [June 4, 2023, 10:05pm UTC](https://discourse.julialang.org/t/julia-as-a-bridge-between-windows-and-raspberry-pi/99748/12 "2023-06-04T22:05:03Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![johnh](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/johnh/32/3615_2.png) [@johnh](https://discourse.julialang.org/u/johnh)\
**Post date:** [June 5, 2023, 1:55am UTC](https://discourse.julialang.org/t/julia-as-a-bridge-between-windows-and-raspberry-pi/99748/13 "2023-06-05T01:55:33Z")

</div>

@rduarte That is exactly how the SFTP browser works in MobaXterm.  
Please install MobaXterm on your Windows laptop and try it.

---

<div class="post-metadata">

**Author:** ![mkitti](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkitti/32/12459_2.png) [@mkitti](https://discourse.julialang.org/u/mkitti)\
**Post date:** [June 5, 2023, 4:59am UTC](https://discourse.julialang.org/t/julia-as-a-bridge-between-windows-and-raspberry-pi/99748/14 "2023-06-05T04:59:37Z")

</div>

What’s the current error? Is it changing at all?

I would expect this to create a different error than the ones you have been encountering.

```julia
cd(raw"C:\User\Duarte\Desktop")
run(`scp rduarte@rapsberrypi:/some/path .`)

```

Have you tried opening up Cmd.exe or Powershell.exe and executing the commands directly there?

---

<div class="post-metadata">

**Author:** ![RDuarte](https://avatars.discourse-cdn.com/v4/letter/r/a183cd/32.png) [@RDuarte](https://discourse.julialang.org/u/RDuarte)\
**Post date:** [June 5, 2023, 10:04am UTC](https://discourse.julialang.org/t/julia-as-a-bridge-between-windows-and-raspberry-pi/99748/15 "2023-06-05T10:04:52Z")

</div>

Hello @mkitti  
The error I getting now is:  
 ![erro3](https://global.discourse-cdn.com/julialang/original/3X/0/7/07275f15bb145c9284f7fe3db1f8cc5a036fbb64.jpeg)

---

<div class="post-metadata">

**Author:** ![TheLateKronos](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/thelatekronos/32/12824_2.png) [@TheLateKronos](https://discourse.julialang.org/u/TheLateKronos)\
**Post date:** [June 5, 2023, 10:28am UTC](https://discourse.julialang.org/t/julia-as-a-bridge-between-windows-and-raspberry-pi/99748/16 "2023-06-05T10:28:39Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![RDuarte](https://avatars.discourse-cdn.com/v4/letter/r/a183cd/32.png) [@RDuarte](https://discourse.julialang.org/u/RDuarte)\
**Post date:** [June 5, 2023, 11:10am UTC](https://discourse.julialang.org/t/julia-as-a-bridge-between-windows-and-raspberry-pi/99748/17 "2023-06-05T11:10:15Z")

</div>

Hello @TheLateKronos  
Yes, I need that happens from inside Julia.  
Thanks

---

<div class="post-metadata">

**Author:** ![djvanderlaan](https://avatars.discourse-cdn.com/v4/letter/d/838e76/32.png) [@djvanderlaan](https://discourse.julialang.org/u/djvanderlaan)\
**Post date:** [June 5, 2023, 11:10am UTC](https://discourse.julialang.org/t/julia-as-a-bridge-between-windows-and-raspberry-pi/99748/18 "2023-06-05T11:10:32Z")

</div>

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:

```julia
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:

```julia
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](https://www.digitalocean.com/community/tutorials/how-to-configure-ssh-key-based-authentication-on-a-linux-server). If that works, then running the same commands from julia should also work.

---

<div class="post-metadata">

**Author:** ![mkitti](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkitti/32/12459_2.png) [@mkitti](https://discourse.julialang.org/u/mkitti)\
**Post date:** [June 5, 2023, 5:25pm UTC](https://discourse.julialang.org/t/julia-as-a-bridge-between-windows-and-raspberry-pi/99748/19 "2023-06-05T17:25:34Z")

</div>

It probably is that directory does not exist. Specifically, are you sure the path is “User” not “Users” with an “s”?

---

<div class="post-metadata">

**Author:** ![RDuarte](https://avatars.discourse-cdn.com/v4/letter/r/a183cd/32.png) [@RDuarte](https://discourse.julialang.org/u/RDuarte)\
**Post date:** [June 5, 2023, 11:05pm UTC](https://discourse.julialang.org/t/julia-as-a-bridge-between-windows-and-raspberry-pi/99748/20 "2023-06-05T23:05:03Z")

</div>

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

[Next page](https://discourse.julialang.org/t/julia-as-a-bridge-between-windows-and-raspberry-pi/99748.md?page=2)
