Microsoft – Windows / Cygwin – Error – $’\r’: command not found

Background

In Microsoft Windows, Launched Cygwin terminal mode and running a little bash shell script.

But, getting the error “$’\r’: command not found”

The \r is a dead giveaway, as it means there is something amiss with Line Character and Carriage Return.

Fix

To fix:

  • Launched Notepad++
  • Load the Bash Script File
  • Access the menu items “Edit\EOL Conversion\Unix Format”
  • Re-save file (File \ Save)

Addendum

Addendum – Thursday July 10th, 2014

Please try the following StackOverflow Q/A postings:

  • Running shell script through cygwin on Windows
    Link
  • Replace lf with crlf in text file cygwin
    Link

They discuss using dos2unix to accomplish same thing.  Crediting Roman Hocke and “me_and“.

licielrsync – rsync windows Interface

licielrsync – rsync windows Interface

If you need a quick Windows Interface for rsync, you might want to try licielrsync.

It is available @

http://code.google.com/p/licielrsync/downloads/detail?name=licielrsync-0.2.0.0.7z&can=2&q=

To speed up download and save on bandwidth cost, the file is compressed.  Interestingly enough, it is not compressed as a .zip, but in 7-zip’s native 7z.

So hoping you already use 7-zip or you can download from:

http://www.7-zip.org/

Once un-zip, just run the exe

As we are trying to play with getting cygwin, here are the parameters we used:

Source
rsync://mirrors.kernel.org/sourceware/cygwin/release/

Destination
e:\downloads\cygwin\release

Couple of quick follow-ups:

1) You might have to create the destination folder a bit ahead of time

2) licielrsync, itself, uses cygwin

References:

  1. The coolest interface to rsync
    The coolest interface to rsync for Windows

Cygwin – Grabbing on Mac for Windows Deployment

Cygwin – Grabbing on Mac for Windows Deployment

Working on my Mac Laptop today, but need to get Cygwin for a Windows Machine.

Yes, so usually you go to Cygwin web site and download the App.  But, cygwin is a bit of a pain here.  It does not allow one to download the full install.  The only install available is a kicker install.

So I am having a bit of horrible tooth-ache.  Looked all over the .Net for a good whole install.

Googled for the usual suspects:

  1. Offline Install
  2. Full Install

But nothing credible, nor half-way reliable.

The only thing that seemed worthwhile is download all the files locally and copy all those files from my laptop to the Windows Server.

So quick learn of rsync is in order.

Opted for a GUI Application; specifically Grsync.

  1. Éric Béliveau – Grsync
    http://www.macupdate.com/app/mac/38699/grsync

There are only a few options that one needs to know and enter.  Here are those entries:

1) Source

The Source is either a folder or a URL.  In our case, it is the URL for Cygwin.  To determine that URL, please sojourn to http://www.sourceware.org/cygwin/mirrors.html.  Per each URL, you have a choice http, ftp, or rsync.  As we doing rysync, grap the URL for rsync.

Based on our proximity, we chose rsync://mirrors.kernel.org/sourceware/cygwin/release/

 

2) Destination

For the Destination, choose a local folder on your machine.

3) The other options that end you up in a good place, are:

On the “Basic Options” Tab:

  • Preserve time (Checked)
  • Verbose (Checked)
  • Show Transfer progress (Checked)

On the “Advanced options” Tab:

  • Protect remote args (Unchecked)


“Advanced Options”

 

References:

  1. Cygwin – Mirror Sites
    http://www.sourceware.org/cygwin/mirrors.html

Cygwin – Editor – Error – Message – “Can’t open file for editing”

Cygwin – Editor – Error – Message – E212 – “Can’t open file for editing”

Earlier in the year, a friend had setup Cygwin on my behalf.

For those a bit unfamiliar, Cygwin allows one to run Linux emulation  on MS Windows computers.

Anyways, last couple of days turned on to the fact that I am a bit un-able to ssh to the computer when working on my laptop.

So what do:

  • Tried pinging to make sure that I am able to resolve the DNS Names
  • Tried telnet (telnet <hostname> 22)
  • Tried ssh in verbose mode (ssh -A -vvv -l <username> <hostname>)

But, still the same “un-helpful” error message:

debug1: identity file /Users/<username>/.ssh/id_rsa type 1
debug1: identity file /Users/<username>/.ssh/id_rsa-cert type -1
debug1: identity file /Users/<username>/.ssh/id_dsa type -1
debug1: identity file /Users/<username>/.ssh/id_dsa-cert type -1
ssh_exchange_identification: Connection closed by remote host

So next in line is me remote desktop’ing to the windows box, and try to review the sshd logfile for cygwin.

That log file’s full name is /var/log/sshd.log

So journeyed to /var/log and performed a quick “ls -l”

$ ls -l
total 244
drwxr-xr-x+ 1 psmith root 0 Feb 6 2012 apache
drwxr-xr-x+ 1 psmith root 0 Feb 6 2012 apache2
-rw-r--r-- 1 cyg_server root 3072984 Nov 13 07:59 lastlog
-rw-r--r--+ 1 psmith Domain Users 0 Feb 6 2012 messages
-rw-r--r-- 1 psmith root 129106 Feb 6 2012 setup.log.full
-rw-r--r-- 1 cyg_server None 0 Feb 6 2012 sshd.log
-rwxr--r--+ 1 psmith Domain Users 49280 Nov 13 17:54 wtmp

And, obviously, sshd.log is empty, not half empty, fully empty.

The next steps are to edit sshd configuration file (enable verbose logging) and restart sshd.

So changed to the /etc folder and edited sshd_config.

But, each time I tried saving my changes kept getting the error message:

"sshd_config" E212: Can't open file for writing.

So what do, messed around for a bit and wished I was Ice-Cube and hit a tripple double.

But, no, just Daniel.

Later on went to my home folder (/home/<username>) and was able to create, edit, and saved files.

It makes a bit more sense now.  Not able to save files…It appears likely that I just lack permissions.

Need to read-up on assigning permisions in cygwin.