Results 1 to 2 of 2
Hello everyone
The title of this post may sound like it's real easy and simple enough for a noob to do but my situation isn't noobish.
I have this script ...
- 11-14-2010 #1Just Joined!
- Join Date
- Aug 2010
- Posts
- 8
editing script to create a default web page
Hello everyone
The title of this post may sound like it's real easy and simple enough for a noob to do but my situation isn't noobish.
I have this script that i found on the internet that i wish to edit and create a new user and set a pass word AND create a default web page in the /var/www/html directory.
This is the script with my edits included. The commented out field are my own editing.....
I know this may seem like a weird way of doing it but please forgive me, i haven't worked on linux in years and am trying to get back in the swing of it. My main points areCode:#!/bin/bash # Script to add a user to Linux system if [ $(id -u) -eq 0 ]; then read -p "Enter username : " username read -s -p "Enter password : " password egrep "^$username" /etc/passwd >/dev/null if [ $? -eq 0 ]; then echo "$username exists!" exit 1 else pass=$(perl -e 'print crypt($ARGV[0], "password")' $password) useradd -m -p $pass $username [ $? -eq 0 ] && echo "User has been added to system!" || echo "Failed to add a user!" #touch index.php /var/www/html fi else echo "Only root may add a user to the system" exit 2 fi
- Make a file in the /var/www/html folder that is a .php or .html extension
- How could i create a default html / php web page from whithin the script? if possible?
Thanks in advanced,
Braden
- 12-11-2010 #2
You should make a directory for the user, then create the HTML file:
Code:mkdir /var/www/html/$username || exit 1 { printf "<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">\n" printf "<head>\n <title></title>\n </head>\n" printf " <body>\n <h1></h1>\n" } > /var/www/html/$username/index.html


Reply With Quote