#!/bin/bash

tmptty=`tty`
tmptty=`basename $tmptty`
tmpname=`whoami`
ip="$1"


ftpUserNameStr=`/usr/bin/mysql -prootaa <<_EOF_
SELECT pubVarValue FROM OMC_PUB.omcPubVarConf WHERE pubVarName='globalFTPUserName';
_EOF_`

ftpPasswordStr=`/usr/bin/mysql -prootaa <<_EOF_
SELECT pubVarValue FROM OMC_PUB.omcPubVarConf WHERE pubVarName='globalFTPPassword';
_EOF_`

ftpUserName=`echo $ftpUserNameStr | awk '{print $2}'`
ftpPassword=`echo $ftpPasswordStr | awk '{print $2}'`


inp1="$ftpUserName"
inp2="$ftpPassword"

inputfile="inabc"
outputfile="out.log"

chmodcnf_0="chmod 755 /usr/local/wxc2/bin/conf"
chmodcnf="chmod 755 /usr/local/wxc2/bin/conf/*"

rm -fr $inputfile
rm -fr $outputfile
mknod $inputfile p
touch $outputfile

exec 7<>$outputfile
exec 8<>$inputfile

telnet $ip <&8 >&7 &
sleep 2; echo $inp1 >>$inputfile
sleep 2; echo $inp2 >>$inputfile

#tail -f $outputfile &

sleep 3; echo "su -" >>$inputfile
sleep 2; echo "Acrdr00t!" >>$inputfile
sleep 2; echo $chmodcnf_0 >>$inputfile
sleep 2; echo $chmodcnf >>$inputfile
sleep 2; echo "wxc2d start" >>$inputfile
sleep 2; echo "exit" >>$inputfile
sleep 2; echo "exit" >>$inputfile

rm -fr $inputfile
rm -fr $outputfile

