安娜尔返利机器人怎么做网站/百度查询关键词排名工具
lazarus(pascal)和c语言读日志文件筛选保存为新文件,源于看日志每次从一个很多内容文件里查找不方便,写个代码输入时分秒参数,然后按行读取比较日志时间,当前秒和上一秒的输出保存为新文件,只保存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.
实现过程中发现pascal里没有直接命令复制文件,只好外面整个脚本,因为我这从文件里查找内容不能影响原先文件被别的应用继续写
#!/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 ${d} all
fi
写完之后运行可以,但是觉得发布试用要2个文件稍微不完美,好吧,再用c实现一下
#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
//判断一行数据是否有可打印的字符,只有空格不可见的不算,然后判断行首是否满足需要
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;
}
//将字符串转成时间戳,偏移后输出字符串
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 }; // 行数据缓存while (fgets(buf, LINE_MAX, fp)) {line_len = strlen(buf);if (isblankline(buf, time1, time2)) {printf("%s\n", buf);/** 对每行数据(buf)进行处理 **/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;
}
相关文章:

lazarus(pascal)和c语言读日志文件筛选保存为新文件
lazarus(pascal)和c语言读日志文件筛选保存为新文件,源于看日志每次从一个很多内容文件里查找不方便,写个代码输入时分秒参数,然后按行读取比较日志时间,当前秒和上一秒的输出保存为新文件,只保存2秒钟文件小多了&…...

学习JAVA打卡第四十九天
Random类 尽管可以使用math类调用static方法random()返回一个0~1之间的随机数。(包括0.0但不包括0.1),即随机数的取值范围是[0.0,1.0]的左闭右开区间。 例如,下列代码得到1~100之间…...

Golang数据结构和算法
Golang数据结构和算法 数据的逻辑结构和物理结构常见数据结构及其特点算法的时间复杂度和空间复杂度Golang冒泡排序Golang选择排序Golang插入排序Golang快速排序Golang归并排序Golang二分查找Golang sort包Golang链表Golang container/list标准库Golang栈stackGolang二叉搜索树…...

python 装饰器
装饰器是 Python 中一种功能强大的语法特性,它可以用于在不修改原函数代码的情况下,动态地扩展或修改函数的行为。装饰器本质上是一个函数或类,它接受一个函数作为参数,并返回一个新的函数或类。 下面是装饰器的详细解释和示例&a…...

iOS如何获取设备型号的最新方法总结
每一种 iOS 设备型号都有对应的一个或多个硬件编码/标识符,称为 device model 或者叫 machine name 通常的做法是,先获取设备的 device model 值,再手动映射为具体的设备型号(或者直接把 device model 值传给后端,让后…...

SpringBoot之RestTemplate使用Apache的HttpClient连接池
SpringBoot自带的RestTemplate是没有使用连接池的,只是SimpleClientHttpRequestFactory实现了ClientHttpRequestFactory、AsyncClientHttpRequestFactory 2个工厂接口,因此每次调用接口都会创建连接和销毁连接,如果是高并发场景下会大大降低性…...

第49节:cesium 倾斜模型osgb转3dtiles,并加载(含源码+视频)
结果示例: 完整步骤: 1、启动并登陆cesiumlab 2、准备OSGB模型数据(含下载地址) 链接:https://pan.quark.cn/s/46ac7b0b2bed 提取码:TvWL3、倾斜模型切片 选择倾斜模型data文件夹 空间参考、零点坐标 默认 强制双面关闭、无光照 打开...

零信任安全模型详解:探讨零信任安全策略的原理、实施方法和最佳实践,确保在网络中实现最小特权原则
在当今日益复杂和危险的网络环境中,传统的网络安全模型已经不再能够满足对抗不断进化的威胁。零信任安全模型应运而生,以其强调“不信任,始终验证”的理念,成为了当今信息技术领域中的热门话题。本文将深入探讨零信任安全模型&…...

01_nodejs简介
01 【nodejs简介】 1.前言 Node 的重要性已经不言而喻,很多互联网公司都已经有大量的高性能系统运行在 Node 之上。Node 凭借其单线程、异步等举措实现了极高的性能基准。此外,目前最为流行的 Web 开发模式是前后端分离的形式,即前端开发者…...

企业架构LNMP学习笔记4
企业服务器LNMP环境搭建: 常见的软件架构: 1)C/S: client/server 2)B/S: browser/server 不管是C还是B,都是属于客户端属于前端。那么运维人员主要是负责和管理的Server端,也统称为服务器端。为了快速的…...

探索UniApp分包
目录 什么是UniApp分包? UniApp分包的原理 优势 如何使用UniApp分包 1.manifest.json文件配置 2.静态图片资源分包注意事项 3.pages.json配置 结论 探索UniApp分包:优化移动应用性能与用户体验 在移动应用开发领域,性能和用户体验是至…...

uniapp 支持图片放大
<view class"list" v-for"(item, index) in urls" :key"index"><image :src"item" click"viewImg(item, index)" disabled></image></view> js // 预览大图 viewImg(data, index) {uni.previewImag…...

Oracle数据泵备份恢复(导出导入)详细语句
数据泵备份 查询已存在备份目录 select * from dba_directories;新建备份目录 create directory dbbak as /u01/dbbak;注意:在本地新建对应的物理目录 给指定用户赋权 grant read, write on directory dbbak to testuser; 或者直接把目录的权限设置为公开 g…...

【JS案例】JS实现积分抽奖(内附源码)
JS案例实现积分抽奖 🌟效果展示 🌟HTML结构 🌟CSS样式 🌟实现思路 🌟具体实现 1.定义抽奖次数渲染 2.点击抽奖按钮,实现滚动抽奖效果 3.弹窗处理 🌟完整代码 🌟写在最后 dz…...

