Tuesday, January 22, 2008

Cygwin

Can anyone tell me what Cygwin is (beyond what's available on the homepage), along with why and how I might use it?

I've installed the base package, but can't seem to do anything.

20 comments:

threegirldad said...

Well, it's for people who were dragged from UNIX to Windoze kicking and screaming. It's a way to migrate existing knowledge, skills, and code, rather than having to toss it all and learn a different scripting language, rewrite code from scratch, and so forth.

While not true today, 10+ years ago OS System Administration on Windoze was, well, a joke.

SA [System Administrator]: How do I make XYZ configuration change?

MS: Well, you just fire up our whizbang utility with the graphical interface, click these 5 options in sequence, and presto!

SA: What if I want to do that programatically?

MS: I don't understand what you mean.

SA: I have several hundred (or thousand or tens of thousand) machines to manage. You aren't seriously suggesting that I manually repeat that 5-step process for each one...are you???

MS: Errrr...ummmm...

And thus was born Cygwin: a Win32 port of the "standard" UNIX toolset. Even now, a combination of bash, sed, and awk still beats the pants off of VBScript/Windows Script Host for certain tasks. But Cygwin is probably now most useful for software developers who need to migrate applications from UNIX (or Linux) to Windows. Cygwin allows them to recompile existing code from source, as opposed to having to rewrite it from scratch.

threegirldad said...

Sorry -- I posted prematurely. Did you install it out of curiosity, or did you have something in particular in mind?

Charles Sebold said...

I concur with the above comments, and add:

Some people use it to recompile Unix/GNU/Linux code, and some use it because it's a handy package-management system for Unix/GNU/Linux tools. (I used a Cygwin version of Emacs for a while, for example.)

I like it, but it's a little hefty sometimes compared to MinGW. I echo the last comment: what did you want to do with it?

threegirldad said...

Some people use it to recompile Unix/GNU/Linux code

Was Richard Stallman looking over your shoulder while you were typing? ;-)

(I used a Cygwin version of Emacs for a while, for example.)

Gack!!! I'll stick with Vim, thanks. Let the "editor wars" begin! ;-)

I like it, but it's a little hefty sometimes compared to MinGW.

I'll agree with that.

Matt Gumm said...

I note with great relish that my post got you here, Charlie. But does that mean I'm going to have to come up with a series of über-geek questions to get you to visit?

As to why, well, I thought I would try out this todotxt thing from Lifehacker. Had no idea it was going to be so complicated.

I couldn't get it to work, so I was just gonna give up, but decided instead to ask about it, and see if it was worth my time to mess with, or if I needed to look for a different way to up my nerd quotient.

threegirldad said...

I have it running on XP, but haven't tried Vista yet. Are you getting a specific error message?

Matt Gumm said...

Should have been more specific. I got Cygwin installed (on home & work) on XP. I couldn't get the todotxt download to work on it, which was why I initially installed it. The ToDoTxt thing is just a bash script, but for some reason I can't change the mode on it.

Anyway, I have this program installed that I can't really use and honestly know almost nothing about, and before I just turn around and uninstall it, I thought I'd ask around a bit.

threegirldad said...

Apologies - "I have it running" meant "I have the todo shell script running." So the problem is that you can't chmod the file, as per the instructions on the site? When you `chmod +x todo.sh` you get an error message of some sort?

Matt Gumm said...

I'm sure it's user error, I just don't know what the error is.

The site said to type chmod 755 todo.sh. You said the same, only +x in place of 755. Neither one of those things mean anything to me - I'm a born & bred Win guy, I guess.

The error I get is this:
chmod: cannot access 'todo.sh': no such file or directory.

threegirldad said...

OK, that makes sense. So, try this:

- Copy (or move) todo.sh to C:\cygwin\usr\local\bin.

- Launch an XP command prompt, and enter echo %userprofile%. Copy .todo to this directory.

