CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Advanced:
runing bash script from cgi-bin

 



jusstakas
New User

Feb 23, 2009, 4:56 AM

Post #1 of 2 (802 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:


Code
 
#!/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


FishMonger
Veteran / Moderator

Feb 23, 2009, 7:35 AM

Post #2 of 2 (795 views)
Re: [jusstakas] runing bash script from cgi-bin [In reply to] Can't Post

This is a Perl forum, not bash.

You will have better luck asking your question in a bash forum, like here:
http://www.experts-exchange.com/Programming/Languages/Scripting/Shell/bash/#browseZones

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives