0

I'm writing a VMWare ESX automated build script and I'm falling at the last hurdle, probably as I'm really not strong at scripting.

I need to secure Grub so in my script I have a like saying;

echo "password --md5 password-converted-to-md5" >> /boot/grub/grub.conf

This unfortunately places the following into this file;

password ?-md5 password-converted-to-md5

I know it's a simple one for some of you guys but I've been googling for hours and I'm getting frustrated.

Thank you very much in advance.

Joachim Sauer
  • 302,674
  • 57
  • 556
  • 614
Chopper3
  • 298
  • 2
  • 8
  • 1
    Are you absolutely sure that both dashes in "--md5" are simple ASCII minus characters (U+002D)? You might accidentally have used U+2010 HYPEN "‐", U+2011 NON-BREAKING HYPEN "‑" or any other similar character. Try deleting both dashes and re-typing them. – Joachim Sauer Oct 12 '09 at 12:24
  • 1
    (note: this kind of error is relatively common when writing scripts in anything than a simple text editor, MS Word and similar tools are infamous for doing that kind of replacements that make sense in natural language text but mess up code) – Joachim Sauer Oct 12 '09 at 12:25
  • I used MS Notepad but will now check using nano/vi - thanks. – Chopper3 Oct 12 '09 at 12:59

2 Answers2

2

make sure you have simple ascii dashes and not other chars like non-breaking-hyphen, mathematical-minus, en-dash, em-dash, etc. best is to just re-type your line, this will hopefully solve your problem

knittl
  • 246,190
  • 53
  • 318
  • 364
  • You were right, thank you - I'd written the script using MS notepad and for some reason the first hyphen was displayed fine in notepad but as an accented 'u' in nano - lovely old MS eh! thanks again chaps. – Chopper3 Oct 12 '09 at 13:11
1

I would use simple quote and see if it's help:

echo 'password --md5 password-converted-to-md5' >> /boot/grub/grub.conf

or with a variable:

echo $passwordVar' --md5 password-converted-to-md5' >> /boot/grub/grub.conf