• Login
Community
  • Login

Notepad++ generates corrupt files for Linux (Shell script)

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
7 Posts 5 Posters 2.1k Views
Loading More Posts
  • 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.
  • H
    Hansli Müller
    last edited by Hansli Müller Jun 7, 2019, 3:12 PM Jun 7, 2019, 3:12 PM

    Message: -bash: ./getslaveip.sh: /bin/bash^M: Defekter Interpreter: Datei oder Verzeichnis nicht gefunden

    Why that?

    More here: https://forum-raspberrypi.de/forum/thread/43379-raspbian-stretch-kann-mit-unter-windows-und-notepad-erstellte-shellskripts-nicht/?postID=382917#post382917

    Regards,
    Jan

    D 1 Reply Last reply Jun 9, 2019, 11:43 AM Reply Quote 0
    • P
      PeterJones
      last edited by Jun 7, 2019, 3:15 PM

      You saved the file with Windows EOL (CRLF), but then used it on a Linux system (which wants just LF).

      If you are using FTP to transfer the file from your windows editor machine to the linux system, use ASCII mode rather than binary mode. or, if you’d prefer, in Windows Notepad++, Edit > EOL Conversion > Unix (LF), then save the file and move it to the linux machine however you used to.

      1 Reply Last reply Reply Quote 1
      • A
        Alan Kilborn
        last edited by Jun 7, 2019, 5:36 PM

        One more thing maybe worth mentioning is that sometimes programs require the last line of a file to have a line-ending character(s). Notepad++ does NOT enforce such a thing when you save, so…

        1 Reply Last reply Reply Quote 2
        • D
          dinkumoil @Hansli Müller
          last edited by Jun 9, 2019, 11:43 AM

          @Jan-Marti

          If the error was actually caused by a wrong end-of-line format, I recommend using my AutoEolFormat plugin, which I created for exactly this purpose. Available via PluginManager (Notepad++ up to v7.5.9) and PluginsAdmin (Notepad++ v7.6 and higher).


          Sollte der Fehler tatsächlich durch ein falsches Zeilenende-Format hervorgerufen worden sein, empfehle ich die Verwendung meines AutoEolFormat- Plugins, dass ich für genau diesen Zweck erstellt habe. Erhältlich über PluginManager (Notepad++ bis v7.5.9) und über PluginsAdmin (Notepad++ v7.6 und höher).

          M 1 Reply Last reply Jun 9, 2019, 7:06 PM Reply Quote 2
          • M
            Meta Chuh moderator @dinkumoil
            last edited by Jun 9, 2019, 7:06 PM

            @Jan-Marti

            i can highly recommend @dinkumoil 's autoeolformat plugin for your case, as it can set all your newly created .sh files to linux/unix (lf) eol automatically, without having to think about them.
            (see screenshot below)

            • create a group named e.g. Linux Shell Scripts
            • add the extension .SH to it
              (note: the . is optional and will be added automatically, if you type an extension without it)
            • select Unix (LF) from the eol format dropdown menu.

            ich kann dir @dinkumoil 's autoeolformat plugin für deine raspberry sachen wärmstens empfehlen.
            einmal eingerichtet, setzt es .sh dateien, und andere die du am raspi verwendest, automatisch auf das benötigte zeilenendeformat linux/unix (lf) statt windows (cr+lf), ohne dass man dauernd darüber nachdenken musst.
            (siehe screenshot unten)

            • erstell eine gruppe, z.b. Linux Shell Scripts
            • füge die dateiendung .SH hinzu, oder auch andere die du zusätzlich brauchen könntest.
              (der . punkt ist optional und wird automatisch hinzugefügt, wenn man ihn nicht eingibt)
            • wähle Unix (LF) aus dem eol format dropdown menü.

            Imgur

            lg

            1 Reply Last reply Reply Quote 2
            • D
              dinkumoil
              last edited by dinkumoil Jun 10, 2019, 10:52 AM Jun 10, 2019, 10:52 AM

              @Jan-Marti , @Meta-Chuh

              It seems that my design of the AutoEolFormat UI isn’t very intuitive because the required steps have to be done in a different order.

              1. Type a group name (e.g. Linux Shell Scripts) into the Group name input field.
              2. Select Unix (LF) from the EOL format dropdown menu.
              3. Click on the + button under the left list box.
              4. Type .SH into the New filename extension(s) inputfield. (note: the . is optional and will be added automatically, if you type an extension without it).
              5. Click on the + button under the right list box.

              Es scheint, dass mein Design der Benutzeroberfläche von AutoEolFormat nicht sehr intuitiv ist, da die erforderlichen Schritte in einer anderen Reihenfolge durchgeführt werden müssen.

              1. Geben Sie einen Gruppennamen (z.B. Linux Shell Scripts) in das Eingabefeld Group name ein.
              2. Wählen Sie Unix (LF) aus dem Dropdown-Menü EOL-Format.
              3. Klicken Sie auf die Schaltfläche + unter dem Listenfeld links.
              4. Geben Sie .SH in das Eingabefeld New filename extension(s) ein. (Hinweis: Der . ist optional und wird automatisch hinzugefügt, wenn Sie eine Erweiterung ohne ihn eingeben).
              5. Klicken Sie auf die Schaltfläche + unter dem Listenfeld rechts.
              M 1 Reply Last reply Jun 10, 2019, 1:15 PM Reply Quote 3
              • M
                Meta Chuh moderator @dinkumoil
                last edited by Jun 10, 2019, 1:15 PM

                @dinkumoil

                oooops, my apologies, i just wrote this from top to bottom, after already having done those settings.
                thanks for the correction before anything happens.


                upsi, klaro … ich sollte besser mitschreiben während ich was einstelle, statt danach aus dem gedächtnis.
                sorry, für meinen senf. war gut gemeint, bringt aber natürlich nichts, wenn dadurch das eol format nicht mitgespeichert wird.
                danke für’s ausbessern, bevor was passiert.

                glg

                1 Reply Last reply Reply Quote 2
                2 out of 7
                • First post
                  2/7
                  Last post
                The Community of users of the Notepad++ text editor.
                Powered by NodeBB | Contributors