How to set unix carriage returns in .sh file in windows - docker-compose

I've been following along this quickstart guide:
https://docs.docker.com/compose/aspnet-mssql-compose/
Unfortunately I've come undone with this aspect:
Note: Make sure to use UNIX line delimiters. The script doesn’t work
if you use Windows-based delimiters (Carriage return and line feed).
I've tried downloading and running dos2unix on my .sh file, and I've tried in notepad++ using the Edit > EOL Conversion - UNIX (LF) option.
But whenever I run my docker-composer up I get this:
I'm working on a windows machine. My docker engine is running linux containers (as was default). Hoping to get this quickstart working so I can get my head around it better as I'm not 100% sure of the issue but it seems related to these return characters.

Give vim editor a shot. Use set ff=unix to have \n as a line separator. You'll need vim anyway when you'll be editing linux configs inside your containers.
If you don't want to fix your editor, install sed (from cygwin or unixtools) and run this command to fix your text files:
sed 's/\r//g' entrypoint-crlf.sh > entrypoint.sh
To develop linux software it's better to have linux handy. You can run your next favorite editor (vim/emacs) in docker too.
Even better is to have a mac or linux desktop. It's so much easier to deal with linux containers when your desktop is unix-flavoured. Some people have a linux VM and do all development there accessing with ssh.

Related

How to get Emacs on MINGW64 (Windows 10)

