
jusstakas
New User
Feb 23, 2009, 4:56 AM
Post #1 of 2
(1600 views)
|
runing bash script from cgi-bin
|
Can't Post
|
|
Hi guys, i created a small bash script that creates a web hosting account for registered users. how can i run this script from cgi-bin directory (as cgi), that users can register themselves from html form. How i can put these variables $1 $2 and $3 from html form ? i cant even make it work in cgi-bin directory, i always get the 500 error the script:
#!/bin/bash # # usernamePrefix="" username="$usernamePrefix$1" password="$2" epastas="$3" quota=100000 dbname_user="$username" userLen=`perl -e "print length(\"$username\")"` if [ $userLen -gt 20 ]; then echo "Username: $username is too long ($userLen chars > 20), exiting" exit fi cryptPassword=`perl -e "print crypt(\"$password\",\"xx\")"` echo "Username = $username Password = $password" echo "-----------------------------------------" # create the group and user echo "* Creating group $username" groupadd $username echo "* Creating user $username" useradd --create-home --password $cryptPassword --shell /bin/false --comment hosting -g $username $username # personalise skel files echo "* Copying helper files and personalising" sed -e "s/<h1>Tips/<h1>Site for $username/g" /home/$username/public_html/tips.htm > /home/$username/public_html/index.htm # set quota echo "* Applying quota" setquota -u $username $quota $quota 0 0 -a # create database echo "* Creating MySQL database for User" echo "CREATE DATABASE $dbname_user; GRANT ALL ON $dbname_user.* to '$username'@'localhost' identified by '$password';" | mysql -u root -ppassword # setting permissions echo "* Setting permissions and ownership" chmod 755 /home/$username/public_html chmod 644 /home/$username/public_html/* chmod -R 755 /home/$username/public_html/cgi-bin chown -R $username.website-hosting /home/$username/public_html echo echo "* All done!" echo thanks for the answers
|