Nov 12 2010

Text File Weirdness

Yesterday I was working on someone’s computer and I wanted to run a couple of SQL scripts.  But the task, which should have taken mere minutes, took close to 45 minutes.

Here’s why.

I downloaded a sql script from my website but any tool that I would use to run the script was failing.  Even though I know the script was good.

When opening the script in Notepad it looked like this…

munged

…when is should have looked like this.

fixed

 

To figure out what was wrong, Notepad++ too the rescue.  Here is what each the file looks like in Notepad++…

Broken.notepad

Fortunately for me, Notepad++ is “smart enough” to not care what the Windows standard is.  The trick is that Notepad++ is showing me that each line is being delimited with an ASCII Line Feed (LF) character.  Windows expects lines in text files to be delimited with 2 ASCII characters, the Carriage Return and Line Feed (CRLF).  In other words, it should like like this…

notepad  .fixed

 

How to fix it.

To fix it I used Notepad++ Advanced find and replace fixture.  Do CTRL-H (a windows standard keystroke, BTW, for opening the Find/Replace dialog in most programs.)

Here is what the dialog should look like in order to fix the file…

notepad   find dialog

Notice at the bottom of the dialog I selected the Extended feature, which allows me to find and replace non-visible ASCII characters.  Use \n to find Line Feed characters (think of “n” as meaning New Line) and use \r to find Carriage Returns (think of “r” as meaning Return.).

After doing the replace, not only would the file open correctly in Notepad but my SQL tools would run the script.  

The next thing to figure out is how the file got munged.  I suspect that the wonderful, new, free FTP client that I am using may have done it when I uploaded the file and that I need to tweak some setting next time I use it.   Maybe my next post I can disclose the fix.

Hope this helps someone else.  Enjoy.

Seth

PS  In case you don’t realize it yet from this post…NOTEPAD++ ROCKS.

UPDATE – I discovered that it was not the FTP upload that was munging the file.  It was the mere act of downloading it from the website.   So now I am zipping scripts before putting them there.

Nov 04 2010

FINALLY fixed my problem with DVD hanging on Windows 7. Yippee

I had a problem on my machine.  I COULD NOT GET my dvd player to work reliable.  Here are the nitty gritty details of the problem per my SUPERUSER.COM question that I posted 3 months ago

——————————-

Hello,

I have x64 Windows 7 running on an ASUS M50VM. The DVD drive works completely unreliably if not at all.

But the story is not that simple so bear with me…here are the gory details.

When I first got the machine it came with Windows XP and I upgraded it to Windows Vista X64 and the DVD worked fine.

When Windows 7 RC2 came out I tried it on a Virtual Machine and I liked it so much that I upgraded the machine to Win7 RC1. The DVD worked fine.

Of course, RC1 was going to start spontaneously rebooting, so when Windows 7 was released I DID A CLEAN INSTALL of Windows 7. Just to clarify…by clean install I mean I did a FORMAT of the HARD DRIVE and INSTALLED it from scratch.

EVER since then the DVD mostly doesn’t work. I can sometime read from disk but that will often hang. (Please see my description below of HANG for details.) CD or DVD writes ALWAYS fail with a HANG (I have done a successful write only one time.)

Here is what I mean by HANG…
*Explorer Window is unresponsive.
*Any software accessing the DVD drive is unresponsive.
*The DVD tray will not eject.
*Using a paper clip will eject but the disk is usually spinning real hard.
*Attempting to shut down windows will fail. I have waited as long as ten minutes but the whole OS seems to hang. I do a hard shutdown.
*Sometimes accessing the DVD (when it does not cause a HANG) will still fail and the device will actually seem to disappear from the system until I reboot.

A couple of other things. It is NOT a hardware failure. It is the Windows OS. I know this because I swapped out my DVD drive with a friend with the same model…his machine is fine (he is still running Vista X64) and my machine still fails.

For what it is worth. I swapped out my primary disk with the INTEL 160GB SSD.

—————————————

Here is my solution.

 

finally found the answer to this question.

The following URL explains the problem and I got my answer from the second to last post.

DVD Drive Wont Eject and Feezes Computer

ASUS Firmware Update that fixed it for me

 

Seth

Nov 01 2010

My Stackoverflow flair!

I’ve got Flair over on StackOverflow.

 

 profile for Seth Spearman at Stack Overflow, Q&A for professional and enthusiast programmers