I currently use MINGW64 (Git Bash) as my terminal on my Windows 10 machine. It works great, I like it, but it only has Vim installed as an editor and I prefer Emacs. I'm unfortunately having a really awful time getting it to work in my terminal.
What's weirder still is that I have Emacs working in Cygwin64; but I don't like using that as my terminal. The most logical fix is simply that it Emacs to my Path ENV, however that doesn't seem to help (perhaps I'm doing that wrong?). I just get bash: emacs: command not found. I found a command to install it, using Pacman, however the Pacman command cannot be found either (which is weird because I thought that was installed by default with MINGW64.
Would love any and all help on this.
A couple of options:
Use Cygwin and the Cygwin emacs. Consider your Cygwin environment completely separate from Windows, so set your PATH from within the .bashrc, not within Windows. Launch emacs from the bash command-line.
Use the Emacs Windows binary distribution, but point to the utilities within Cygwin (there's an emacs package to help with this). Again, launch from the bash command line to inherit the bash environment within emacs.
Use the Windows Subsystem for Linux, with a Linux installation, and stick with emacs from there. You get the best of the Linux world, and access to the Windows directories and files as well.
My goto choice for MANY years was the Emacs Windows binary in conjunction with Cygwin. Once I started using the WSL, however, it just worked a lot better, in a clean Linux environment, and I could get terminal and GUI emacs (and other apps) running using the VcXsrv X Server. WSL has a version that directly supports X Windows, but I don't care for the windowing environment it uses, so I stick with VcXsrv.

/usr/bin/env: 'python3\r': No such file or directory error is throwing in Windows

I am trying to deploy the hyperlegder sawtooth in my windows local machine from the below repository 'https://github.com/hyperledger/education'.
When I start the application using Docker, then I am getting an error for the tunachain-tp as below
tunachain-tp | /usr/bin/env: 'python3\r': No such file or directory
I have tried to solve the problem in the below ways
Installed python and configured the path variable
Uninstalled python
But, unfortunately none of the solution is worked out for me.
How to solve this problem?
Your issue is not with Python but with your file encoding.
It is a Windows file (end of line \r\n) but the file should be Unix (end of line \n). To fix this on Windows, you can do this in Notepad++ -> end of line Unix. You can also use cygwin (or Linux inside the docker container actually) with dos2unix.
The above is probably your problem.
Also verify Python version 3 is installed with....
python3 --version
On the command line.

How to execute shell script by double clicking in centos?

As the tile,I have a shell script needs to run every time I have to open a terminal and type "./ xxx.sh" .it is annoying when it gets too frequent now how do I execute by double clicking like the way you do it in windows?
I know there is an option just for that in Ubuntu but I can't see that here in CentOS.
I did a little bit of digging up and found these two links. Let me know if they were helpful
https://askubuntu.com/questions/286621/how-do-i-run-executable-scripts-in-nautilus
https://unix.stackexchange.com/questions/189777/how-to-launch-shell-script-with-double-click-in-centos-7
The first link is an askUbuntu link I know. But gnome uses nautilus as the file explorer program.
In my arch linux installation where I am running a cinnamon desktop environment, I just had to add a shebang (#!/usr/bin/bash) at the head of the file and use chmod to make the file an executable and I could run the script from by double clicking on it. I hope you have already tried this?
For the record this is how I do it:
In terminal
[youname#localhost ~]$ gedit ~/Desktop/YourApplication.desktop
In the file
[Desktop Entry]
Name=My Application
Comment=My Application run script
Exec=/AddressOfyourScript/yourscript.sh
Icon=/AddressOfyourIcon/youricon.png
Terminal=true
Type=Application
save and done.Apparently CentOS should give a GUI for this function.

How do I get eshell working correctly in emacs?

For some reason, when I type in commands I'm used to on linux, it works perfectly, as it does in bash... But in eshell, it doesn't work.
I've narrowed the problem to a trivial and small sample, as follows:
$ du
c:/Program: command not found
$ which bash
c:/Program Files (x86)/Git/bin/bash.exe
How do I get this working? (du is whatever it is by default... It's implemented in elisp, I haven't made any unusual changes there, that is, it's a compiled lisp function in `em-unix.el')
I would've expected something along the lines of "You have used 1.3 GiB of disk space", rather than that command not found error.
It doesn't use bash.exe, but it can use du.exe, when present.
On my system:
c: gutov $ which bash.exe
which: no bash.exe in ...
c: gutov $ which du.exe
h:/Apps/System/gnuwin32/bin/du.exe
From your error message I can tell that it calls some command and fails because it doesn't properly quote the path to executable (which contains spaces). Maybe you should do M-x report-emacs-bug.
Overall, I recommend:
1) Uninstall Git and reinstall it selecting the second option when asked about your PATH environment ("Run Git from the Windows Command Prompt"). This will remove the unix tools packaged with it from PATH.
2) Install in some directory without spaces and add to PATH unix tools from GnuWin32 project, or from Eli Zaretski's ports. The latter contains fewer packages overall, but it has a much faster find, for example. You can mix them.
Alternatively, maybe you can get away with just reinstalling Git into directory without spaces.

How to change the line ending used in Netbeans

Netbeans has this wiki entry on line endings: http://wiki.netbeans.org/FaqEditorEOLs
But it isn't very useful. It just says that you shouldn't develop on different OS and that's that...
In my situation however, I have no power over it. I'm on a windows machine and the PHP app I'm working on needs to end with the UNIX EOL.
There does not seem to be an option to set this for new files. Can anyone tell me where to set this?
Just saw that you can set this as a command-line startup flag: -J-Dline.separator=LF
I haven't tested this myself but I'm looking for ways to bake this into the configs somehow.
Since, a specific plug-in came out: http://plugins.netbeans.org/PluginPortal/faces/PluginDetailPage.jsp?pluginid=36810
I also like #JimLewis suggestion but I work on Windows with a linux virtual machine thus in some cases the versioning system line ending cannot help.
[update 201709]
I no longer use netbeans (sorry, but I need python support and it's too buggy) and almost no longer develop on windows, but #marinos-an in a comment suggests https://github.com/welovecoding/editorconfig-netbeans which uses a common setting file that can be picked up by multiple editors through plugins. Definitely interesting to try since the settings file is committable!
Have you considered managing the line endings at the version control level? Subversion,
for example, lets you set an "eol-style" attribute with values "LF", "CR", "CRLF",
and "native" (which translates the line endings stored in the repository to whatever
is appropriate for the platform where the files are being checked out, and converts
the other way when you check in.)
Please use following Netbeans Plugin
http://plugins.netbeans.org/plugin/36810/show-and-change-line-endings
fentie's answer solved my problem with line endings, as pasting multi-line MySQL from NetBeans into the MySQL command prompt caused errors.
To pass this argument to NetBeans every time it opens, add it to the netbeans.conf file:
/Applications/NetBeans/NetBeans\ 7.1.2.app/Contents/Resources/NetBeans/etc/netbeans.conf on OS X.
From the NetBeans Mac page under Tips & Tricks.
When I pasted multi-line SQL statements from NetBeans to the MySQL command line client on OS X or a remote Linux server, MySQL would list all possible command choices, give me some strange '> type of prompt and I was forced to hit Ctrl+C and log back into MySQL again.
For my Netbeans 12.6
I found a pluging called "Change Line Endings on Save"
https://plugins.netbeans.apache.org/catalogue/?id=31
more details are there
https://github.com/junichi11/netbeans-change-lf
once pluging installed you can configure EOL in there:
Tools > Options > Editor > Line Endings