Question

I am using Mac OSX 10.6 and doing web development on it. I know a small amount about writing shell scripts, but I am not really versed in them as of yet.

What I would like to do is to write a shell script that will simply ask for a local site alias and the document directory and it will then append the new alias onto hosts with something like "127.0.0.1 mysite.local" on a new line at the bottom of etc/hosts.

Then the script would append Apache's httpd-vhosts.conf file with something like this:

<VirtualHost *:80>
    DocumentRoot "/Repositories/myproject/mysite.com/trunk/htdocs"
    ServerName mysite.local
    ServerAlias mysite.localhost
</VirtualHost>

Then it would finally run the command to restart my Apache server. Now I know the terminal command to restart Apache, that is simple enough. I also know how to read in the site name and path from the user running the script. Such as below:

#!/bin/bash
read -p "New local site name: " site
read -p "Site path (ex:/Repositories/myproject/mysite.com/trunk/htdocs): " sitepath

What I don't know how to do is to append text to a file from terminal.

Any thoughts or helpful ideas?

Thanks, Patrick

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top