angular抛出 ExpressionChangedAfterItHasBeenCheckedError错误分析
当变更检测完成后又更改了表达式值时,Angular 就会抛出 ExpressionChangedAfterItHasBeenCheckedError 错误。Angular 只会在开发模式下抛出此错误。 在开发模式下,Angular 在每次变更检测运行后都会执行一次附加检查,以确保绑定没有更改。这…...

动态链接库的__declspec(dllexport)关键字的概念
在 Windows 操作系统下,创建一个动态链接库(DLL)项目时,您需要通过 __declspec(dllexport) 关键字来显式地标记希望在 DLL 中 公开 的函数、类、变量等符号。这是因为在默认情况下,编译器会将函数和符号视为 私有&…...

群晖NAS:DS Video、Jellyfin等视频电影电视剧海报、背景墙搜刮器
群晖NAS:DS Video、Jellyfin等视频电影电视剧海报、背景墙搜刮器 本文只使用豆瓣插件方式,系统默认的 The Movie Database 好注册,但是授权码输入后域名不通过,很麻烦。 1、插件地址: https://www.aliyundrive.com/s…...

WEBGL(3):鼠标动态绘制点
1 实现思路 绘制单个点鼠标事件监听点击事件将点推送到数组中绘制数组中所有点 2 实现代码 <!DOCTYPE html> <html lang"en"><head><meta charset"UTF-8"><meta http-equiv"X-UA-Compatible" content"IEedge&…...

Sass基础
Sass基础 简介 Sass是一种stylesheet语言,可以被编译成CSS。Sass允许你使用诸如variabels,nested rules,mixins,functions等等语法,这些都将在本篇的接下来进行讲解。 因为之前一直学的后端,前端只是因为…...

Java中的消息队列有哪些?
在Java中,有几种常见的消息队列实现,包括: Apache Kafka:一个分布式流处理平台,具有高吞吐量、可持久化、可扩展等特点。 RabbitMQ:一个开源的消息代理,实现了AMQP(高级消息队列协议…...

多维时序 | Matlab实现GRU-Adaboost和GRU多变量时间序列预测对比
多维时序 | Matlab实现GRU-Adaboost和GRU多变量时间序列预测对比 目录 多维时序 | Matlab实现GRU-Adaboost和GRU多变量时间序列预测对比预测效果基本介绍模型描述程序设计参考资料 预测效果 基本介绍 多维时序 | Matlab实现GRU-Adaboost和GRU多变量时间序列预测对比 模型描述 M…...

测试用例编写规范参考
章节目录: 一、规范目的二、模块划分三、颗粒度规范四、编写规范五、具体分项5.1 用例标题5.2 前置条件5.3 操作步骤5.4 预期结果 六、用例维护七、结束语 一、规范目的 规范合理,可执行性。一定要保证高可读性。 二、模块划分 同级别、同等级功能点。…...

unity3d:功能验证,收集开源项目的工程合集
unity3d功能验证,和收集开源项目的工程合集 目录持续更新地址 【腾讯文档】UnityForTest目录 https://docs.qq.com/doc/DWm9HSkVhTGdyUUVo 源码 https://github.com/luoyikun/UnityForTest 动画 创建骨骼动画 BoneAnimation场景 代码创建Mesh,骨骼…...

plotly_beforehover 用法:
在Plotly.js中,plotly_beforehover是在鼠标悬停在数据点上之前触发的回调事件。它的主要作用是在鼠标悬停事件发生前做一些准备工作。 plotly_beforehover事件是与图表对象绑定的,可以通过调用on方法来绑定事件处理程序。下面是一个示例代码:…...

利用 AI 赋能云安全,亚马逊云科技的安全技术创新服务不断赋能开发者
文章分享自亚马逊云科技 Community Builder:李少奕 2023年6月14日,一年一度的亚马逊云科技 re:Inforce 全球大会在美国安纳海姆落下了帷幕。re:Inforce 是亚马逊云科技全球最大的盛会之一,汇集了来自全球各地的安全专家,共同学习、…...

18. 填坑Ⅰ
Description 又是北湖深坑,惊不惊喜,意不意外?! 觉得用水填湖太没意思了,用石头填坑多有意思。 假设北湖的地面还是一维的,每一块宽度都为1,高度是非负整数,用一个数组来表示。 现提…...

CSS 实现平面圆点绕椭圆动画
前言 👏CSS实现平面圆点绕椭圆动画,速速来Get吧~ 🥇文末分享源代码。记得点赞关注收藏! 1.实现效果 2.实现原理 transform-style:CSS 属性 transform-style 设置元素的子元素是位于 3D 空间中还是平面中。如果选择平面…...

docker login : x509: certificate signed by unknown authority
一. 背景 docker login 登录harbor镜像仓库报错. [rootmaster01 sloth]# docker login docker.harbor.master01.com Username: bigdata Password: Error response from daemon: Get https://docker.harbor.master01.com/v2/: x509: certificate signed by unknown authority …...

金蝶云星空二开,插件查看工具
可查询单据上挂载的系统原有插件、二开插件及插件类型 1.支持模糊查询单据列表 2.支持项目与账套二开插件对比 3.支持金蝶不同账套之间对比差异 操作步骤: 1.登陆界面,选择金蝶云管理中心账套登录获取账套列表; 2.单一标识查询:…...

error: ‘std::_hypot‘ has not been declared using std::hypot;
Cmake 使用qt的编译器 编译opencv时 执行mingw32-make时出现了错误 本质原因就是 _hypot 没有声明。所以找到对应的文件声明一下 就行了。 E:\*****\Qt5.14.1\Tools\mingw730_64\lib\gcc\x86_64-w64-mingw32\7.3.0\include\c 下面的math.h 文件。 可以看到这个文件有一个…...