- Open .todo in Wordpad (not Notepad), and edit the line that reads "TODO_DIR="/home/gina/docs/todo" so that it points to an existing directory where you want todo to write its files. The edited line might look like this:

TODO_DIR="C:/Documents and Settings/gummby/My Documents/todo"

Note the use of '/' instead of '\' -- that isn't accidental.

Now, launch cygwin. At the shell prompt ('$'), enter cd /usr/local/bin. Now enter ls. You should see "todo.sh". Now chmod +x todo.sh. Now try adding a reminder:

todo.sh add This is my first reminder

...and hold your breath. ;-)

Matt Gumm said...

Yeah, maybe I should have just given up.

I don't understand what you mean by:
- Launch an XP command prompt, and enter echo %userprofile%. Copy .todo to this directory.

Do I have to do that from the command line, or can I just drag it with a right click? And where exactly am I copying it to?

threegirldad said...

[sigh] Assumptions -- not a good thing.

Don't give up!

Click the Start button, then click "Command Prompt". Now type that command I listed. %userprofile% is just a system variable that should translate to something like:

C:\Documents and Settings\gummby

The "gummby" part is no doubt different. I was just guessing there.

So, now you should have the directory location, and you can drag and drop .todo from wherever it is now to there -- no need to use the command line.

Let me know if that makes more sense.

Todo is a neat little utility; thanks for pointing it out.

Matt Gumm said...

Still getting the same error. Would it have anything to do with the fact that my WIN signon is first and last name, separated by a space?

Matt Gumm said...

Whoops. I think I got the command mode changed. But now I'm getting a different error.

Fatal Error: ~todo is not a directory.

Matt Gumm said...

I think I figured out what the problem was. I was editing the wrong line. I finally figured out that the lines with the # were comment lines.

Thanks for all your help.

Now my next question(s) are:
Do I have to change the directory every time before I can do anything?
What else can I do with this bad boy?

Charles Sebold said...

Was Richard Stallman looking over your shoulder while you were typing? ;-)

Funny. No, but being a Unix sysadmin, there can sometimes be a difference in all those things. (And yes, I think there is something to be said for distinguishing GNU and Linux.)

Gack!!! I'll stick with Vim, thanks. Let the "editor wars" begin! ;-)

Oh, come on. Emacs is a great operating system, it just needs to come with a better editor.

I note with great relish that my post got you here, Charlie. But does that mean I'm going to have to come up with a series of über-geek questions to get you to visit?

Humph. I visit whenever my news reader tells me that you update. I just don't think I'm qualified to chime in unless you cross into this category, and clearly going home for the night yesterday put me so far behind even this time that I might as well give up.

threegirldad said...

Doh! [forehead slap]

More assumptions on my part. Yes, '#' is the comment char in this case.

At this point, you should be able to just launch cygwin and run todo.sh without changing directories.

I'm guessing that when you said, "this bad boy," you meant cygwin, not the todo script. If so, that's a pretty wide open question. Is that what you're asking?

threegirldad said...

Funny. No, but being a Unix sysadmin, there can sometimes be a difference in all those things. (And yes, I think there is something to be said for distinguishing GNU and Linux.)

Of course. I'm one too, so I agree. But it was too good to pass up. ;-)

Oh, come on. Emacs is a great operating system, it just needs to come with a better editor.

Touché.

Cheers!

Matt Gumm said...

TGD: Yes, with Cygwin. I'll bang my head through todo.sh, and I'll get back to you after I've messed with it for a bit.

Charlie: Dude, you're just getting here for the good part. You don't have to walk me through actually using it (TDG did all the heavy lifting for you); you can just tell me what it's good for. If I'm not a UNIX admin, can I use it for anything useful?

Your mission, should you decide to accept it, is to make me a UNIX geek.

Dave said...

The thing I use cygwin for is if I happen to be on a windows box that has no ssh client. There may be some other more light-weight yet free (speach and beer) way to get ssh going on a wintel box, but I've never taken the trouble to find out.