cuban
09-09-2001, 02:02 AM
I have a script to call on a file
#!/bin/sh
#Define Variables
username=`awk -F: '{print $1}' /tmp/new.webhost`
userweb=`awk -F: '{print $2}' /tmp/new.webhost`
userpass=`awk -F: '{print $3}' /tmp/new.webhost`
#Do this!
useradd -g 200 -s /bin/false -d /webs/$userweb $username
chmod -R 755 $userweb
chown -R $username $userweb
chgrp -R webhosting $userweb
passwd $username $userpass
echo "<VirtualHost 216.110.5.16>" >> /etc/httpd/conf/named-virtual.conf
echo "DocumentRoot /webs/$userweb" >> /etc/httpd/conf/named-virtual.conf
echo "ServerName $userweb" >> /etc/httpd/conf/named-virtual.conf
echo "</VirtualHost>" >> /etc/httpd/conf/named-virtual.conf
/etc/rc.d/init.d/httpd restart
My problem is when it reads a file with more than one line of delimited text, it adds that field in all at the same time! Instead of running it many times!
username:userweb
username2:userweb2
useradd -g 200 -s /bin/false -d /webs/userweb userweb2 username username2
How can I solve this?
#!/bin/sh
#Define Variables
username=`awk -F: '{print $1}' /tmp/new.webhost`
userweb=`awk -F: '{print $2}' /tmp/new.webhost`
userpass=`awk -F: '{print $3}' /tmp/new.webhost`
#Do this!
useradd -g 200 -s /bin/false -d /webs/$userweb $username
chmod -R 755 $userweb
chown -R $username $userweb
chgrp -R webhosting $userweb
passwd $username $userpass
echo "<VirtualHost 216.110.5.16>" >> /etc/httpd/conf/named-virtual.conf
echo "DocumentRoot /webs/$userweb" >> /etc/httpd/conf/named-virtual.conf
echo "ServerName $userweb" >> /etc/httpd/conf/named-virtual.conf
echo "</VirtualHost>" >> /etc/httpd/conf/named-virtual.conf
/etc/rc.d/init.d/httpd restart
My problem is when it reads a file with more than one line of delimited text, it adds that field in all at the same time! Instead of running it many times!
username:userweb
username2:userweb2
useradd -g 200 -s /bin/false -d /webs/userweb userweb2 username username2
How can I solve this?