Linux scripts going wonky? That’ll be the newline…
March 5, 2013 Leave a comment
Recently I’ve been working with Linux more closely than I have in the past, in part due to the use of ZENWorks 11 which in our case runs on SLES rather than Windows. Today I wanted to sort out the next stage of our imaging process, which involves customising the PXE boot menu so we can easily upgrade machines without needing to mess around with hardware rules (more on that later!)
Basically what this comes down to is a custom bash script to detect the machine type and run various imaging maintenance commands.
So I fired up my trusty editor of choice (the excellent Notepad2) to start editing. Feeling confident about the script it was duly copied to USB, mounted in Linux and… fail 😦
Bits of the script were running but bits were writing over the same line and other sections showing command not found5
Hardened Linux fans will most likely be throwing things at the screen right now as the answer is devilishly simple… newlines! Not something you think about when only operating in the Windows world but unless you set it correctly any files made inside a Windows editor won’t work too well when you run them on Linux.
Luckily all it takes to sort is one click on the File Menu et voila, problem solved…