Community

    • Login
    • Search
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

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

    Help wanted · · · – – – · · ·
    5
    7
    1278
    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

      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

      dinkumoil 1 Reply Last reply Reply Quote 0
      • PeterJones
        PeterJones last edited by

        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
        • Alan Kilborn
          Alan Kilborn last edited by

          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
          • dinkumoil
            dinkumoil @Hansli Müller last edited by

            @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).

            Meta Chuh 1 Reply Last reply Reply Quote 2
            • Meta Chuh
              Meta Chuh @dinkumoil last edited by

              @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
              • dinkumoil
                dinkumoil last edited by dinkumoil

                @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.
                Meta Chuh 1 Reply Last reply Reply Quote 3
                • Meta Chuh
                  Meta Chuh @dinkumoil last edited by

                  @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
                  • First post
                    Last post
                  Copyright © 2014 NodeBB Forums | Contributors