Applescript - Bizarre issue with vhost file in SL apache

Discussion in 'Mac Programming' started by kannary, May 30, 2011.

  1. kannary macrumors newbie

    May 30, 2011
    I have a bizarre issue: I have an applescript (actually inside automator, but all the same) that creates an entry in the vhost file for apache to add a virtual server. The script works fine and adds the entry, which is properly formatted and closed:

    <VirtualHost *:80>
              DocumentRoot /Users/Klima/Sites/testsite
              ServerName testsite
              ServerAlias *.testsite
    Here is the weird part: When I restart the server, it gives me a syntax error and fails to restart. It keeps telling me the <virtualhost> is not closed, but it is. The vhost file looks fine and complete (I have been doing this for years). The ODD this is that if I edit ANYTHING on the file and resave it, it works fine, and by ANYTHING I mean ANYTHING....delete an empty space, retype any another words, it won't work unless I edit it manually and resave it. No weird hidden characters, no estrange file encoding (Western MacOS Roman with Unix LF), no missing tags....the file as changed by applescript looks pristine, but it simply will not work. And it is weird because the manual edit can be anywhere in the file, even on prior entries not added by applescript. I can even just delete a character or empty space, retype it leaving the file identical as before I edited it, save it and it works.

    The applescript is authorized to write with permissions and throws no errors. Works fine. I even tested removing the "*" and adding the dice.


    Anyone has any ideas what this could be? I am at a lost. An yes, I guess I could manually edit the vhost file and resave, sort of defeats the purpose of having an applescript generate the file for me.
  2. jiminaus macrumors 65816


    Dec 16, 2010
    It seems clear the editor is changing something. Line endings and encoding are the only things that come to mind. As I don't see any non-ASCII characters, that seems to rule out encoding, leaving line endings.

    If you hexdump -C vhost and look at the new lines before and after editing do you notice any changes?
  3. kannary thread starter macrumors newbie

    May 30, 2011
    Here it is

    Thanks a lot for the reply. Yeap, it is a weird one.

    Sorry, I just edited this as I did not read the post well. I will try it.
  4. chown33 macrumors 604

    Aug 9, 2009
    Sailing beyond the sunset
    You say the file is identical, but things can appear identical when they really aren't.

    The obvious test is to do a low-level compare before and after.

    The 'cmp' command compares byte by byte. Try that. Post any differences.

    Or use the 'hexdump -C' command before and after, then diff the hex output. Again, post any differences.

Share This Page