Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Linux Programming
  4. Reading Files on network box

Reading Files on network box

Scheduled Pinned Locked Moved Linux Programming
questioncsharpasp-netdotnetsysadmin
16 Posts 9 Posters 65 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • realJSOPR Offline
    realJSOPR Offline
    realJSOP
    wrote on last edited by
    #1

    Facts: 0) I'm writing a .Net Core 3.1 command line app (using C#) to read text files on some Raspberry Pi machines on the network. This app will be able to run on either Windows or Linux. 1) The files in question are in the /etc, /proc and /sys folders. 2) I don't want to create shares of these folders. 3) I'd prefer not to have to install/configure anything on the remote boxes (if at all possible). 4) I know the user ids and passwords for the remote boxes, and am aware that I have to somehow use these credentials in order to "connect" to the remote boxes). 5) I don't want to use another language. I mean, doNet Core is supposed to be cross-platform, right? Problem: How do I go about reading a file on a remote linux box? I've tried a number of ways to do this, but I keep getting the following exception: "The network name cannot be found. : '\\\\192.168.1.10\\sys\\class\\thermal\\thermal_zone0\\temp'" (BTW, when running in Windows, the exception is presented with backslashes. I'm actually using forward slashes.)

    ".45 ACP - because shooting twice is just silly" - JSOP, 2010
    -----
    You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
    -----
    When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013

    K L J U 4 Replies Last reply
    0
    • realJSOPR realJSOP

      Facts: 0) I'm writing a .Net Core 3.1 command line app (using C#) to read text files on some Raspberry Pi machines on the network. This app will be able to run on either Windows or Linux. 1) The files in question are in the /etc, /proc and /sys folders. 2) I don't want to create shares of these folders. 3) I'd prefer not to have to install/configure anything on the remote boxes (if at all possible). 4) I know the user ids and passwords for the remote boxes, and am aware that I have to somehow use these credentials in order to "connect" to the remote boxes). 5) I don't want to use another language. I mean, doNet Core is supposed to be cross-platform, right? Problem: How do I go about reading a file on a remote linux box? I've tried a number of ways to do this, but I keep getting the following exception: "The network name cannot be found. : '\\\\192.168.1.10\\sys\\class\\thermal\\thermal_zone0\\temp'" (BTW, when running in Windows, the exception is presented with backslashes. I'm actually using forward slashes.)

      ".45 ACP - because shooting twice is just silly" - JSOP, 2010
      -----
      You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
      -----
      When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013

      K Offline
      K Offline
      k5054
      wrote on last edited by
      #2

      Is this any help? [GitHub - sshnet/SSH.NET: SSH.NET is a Secure Shell (SSH) library for .NET, optimized for parallelism.](https://github.com/sshnet/SSH.NET) I have not looked too closely at it, but at worst you could use the SCP functionality to copy the file to the local host and then read them in the normal way.

      Keep Calm and Carry On

      realJSOPR 1 Reply Last reply
      0
      • K k5054

        Is this any help? [GitHub - sshnet/SSH.NET: SSH.NET is a Secure Shell (SSH) library for .NET, optimized for parallelism.](https://github.com/sshnet/SSH.NET) I have not looked too closely at it, but at worst you could use the SCP functionality to copy the file to the local host and then read them in the normal way.

        Keep Calm and Carry On

        realJSOPR Offline
        realJSOPR Offline
        realJSOP
        wrote on last edited by
        #3

        They don't mention anything about .Net Core... :(

        ".45 ACP - because shooting twice is just silly" - JSOP, 2010
        -----
        You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
        -----
        When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013

        Richard DeemingR M 2 Replies Last reply
        0
        • realJSOPR realJSOP

          They don't mention anything about .Net Core... :(

          ".45 ACP - because shooting twice is just silly" - JSOP, 2010
          -----
          You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
          -----
          When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013

          Richard DeemingR Offline
          Richard DeemingR Offline
          Richard Deeming
          wrote on last edited by
          #4

          It supports .NET Standard 1.3 and 2.0, so it should just work in Core.


          "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

          "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

          1 Reply Last reply
          0
          • realJSOPR realJSOP

            Facts: 0) I'm writing a .Net Core 3.1 command line app (using C#) to read text files on some Raspberry Pi machines on the network. This app will be able to run on either Windows or Linux. 1) The files in question are in the /etc, /proc and /sys folders. 2) I don't want to create shares of these folders. 3) I'd prefer not to have to install/configure anything on the remote boxes (if at all possible). 4) I know the user ids and passwords for the remote boxes, and am aware that I have to somehow use these credentials in order to "connect" to the remote boxes). 5) I don't want to use another language. I mean, doNet Core is supposed to be cross-platform, right? Problem: How do I go about reading a file on a remote linux box? I've tried a number of ways to do this, but I keep getting the following exception: "The network name cannot be found. : '\\\\192.168.1.10\\sys\\class\\thermal\\thermal_zone0\\temp'" (BTW, when running in Windows, the exception is presented with backslashes. I'm actually using forward slashes.)

            ".45 ACP - because shooting twice is just silly" - JSOP, 2010
            -----
            You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
            -----
            When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #5

            FTP? [FTP Examples for .NET Core C#](https://www.example-code.com/dotnet-core/ftp.asp)

            It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it. ― Confucian Analects: Rules of Confucius about his food

            M 1 Reply Last reply
            0
            • L Lost User

              FTP? [FTP Examples for .NET Core C#](https://www.example-code.com/dotnet-core/ftp.asp)

              It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it. ― Confucian Analects: Rules of Confucius about his food

              M Offline
              M Offline
              markkuk
              wrote on last edited by
              #6

              FTP would require both installation and configuration on the Linux machines. SSH service is installed by default but not enabled.

              K 1 Reply Last reply
              0
              • realJSOPR realJSOP

                They don't mention anything about .Net Core... :(

                ".45 ACP - because shooting twice is just silly" - JSOP, 2010
                -----
                You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
                -----
                When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013

                M Offline
                M Offline
                markkuk
                wrote on last edited by
                #7

                The release notes for version 2016.0.0[^] says:

                Quote:

                This is the first release of SSH.NET providing support for .NET Core and Universal Windows Platform 10

                The latest "stable" release is 2016.1.0 and 2020.0.0 is in beta. Here's an example for file upload using SSH.NET and .Net Core: Upload File to SFTP Server using C# | DotNet Core | SSH.NET[^].

                realJSOPR 1 Reply Last reply
                0
                • M markkuk

                  FTP would require both installation and configuration on the Linux machines. SSH service is installed by default but not enabled.

                  K Offline
                  K Offline
                  kalberts
                  wrote on last edited by
                  #8

                  Is not FTP installed by default on all Linux machines nowadays? I honestly would have taken that for granted. FTP was developed in the days when you measured program size in kilobytes. The protocol is so simple that a student could implement it as homework assignment #3. I can't see any reason for taking it out.

                  M 1 Reply Last reply
                  0
                  • K kalberts

                    Is not FTP installed by default on all Linux machines nowadays? I honestly would have taken that for granted. FTP was developed in the days when you measured program size in kilobytes. The protocol is so simple that a student could implement it as homework assignment #3. I can't see any reason for taking it out.

                    M Offline
                    M Offline
                    markkuk
                    wrote on last edited by
                    #9

                    Member 7989122 wrote:

                    Is not FTP installed by default on all Linux machines nowadays?

                    No, not anymore. There are better replacements such as SFTP or SCP. Curl or wget can be used as FTP clients if absolutely necessary.

                    Member 7989122 wrote:

                    FTP was developed in the days when you measured program size in kilobytes.

                    Those days nobody could imagine the need for network security. FTP transmits everything, including user credentials, in cleartext. The protocol design makes it difficult to pass through firewalls without causing additional security risks. In general, it's just too dangerous and should not be used.

                    L 1 Reply Last reply
                    0
                    • M markkuk

                      Member 7989122 wrote:

                      Is not FTP installed by default on all Linux machines nowadays?

                      No, not anymore. There are better replacements such as SFTP or SCP. Curl or wget can be used as FTP clients if absolutely necessary.

                      Member 7989122 wrote:

                      FTP was developed in the days when you measured program size in kilobytes.

                      Those days nobody could imagine the need for network security. FTP transmits everything, including user credentials, in cleartext. The protocol design makes it difficult to pass through firewalls without causing additional security risks. In general, it's just too dangerous and should not be used.

                      L Offline
                      L Offline
                      Lost User
                      wrote on last edited by
                      #10

                      Quote:

                      If you are connecting to an FTP server that requires credentials and supports Secure Sockets Layer (SSL), you should set EnableSsl to true.

                      And there's one's own encryption / decryption, staging directories, etc. Keep the baby.

                      It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it. ― Confucian Analects: Rules of Confucius about his food

                      1 Reply Last reply
                      0
                      • M markkuk

                        The release notes for version 2016.0.0[^] says:

                        Quote:

                        This is the first release of SSH.NET providing support for .NET Core and Universal Windows Platform 10

                        The latest "stable" release is 2016.1.0 and 2020.0.0 is in beta. Here's an example for file upload using SSH.NET and .Net Core: Upload File to SFTP Server using C# | DotNet Core | SSH.NET[^].

                        realJSOPR Offline
                        realJSOPR Offline
                        realJSOP
                        wrote on last edited by
                        #11

                        I added SshNet with Nuget, and it workds great. :)

                        using SshNet;

                        using (var client = new SshClient("192.168.1.10", "userid", "password"))
                        {
                        client.Connect();
                        string data = string.Empty;
                        using (SshCommand cmd = client.CreateCommand("cat /proc/cpuinfo"))
                        {
                        data = cmd.Execute();
                        }
                        }

                        ".45 ACP - because shooting twice is just silly" - JSOP, 2010
                        -----
                        You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
                        -----
                        When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013

                        pkfoxP 1 Reply Last reply
                        0
                        • realJSOPR realJSOP

                          Facts: 0) I'm writing a .Net Core 3.1 command line app (using C#) to read text files on some Raspberry Pi machines on the network. This app will be able to run on either Windows or Linux. 1) The files in question are in the /etc, /proc and /sys folders. 2) I don't want to create shares of these folders. 3) I'd prefer not to have to install/configure anything on the remote boxes (if at all possible). 4) I know the user ids and passwords for the remote boxes, and am aware that I have to somehow use these credentials in order to "connect" to the remote boxes). 5) I don't want to use another language. I mean, doNet Core is supposed to be cross-platform, right? Problem: How do I go about reading a file on a remote linux box? I've tried a number of ways to do this, but I keep getting the following exception: "The network name cannot be found. : '\\\\192.168.1.10\\sys\\class\\thermal\\thermal_zone0\\temp'" (BTW, when running in Windows, the exception is presented with backslashes. I'm actually using forward slashes.)

                          ".45 ACP - because shooting twice is just silly" - JSOP, 2010
                          -----
                          You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
                          -----
                          When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013

                          J Offline
                          J Offline
                          Josh Gray2
                          wrote on last edited by
                          #12

                          Do you want to force linux to do the windows thing, or windows to do the linux thing? For the former run samba on the linux box and create shares you can access from windows. This will probably suck, the degree to which it sucks will depend on the file system you are using on the linux side. For the latter you can run an ftp server on the linux side or setup ssh and use scp. These will suck less.

                          realJSOPR 1 Reply Last reply
                          0
                          • J Josh Gray2

                            Do you want to force linux to do the windows thing, or windows to do the linux thing? For the former run samba on the linux box and create shares you can access from windows. This will probably suck, the degree to which it sucks will depend on the file system you are using on the linux side. For the latter you can run an ftp server on the linux side or setup ssh and use scp. These will suck less.

                            realJSOPR Offline
                            realJSOPR Offline
                            realJSOP
                            wrote on last edited by
                            #13

                            I found a solution - use the SshNet library and I don't have to do anything on the other pi's on the network.

                            ".45 ACP - because shooting twice is just silly" - JSOP, 2010
                            -----
                            You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
                            -----
                            When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013

                            1 Reply Last reply
                            0
                            • realJSOPR realJSOP

                              Facts: 0) I'm writing a .Net Core 3.1 command line app (using C#) to read text files on some Raspberry Pi machines on the network. This app will be able to run on either Windows or Linux. 1) The files in question are in the /etc, /proc and /sys folders. 2) I don't want to create shares of these folders. 3) I'd prefer not to have to install/configure anything on the remote boxes (if at all possible). 4) I know the user ids and passwords for the remote boxes, and am aware that I have to somehow use these credentials in order to "connect" to the remote boxes). 5) I don't want to use another language. I mean, doNet Core is supposed to be cross-platform, right? Problem: How do I go about reading a file on a remote linux box? I've tried a number of ways to do this, but I keep getting the following exception: "The network name cannot be found. : '\\\\192.168.1.10\\sys\\class\\thermal\\thermal_zone0\\temp'" (BTW, when running in Windows, the exception is presented with backslashes. I'm actually using forward slashes.)

                              ".45 ACP - because shooting twice is just silly" - JSOP, 2010
                              -----
                              You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
                              -----
                              When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013

                              U Offline
                              U Offline
                              User 13269747
                              wrote on last edited by
                              #14

                              Quote:

                              Facts: 0) I'm writing a .Net Core 3.1 command line app (using C#) to read text files on some [...] machines on the network.[...] [...] 2) I don't want to create shares of these folders.

                              If those files aren't shared, how do you expect to read them? after all, if those remote files were on Windows, you'd still need to share them for a remote computer to read them. You appear to be under the impression that, on Linux, all files are shared by default. I can assure you that this is not the case.

                              [...] How do I go about reading a file on a remote linux box?

                              Same way you would on a Windows box: you'd create a share. A second option is to install some sort of file server on the Pis(ftp, http, ssh/scp, etc) and use that to copy the files across.

                              realJSOPR 1 Reply Last reply
                              0
                              • U User 13269747

                                Quote:

                                Facts: 0) I'm writing a .Net Core 3.1 command line app (using C#) to read text files on some [...] machines on the network.[...] [...] 2) I don't want to create shares of these folders.

                                If those files aren't shared, how do you expect to read them? after all, if those remote files were on Windows, you'd still need to share them for a remote computer to read them. You appear to be under the impression that, on Linux, all files are shared by default. I can assure you that this is not the case.

                                [...] How do I go about reading a file on a remote linux box?

                                Same way you would on a Windows box: you'd create a share. A second option is to install some sort of file server on the Pis(ftp, http, ssh/scp, etc) and use that to copy the files across.

                                realJSOPR Offline
                                realJSOPR Offline
                                realJSOP
                                wrote on last edited by
                                #15

                                You really should read the whole thread. The solution has been found.

                                ".45 ACP - because shooting twice is just silly" - JSOP, 2010
                                -----
                                You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
                                -----
                                When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013

                                1 Reply Last reply
                                0
                                • realJSOPR realJSOP

                                  I added SshNet with Nuget, and it workds great. :)

                                  using SshNet;

                                  using (var client = new SshClient("192.168.1.10", "userid", "password"))
                                  {
                                  client.Connect();
                                  string data = string.Empty;
                                  using (SshCommand cmd = client.CreateCommand("cat /proc/cpuinfo"))
                                  {
                                  data = cmd.Execute();
                                  }
                                  }

                                  ".45 ACP - because shooting twice is just silly" - JSOP, 2010
                                  -----
                                  You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
                                  -----
                                  When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013

                                  pkfoxP Offline
                                  pkfoxP Offline
                                  pkfox
                                  wrote on last edited by
                                  #16

                                  Hi John, it supports private keys to - I use it in one of my net core apps to communicate with a remote database using port forwarding

                                  "I didn't mention the bats - he'd see them soon enough" - Hunter S Thompson - RIP

                                  1 Reply Last reply
                                  0
                                  Reply
                                  • Reply as topic
                                  Log in to reply
                                  • Oldest to Newest
                                  • Newest to Oldest
                                  • Most Votes


                                  • Login

                                  • Don't have an account? Register

                                  • Login or register to search.
                                  • First post
                                    Last post
                                  0
                                  • Categories
                                  • Recent
                                  • Tags
                                  • Popular
                                  • World
                                  • Users
                                  • Groups