中文亚洲精品无码_熟女乱子伦免费_人人超碰人人爱国产_亚洲熟妇女综合网

當(dāng)前位置: 首頁 > news >正文

在線推廣企業(yè)網(wǎng)站的方法廣東今日最新疫情通報

在線推廣企業(yè)網(wǎng)站的方法,廣東今日最新疫情通報,九江建設(shè)局網(wǎng)站,福州工程建設(shè)信息網(wǎng)站lazarus(pascal)和c語言讀日志文件篩選保存為新文件,源于看日志每次從一個很多內(nèi)容文件里查找不方便,寫個代碼輸入時分秒?yún)?shù),然后按行讀取比較日志時間,當(dāng)前秒和上一秒的輸出保存為新文件,只保存2秒鐘文件小多了&…

lazarus(pascal)和c語言讀日志文件篩選保存為新文件,源于看日志每次從一個很多內(nèi)容文件里查找不方便,寫個代碼輸入時分秒?yún)?shù),然后按行讀取比較日志時間,當(dāng)前秒和上一秒的輸出保存為新文件,只保存2秒鐘文件小多了,容易觀察。

首先上pascal代碼

program project1;{$mode objfpc}{$H+}uses{$IFDEF UNIX}cthreads,{$ENDIF}Classes,SysUtils,CustApp,dateutils { you can add units after this };type{ analyselog }analyselog = class(TCustomApplication)protectedprocedure DoRun; override;publicconstructor Create(TheOwner: TComponent); override;destructor Destroy; override;procedure WriteHelp; virtual;procedure outLog(fn,outf,t, nextt: string); virtual;function changeSencond(dt: ttime; d: integer): ttime; virtual;end;{ analyselog }procedure analyselog.DoRun;varfn: string;dt1,dt2: string;dt: TTime;beginif GetParamCount > 1 thenbegindt2:= GetParams(1);writeln(dt2);dt := changeSencond(StrToTime(dt2), -1);dt1 := timetostr(dt);writeln(dt1);fn := format('%s/dms-jc5000.txt', [GetParams(2)]);writeln(GetParams(2));writeln(fn);if FileExists(fn) then  outLog(fn,'jc5000.txt',dt1, dt2);if GetParamCount > 2 thenbeginfn := format('%s/dms-all.txt', [GetParams(2)]);if FileExists(fn) then  outLog(fn,'dmsall.txt',dt1, dt2);endendelseWriteHelp;Terminate;end;constructor analyselog.Create(TheOwner: TComponent);begininherited Create(TheOwner);StopOnException := True;end;destructor analyselog.Destroy;begininherited Destroy;end;procedure analyselog.WriteHelp;begin{ add your help code here }writeln('normal usage example: ', ExeName, ' 06:39:37 /root/logs ');writeln('then we will get /root/logs/jc5000.txt from 06:39:36 to 06:39:37');writeln('other usage example: ', ExeName, ' 06:39:37 /root/logs all');writeln('then we will get /root/logs/jc5000.txt and /root/logs/dmsall.txt from 06:39:36 to 06:39:37');end;function analyselog.changeSencond(dt: ttime; d: integer): ttime;varHour, Min, Sec, MSec: word;beginDecodeTime(dt, Hour, Min, Sec, MSec);Sec := Sec + d;Result := EncodeTime(Hour, Min, Sec, MSec);end;procedure analyselog.outLog(fn,outf,t, nextt: string);varF: TextFile;oL: TStringList;d, linestr: string;tover: integer;beginAssignFile(F, fn);Reset(F);tover := 0;oL := TStringList.Create;while not EOF(F) dobeginReadLn(F, linestr);if length(linestr) > 0 thenbegind := copy(linestr, 1, 8);if (0 = comparetext(d, t)) or (0 = comparetext(d, nextt)) thenbeginwriteln(linestr);oL.Add(linestr);tover := 1;endelsebeginif tover > 0 then  break;end;end;end;CloseFile(F);oL.SaveToFile(outf);oL.Free;end;varApplication: analyselog;{$R *.res}beginApplication := analyselog.Create(nil);Application.Title := 'analyse';Application.Run;Application.Free;
end.

實現(xiàn)過程中發(fā)現(xiàn)pascal里沒有直接命令復(fù)制文件,只好外面整個腳本,因為我這從文件里查找內(nèi)容不能影響原先文件被別的應(yīng)用繼續(xù)寫

#!/bin/bash
if [ ! -n "$1" ] ;then
echo "you have not input a hh:mm:ss !"
echo "example : ./getjc5000log.sh 06:39:37"
else
echo "the word you input is $1"
d='/root/logs'
cp -f $d/dms-jc5000.log $d/dms-jc5000.txt
cp -f $d/dms-all.log $d/dms-all.txt
./analyselog $1 $vxwlu0yf4 all
fi

寫完之后運行可以,但是覺得發(fā)布試用要2個文件稍微不完美,好吧,再用c實現(xiàn)一下

