| | Stumble It! | Add to Mixx! | | diigo it | | Slashdot |

Monday, December 8, 2008

pullOut(hair)

I've been struggling with a BASH script in cygwin for the last couple days that I just could .NOT. figure out. The script was supposed to read a text file as input, run a simple ping command against each entry in the text file, and parse the output into an easily readable report.

I had copy/pasted a couple scripts that worked just fine, but when I typed it in myself, all my arrays had only one element in them. The code was identical, but it wasn't working. I figured it might be execution permissions, but (as far as I can tell) cygwin doesn't worry about that. I figured I was missing a package on the install, but when I ran the commands from the terminal, they all worked.
So this morning, in my desperation, I turned on "Show All Characters" in Notepad++ (my text editor of choice). BINGO! The difference between my code and the code that I copy/pasted is that I had carriage returns and line feeds in my code and there were only line feeds in the code that worked. I was able to correct this by telling Notepad++ to format the text in "Unix Format". After doing this and running the script, my arrays were full of the lines in the text file.

0 comments: