windows终端使用ftp访问linux(转)
2014-04-18 21:12
483 查看
debug()
{
debug="true"
if [ $debug = "true" ]
then
echo $1
fi;
}
getYesterday()
{
yesterday=
yesterday=`date -d last-day +"%Y/%m/%d"`
debug $yesterday
}
getToday()
{
today=
today=`date +"%Y/%m/%d"`
debug $today
}
initialDate()
{
getYesterday
getToday
}
getlegoHome()
{
legoHome=
if [ -f /etc/profile.d/lego.sh ]; then
. /etc/profile.d/lego.sh
legoHome=`echo $LEGO_HOME`
fi
}
initail()
{
initialDate
getlegoHome
}
#$1 means lines, $2 tarLogFile, $3 each file
#get its 20 lines after exception
getLogFromEachLine()
{
#no exception
if [ $# != 3 ]
then
return
fi;
fileName=$3
logName=$2
linewithColon=$1
debug $fileName
debug $logName
lines=
lines=`echo $linewithColon | cut -d: -f1- --output-delimiter=" "`
debug $lines
#first and last time, do nothing
for line in $lines
do
grep -i "zip" $fileName > /dev/null
#its zip file
if [ $? = 0 ]
then
endLine=$[line + 20]
zcat $fileName | sed -n "$line,$endLine p" >> $logName
else
endLine=$[line + 20]
cat $fileName | sed -n "$line,$endLine p" >> $logName
fi;
done
}
#exceptionLine begin line, $1 exceptionStartLine,$2 file names
getExceptionLines()
{
exceptionEndLine=
findIt="false"
for allLine in $alllines
do
if [ $findIt = "true" ]
then
exceptionEndLine=$allLine
break;
fi;
if [ $allLine -eq $1 ]
then
findIt="true"
fi;
done;
if [ -z $exceptionEndLine ]
then
exceptionEndLine=`cat $2 | wc -l`
fi;
}
# $1 means the dir, $2 means the tar file
getDayLog()
{ dirName=$1
cd $dirName
logName=$2
whichDay=$3
for file in `ls`
do
echo "start $file" >> $2
#get today's log
#get each line first
alllines=
alllines=`zgrep -n "$whichDay" $file | awk -F : '{print $1}'`
exceptionLines=
exceptionLines=`zgrep -n "$whichDay" $file | grep -i exception | awk -F : '{print $1}'`
for exceptionLine in $exceptionLines
do
getExceptionLines $exceptionLine $file
grep -i "zip" $file > /dev/null
if [ $? = 0 ]
then
zcat $file | sed -n "$exceptionLine,$exceptionEndLine p" >> $logName
else
cat $file | sed -n "$exceptionLine,$exceptionEndLine p" >> $logName
fi;
done;
done
}
getLog()
{
getDayLog $1 $2 $today
getDayLog $1 $2 $yesterday
}
doAll()
{
initail
#feLog
getLog $legoHome/Runtime/Tomcat6/logs /root/feLog
#getLog $legoHome/Runtime/LegoRuntime/logs /root/beLog
#getLog $legoHome/Runtime/LegoRuntime/logs/webnmslog /root/webNmsLog
}
doAll
{
debug="true"
if [ $debug = "true" ]
then
echo $1
fi;
}
getYesterday()
{
yesterday=
yesterday=`date -d last-day +"%Y/%m/%d"`
debug $yesterday
}
getToday()
{
today=
today=`date +"%Y/%m/%d"`
debug $today
}
initialDate()
{
getYesterday
getToday
}
getlegoHome()
{
legoHome=
if [ -f /etc/profile.d/lego.sh ]; then
. /etc/profile.d/lego.sh
legoHome=`echo $LEGO_HOME`
fi
}
initail()
{
initialDate
getlegoHome
}
#$1 means lines, $2 tarLogFile, $3 each file
#get its 20 lines after exception
getLogFromEachLine()
{
#no exception
if [ $# != 3 ]
then
return
fi;
fileName=$3
logName=$2
linewithColon=$1
debug $fileName
debug $logName
lines=
lines=`echo $linewithColon | cut -d: -f1- --output-delimiter=" "`
debug $lines
#first and last time, do nothing
for line in $lines
do
grep -i "zip" $fileName > /dev/null
#its zip file
if [ $? = 0 ]
then
endLine=$[line + 20]
zcat $fileName | sed -n "$line,$endLine p" >> $logName
else
endLine=$[line + 20]
cat $fileName | sed -n "$line,$endLine p" >> $logName
fi;
done
}
#exceptionLine begin line, $1 exceptionStartLine,$2 file names
getExceptionLines()
{
exceptionEndLine=
findIt="false"
for allLine in $alllines
do
if [ $findIt = "true" ]
then
exceptionEndLine=$allLine
break;
fi;
if [ $allLine -eq $1 ]
then
findIt="true"
fi;
done;
if [ -z $exceptionEndLine ]
then
exceptionEndLine=`cat $2 | wc -l`
fi;
}
# $1 means the dir, $2 means the tar file
getDayLog()
{ dirName=$1
cd $dirName
logName=$2
whichDay=$3
for file in `ls`
do
echo "start $file" >> $2
#get today's log
#get each line first
alllines=
alllines=`zgrep -n "$whichDay" $file | awk -F : '{print $1}'`
exceptionLines=
exceptionLines=`zgrep -n "$whichDay" $file | grep -i exception | awk -F : '{print $1}'`
for exceptionLine in $exceptionLines
do
getExceptionLines $exceptionLine $file
grep -i "zip" $file > /dev/null
if [ $? = 0 ]
then
zcat $file | sed -n "$exceptionLine,$exceptionEndLine p" >> $logName
else
cat $file | sed -n "$exceptionLine,$exceptionEndLine p" >> $logName
fi;
done;
done
}
getLog()
{
getDayLog $1 $2 $today
getDayLog $1 $2 $yesterday
}
doAll()
{
initail
#feLog
getLog $legoHome/Runtime/Tomcat6/logs /root/feLog
#getLog $legoHome/Runtime/LegoRuntime/logs /root/beLog
#getLog $legoHome/Runtime/LegoRuntime/logs/webnmslog /root/webNmsLog
}
doAll
相关文章推荐
- Windows终端使用FTP访问Linux
- Windows终端使用FTP访问Linux
- Windows终端使用FTP访问Linux
- 在linux下使用ftp命令访问windows下的Serv-U服务器
- Serv-U在linux下使用ftp命令访问windows下的ftp服务器
- [Linux]FTP/VSFTP/配置文件/本地匿名虚拟用户访问/ftp客户端使用
- Linux使用笔记: 使用Samba访问windows的共享目录
- linux访问windows的FTP乱码
- 使用浏览器访问 Linux 终端
- Linux与Windows之间使用FTP互传文…
- 像Linux终端一样使用windows命令行【cmder】
- Linux下使用pure-ftpd建立匿名ftp访问
- Linux 终端访问 FTP 及 上传下载 文件[转]
- 快速实现配置Windows客户端访问在linux平台上所搭建的Samba服务器&&使用swat软件
- Windows上使用SecureCRT软件连接Linux终端 — 解决问题;The remote system refused the connection
- 在Windows上使用终端模拟程序连接操作Linux以及上传下载文件
- 关于windows下使用putty+Xming远程访问linux程序的中文输入问题
- linux下访问windows ftp服务器出现乱码问题解决方案
- 在linux终端下使用scp与远程windows传输文件