[강영보]님이 남기신 글:
>쉘프로그래밍 과 php를 혼용해서 사용할려고 하는데여.. 잘 안되네여
>
>일단 php로 회원의 정보를 가져와서여 그 회원의 계정에 문서를 설치하는건데여
>
>
>######################
>
>#!/usr/local/bin/php -q
>
><?
>$query = "select uid from member where type = 'free'";
>$result = mysql_query($query,$conn);
>
>while($data = mysql_fetch_array($result)){
> #설치shell
> exec("../../bin/free_install.sh $data[uid]")
> }
>
>?>
>
>이런식으로 해서여..
>free_install.sh 에서는 그냥
>
>#!/bin/bash
>
>echo "무료형 생성할 계정을 입력하세요"
>echo "==============================="
>
>read mallid
>
>echo "몰아이디만 다시 입력하시요"
>
>read mall
>
>if test "$mallid" != ''; then
>cp /hosting/freemall.tar.gz /hosting/$mallid/public_html
>cd /hosting/$mallid/public_html
>tar xvzf /hosting/$mallid/public_html/freemall.tar.gz
>
>rm -rf /hosting/$mallid/public_html/conf/Merchant_set.inc
>#vi /hosting/$mallid/public_html/conf/Merchant_set.bak
>
>echo "<?" >> /hosting/$mallid/public_html/conf/Merchant_set.inc
>echo "\$Merchant_table= \"$mall\";" >> /hosting/$mallid/public_html/conf/Merchant_set.incecho "\$Main_image = \"../conf/mainimg.gif\";" >> /hosting/$mallid/public_html/conf/Merchant_set.incecho "\$product_cnt = \"6\";" >> /hosting/$mallid/public_html/conf/Merchant_set.incecho "\$oldimg = \"../conf/mainimg.gif\";" >> /hosting/$mallid/public_html/conf/Merchant_set.incecho "\$bottom_display = \"Y\";" >> /hosting/$mallid/public_html/conf/Merchant_set.incecho "\$Merchant_money = \"5000\";" >> /hosting/$mallid/public_html/conf/Merchant_set.incecho "\$Merchant_mail = \"Y\";" >> /hosting/$mallid/public_html/conf/Merchant_set.incecho "\$total_product_cnt =\"30\";" >> /hosting/$mallid/public_html/conf/Merchant_set.incecho "\$backcolor=\"#ececec\";" >> /hosting/$mallid/public_html/conf/Merchant_set.inc
>echo "\$layout=\"L\";" >> /hosting/$mallid/public_html/conf/Merchant_set.inc
>echo "?>" >> /hosting/$mallid/public_html/conf/Merchant_set.inc
>cat /hosting/$mallid/public_html/conf/Merchant_set.bak /hosting/$mallid/public_html/conf/Merchant_set.inc
>
>rm -rf sql.bakecho "create table $mall (uid int(11) not null auto_increment primary key, num int(7) not null)" >> ./sql.bakmysql -uroot -pspdhelql rkddudqh < sql.bak
>
>mv /hosting/$mallid/public_html/Product_List/auth.bak /hosting/$mallid/public_html/Product_List/auth.inc
>cat icash/Order.php3.bak | sed "s/icashurl/$mallid/g" > icash/Order.php3.bak
>rm -rf icash/Order.php3
>mv icash/Order.php3.bak icash/Order.php3chown -R $mall.$mall /hosting/$mallid/
>rm -rf /hosting/$mallid/public_html/freemall.tar.gz
>
>echo "설치완료"fi
>
>
>
>"/bin/free_install.sh" 55L, 2248C 55,0-1 Bot
>echo "\$product_cnt = \"6\";" >> /hosting/$mallid/public_html/conf/Merchant_set.inc
>echo "\$oldimg = \"../conf/mainimg.gif\";" >> /hosting/$mallid/public_html/conf/Merchant_set.inc
>echo "\$bottom_display = \"Y\";" >> /hosting/$mallid/public_html/conf/Merchant_set.inc
>echo "\$Merchant_money = \"5000\";" >> /hosting/$mallid/public_html/conf/Merchant_set.inc
>echo "\$Merchant_mail = \"Y\";" >> /hosting/$mallid/public_html/conf/Merchant_set.inc
>echo "\$total_product_cnt =\"30\";" >> /hosting/$mallid/public_html/conf/Merchant_set.inc
>echo "\$backcolor=\"#ececec\";" >> /hosting/$mallid/public_html/conf/Merchant_set.inc
>echo "\$layout=\"L\";" >> /hosting/$mallid/public_html/conf/Merchant_set.inc
>echo "?>" >> /hosting/$mallid/public_html/conf/Merchant_set.inc
>
>cat /hosting/$mallid/public_html/conf/Merchant_set.bak /hosting/$mallid/public_html/conf/Merchant_set.inc
>
>rm -rf sql.bak
>echo "create table $mall (uid int(11) not null auto_increment primary key, num int(7) not null)" >> ./sql.bak
>mysql -uroot -pspdhelql rkddudqh < sql.bak
>
>
>mv /hosting/$mallid/public_html/Product_List/auth.bak /hosting/$mallid/public_html/Product_List/auth.inc
>
>cat icash/Order.php3.bak | sed "s/icashurl/$mallid/g" > icash/Order.php3.bak
>
>rm -rf icash/Order.php3
>mv icash/Order.php3.bak icash/Order.php3
>chown -R $mall.$mall /hosting/$mallid/
>
>rm -rf /hosting/$mallid/public_html/freemall.tar.gz
>
>
>echo "설치완료"
>fi
>
>
>
>이렇게 할려고 하는데여 free_install.sh 에서 바로 설치가 되게 할려고
>하는데여.
>
>도움좀 주세요
>
>
========================================
>exec("../../bin/free_install.sh $data[uid]")
>echo "무료형 생성할 계정을 입력하세요"
>echo "==============================="
>
>read mallid
>
>echo "몰아이디만 다시 입력하시요"
>
>read mall
우선 여기에서 echo 명령어는 필요없습니다.
그리고
PHP 쉘스크립트에서는 한개의 변수($data[uid])만
전달하게 되어 있고
sh 쉘 스크립트에서는 키보드 입력(read)으로 두개의 변수를
받아오도록 되어 있습니다.
두개가 서로 매치되지 않군요.
따라서,
$mallid = $data[uid]; // ?? 맞나요?
$mall = $data[xxx]; // mall 에 필요한 정보
exec("../../bin/free_install.sh $mallid $mall")
...
# 모두 주석처리함
#
#echo "무료형 생성할 계정을 입력하세요"
#echo "==============================="
#
#read mallid
#
#echo "몰아이디만 다시 입력하시요"
#
#read mall
mallid=$1 ## 첫번째로 전달된 변수($data[uid])
mall=$2 ## 두번째로 전달된 변수($data[xxx])
이런식으로 고쳐보세요.. read 는 키보드 입력으로
변수를 받아오는 내부 명령어입니다.
|