#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <stdlib.h>
#include <ctype.h>
#define _XOPEN_SOURCE
#define __USE_XOPEN
#include <time.h>
// 每行最大長度
#define LINE_MAX 2048
//判斷一行數(shù)據(jù)是否有可打印的字符,只有空格不可見的不算,然后判斷行首是否滿足需要
int isblankline(char str[], char* time1, char* time2) {int k = 0;for (int i = 0; str[i] != '\0'; i++) {if (0 == isgraph(str[i])) {k = 1;break;}}if (1 == k && (0 == strncmp(str, time1, 8) || 0 == strncmp(str, time2, 8))) {return 1;}return 0;
}
//將字符串轉(zhuǎn)成時間戳,偏移后輸出字符串
long analyse_time(char* str_time, char* new_time)
{struct tm stm;memset(&stm, 0, sizeof(stm));strptime(str_time, "%H:%M:%S", &stm);stm.tm_year = 70;stm.tm_mday = 1;stm.tm_mon = 1;printf("str_time= %d %d %d     %d\n", stm.tm_hour, stm.tm_min, stm.tm_sec, sizeof(new_time));stm.tm_sec--;long t = mktime(&stm);struct tm tm2 = *localtime(&t);strftime(new_time, 10, "%H:%M:%S", &tm2);printf("new_time= %s    sec %d\n", new_time, tm2.tm_sec);return 0;
}
// 按行讀文件滿足需要的另存為文件
int createfile(char* file1, char* file2, char* file3, char* time1, char* time2) {char cmd[128] = { 0 };sprintf(cmd, "cp -f %s %s", file1, file2);int k = system(cmd);printf("cp %s !%d\n", file2, k);if (access(file2, F_OK) == 0) {FILE* fp = fopen(file2, "r");FILE* out = fopen(file3, "w");if (NULL == fp) {printf("open file failed.\n");return -1;}if (NULL == out) {printf("out file failed.\n");return -1;}int line_len = 0; // 文件每行的長度char buf[LINE_MAX] = { 0 }; // 行數(shù)據(jù)緩存while (fgets(buf, LINE_MAX, fp)) {line_len = strlen(buf);if (isblankline(buf, time1, time2)) {printf("%s\n", buf);/** 對每行數(shù)據(jù)(buf)進(jìn)行處理 **/fputs(buf, out);}}if (0 == feof) {// 未讀到文件末尾printf("fgets error no end\n");}fclose(fp);fclose(out);}else {printf("isnotexist %s!\n", file2);}
}int main(int argc, char* argv[])
{char newtime[10] = { 0 };printf("hello world\n Harmony is coming!%d\n", argc);if (argc < 2) {printf("no param ! example: ./loganalyse 00:00:11\n");return 1;}else {printf("app= %s  param = %s\n", argv[0], argv[1]);analyse_time(argv[1], newtime);}createfile("dms-all.log", "dms-all.txt", "dmsall.txt", newtime, argv[1]);createfile("dms-jc5000.log", "dms-jc5000.txt", "jc5000.txt", newtime, argv[1]);return 0;
}

http://www.risenshineclean.com/news/55475.html

相關(guān)文章:

  • wordpress 連接qq視頻教程seo是什么意思電商
  • 做網(wǎng)站 多少人軟件開發(fā)流程八個步驟
  • wordpress 模板漢化sem 優(yōu)化價格
  • 仿牌做獨立網(wǎng)站可靠嗎全球搜索
  • 上海網(wǎng)站建設(shè)滬icp備手機百度app下載安裝
  • 北京做網(wǎng)站建設(shè)的公司哪家好電銷系統(tǒng)
  • 上海網(wǎng)站建設(shè)公司招聘網(wǎng)絡(luò)營銷策略存在的問題
  • 煙臺h5網(wǎng)站建設(shè)公司投稿網(wǎng)
  • 武漢 網(wǎng)站制作網(wǎng)絡(luò)優(yōu)化seo是什么工作
  • 相親網(wǎng)站做期貨現(xiàn)貨貴金屬的人產(chǎn)品推廣方案ppt
  • 自己建網(wǎng)站數(shù)據(jù)怎么做石家莊抖音seo
  • 安徽合肥做網(wǎng)站的公司最新熱點新聞
  • 拖拽網(wǎng)站怎么做的小紅書kol推廣
  • 移動網(wǎng)站建設(shè)哪家好什么平臺可以打廣告做宣傳
  • 網(wǎng)站建設(shè)分金手指排名十百度網(wǎng)絡(luò)電話
  • 響應(yīng)式制作網(wǎng)站建設(shè)線上教育培訓(xùn)機構(gòu)十大排名
  • 網(wǎng)站導(dǎo)航圖怎么做百度推廣登錄網(wǎng)站
  • 網(wǎng)站正在建設(shè)中 html源碼快手作品免費推廣軟件
  • 海安網(wǎng)站開發(fā)seo教程排名第一
  • 大公司網(wǎng)站色彩設(shè)計萬網(wǎng)域名查詢官網(wǎng)
  • 做有獎競猜網(wǎng)站違法嗎網(wǎng)站搭建需要多少錢?
  • 做網(wǎng)站php與python做推廣怎么賺錢
  • 做ppt的軟件模板下載網(wǎng)站有哪些網(wǎng)站建站公司
  • 商丘銷售網(wǎng)站制作自媒體
  • 百度免費網(wǎng)站怎樣建設(shè)網(wǎng)絡(luò)推廣的重要性與好處
  • 上海網(wǎng)站建設(shè)公司排名外包接單平臺
  • 葫蘆島建設(shè)信息網(wǎng)站企業(yè)建站都有什么網(wǎng)站
  • 閑魚怎么做釣魚網(wǎng)站廣告資源發(fā)布平臺
  • 網(wǎng)站怎么解析到域名百度地圖網(wǎng)頁版進(jìn)入
  • 徐州專業(yè)網(wǎng)站制作公司網(wǎng)址注冊在哪里注冊