- 博客(33)
- 收藏
- 关注
原创 openwrt 网口-wifi-4G网络切换
#!/bin/shchange_mode=$1#网口wan_state=0#4G卡sim_state=0#wifi口wifi_state=0state=0Number=0#当前序号Cur_state=4test_kill=0get_route_first_file(){ IP=`route |grep -i UG|awk '{print $2}' |sed -n 1p` Iface=`route |grep -i UG|awk '{print $8}' |sed -n
2021-12-31 15:17:23 68
原创 openwrt脚本实现客户端无缝链接wifi
openwrt可以根据配置进行查找相关可用wifi,进行切换,重新进行连接,可实现无缝连接,可配置循环周期、阀值、差值:实例 wifi.sh 10 -75 10#!/bin/sh#apclii0是我设置的STA模式下的网络设备,该脚本就是根据设置时间扫描一次,判断STA模式下关联路由器是否有断网,#1、IP_VAL是当时STA模式下关联的路由器名称,IP_ADD把多余的符号去掉,判断当前STA是否有关联到热点#2、如果STA没有关联热点,判断当前配置的热点名称是什么,STA_NAME就是热点名
2021-08-08 21:59:54 81
原创 检查后台系统是否存在运行的脚本
检查是否存在运行的脚本#!/bin/sh#检查是否存在wifi_switch.shresult=`ps |grep -i "wifi_switch.sh" |grep -v "grep"|wc -l`if [ ${result} -eq 0 ];then #echo "start process..... " wifi_switch.shelse echo "runing....."fi...
2021-08-08 21:48:33 287
原创 openwrt 使用sort 默认缺少 -k,添加方式
openwrt工程上默认编译成功后,系统中sort命令是简单的不支持-k等参数默认只有这几个选择添加方式:编译前选上支持-k等参数,在make menuconfig后,依次选中"Base system"->“busybox”->“Coreutils”->“sort Full SuSv3 compliant sort (support -ktcsbdfiozgM)”,编译成功的系统支持sort -k参数。...
2021-08-03 19:47:33 158
原创 crontab定时任务问题
crontab定时任务第一个周期未完成下一个周期执行就来了有一个定时任务,每秒执行一次,前一秒还没有执行完成,下一个秒就来了,怎么解决。 vim test.sh#!/bin/shecho "开始 `date` " >> /tmp/test.txtsleep 10echo "结束 `date` " >> /tmp/test.txt crontab -e* * * * * sleep 1;test.sh输出结果:有多个执行脚本在运行解决办法:使用文件锁f
2021-07-27 16:59:47 206
原创 wifi自动切换信道,并进行重启对应的接口
在这里插入代码片#!/bin/sh#apclii0是我设置的STA模式下的网络设备,该脚本就是3秒扫描一次,判断STA模式下关联路由器是否有断网,#1、CH_VAL是当时STA模式下关联的路由器名称,CH_ADD把多余的符号去掉,判断当前STA是否有关联到热点#2、如果STA没有关联热点,判断当前配置的热点名称是什么,STA_NAME就是热点名称#3、iwlist就是扫描当前的热点,是否有跟当前配置关联的热点名称一样的,如果一样就切换自己信道进行关联#4、以前不是切换信道还是重启网络,发现问题多多
2021-07-26 21:11:14 1027
原创 Modbus TCP Server
#include <stdio.h>#include <unistd.h>#include <stdlib.h>#include <errno.h>#include "modbus.h"int main(){ int server_socket = -1; modbus_t *ctx; modbus_mapping_t *mb_mapping; //创建一个TCP ctx = modbus_new_tcp(NULL,1502); //
2021-06-09 21:08:16 556 2
原创 Modubus TCP Client
Modubus TCP Client#include <stdio.h>#include <unistd.h>#include <string.h>#include <stdlib.h>#include <errno.h>#include <modbus.h>#define LOOP 1#define SERVER_ID 17#defind ADDRESS_START 0#definf ADDR
2021-06-07 21:55:28 453 3
原创 shell脚本读取文件,判断是否需要写入crontab中
shell脚本读取文件,判断写入crontab中` #!/bin/shread_file(){if cat /etc/crontabs/root | grep network_check_switch.sh > /dev/nullthen#echo “存在”return 0else#echo “不存在”return 1fi}while truedoread_fileif [ $? -ne 0 ]; thenecho “*/5 * * * * ping IP” &g
2021-05-30 21:07:29 251
原创 判断输入字段是否为IP地址
判断输入字段是否为IP地址,仅供参考:#include<stdio.h> #include<string.h>#include<stdlib.h>//检查字符是否是在16进制字母中static int String_Hex(char *p){ int ret = 0; if (p == NULL) {
2021-03-20 12:08:22 270
原创 双向链表的插入与删除
#include <strdio.h>#include <string.h>typedef struct list{ int num; struct List *next; struct List *pre;}List;List *Insert_sort(List *head,int num){ List *tmp1 = head; List *tmp0 = (List *)malloc(sizeof(List)); if(tmp0 == NULL)
2021-03-15 14:44:29 76
原创 int数字翻转与string转成int分享
int数字翻转与string转成int分享class Solution {public: int reverse(int x) { int res = 0; while (x != 0) { if (abs(res) > INT_MAX / 10) return 0; res = res * 10 + x % 10; x /= 10; } return r
2021-01-07 10:59:15 113
原创 已输入日期为基准,计算相隔的天数
计算相隔number天数的日期在这里插入代码片 #include <stdio.h> #include <string.h> #include <stdlib.h>#define ...
2019-09-23 16:21:59 190
原创 实现自己的日志打印函数
参考__attribute__使用方法#include <stdio.h> #include <stdlib.h>#include <string.h>#include <stda...
2019-09-10 15:58:06 428
原创 获取文件中内容的行数
在#include <sys/types.h>#include <sys/stat.h>#include <unistd.h> /* * stat函数是 获取文件的 inode的信息 * struct stat * { * dev_t st_dev; //文件设备编号 * ino_t st_ino; ...
2019-08-13 16:27:53 807
原创 判断unsigned long 与unsigned int使用的 是否一致长,以及实现网络字节序与主机字节序的转化
代码仅供参考#include <stdio.h> #include <unistd.h>#include <netinet/in.h>#include <arpa/inet.h...
2019-07-19 11:09:04 677
原创 获取系统的日期时间
//根据格式获取系统日期时间 void get_time(char* str/*格式:%y%m%d%h%n%s%u*/,char*buf) { int i,j; int len; struct tm tm; struct timeb tp; ftime(&tp); i=j=0; tm = *localtime(&am...
2019-07-19 10:54:59 107
原创 判断两个日期相隔多少天
以下代码仅供参考学习!#include <stdio.h> #include <stdlib.h>#include <fcntl.h>#include <string.h>...
2019-07-16 14:49:26 332
原创 关于数据库中写入回车或换行符
回车或换行符:换行符的ASCII码是10,回车符的ASCII码是13。可以采用CHR函数进行转换。例如:db2 update 表名称 set 列=‘123456||CHR(10)||34343’ where 其他条件可以将CHR()中的值换成任意的特殊符号。...
2019-07-12 09:32:29 8889
原创 数据的分割与截取
工作中的总结//计算分隔符分割域个数int splitcount(char*str/*分割的数据*/,char strp/*分割符*/){ int i,icount = 0; int len; if((len == strlen(str)) == 0) { return 0; } for(i = 0;i<len;i++)...
2019-05-31 16:16:02 468
原创 memcpy实现拷贝,源数据长度小于指定长度,不足处前补0
仅作为参考!int cpyadd0(char* pst/*in*/,char* dest/*out*/,int len/*len制定长度,限制范围1~180*/){ int ret; char tmp[200]; if(pst == NULL || dest == NULL || len<1 || len>180) { re...
2019-05-30 14:30:58 3501
原创 字符串的替换
字符串的替换buf原字符串;old要查找的字符串,new替换的字符串char* respace(char*buf, char*old, char*new){ int oldlen = 0; int newlen = 0; int totl = 0; int len = 0; char*pos = NULL; char*start = NULL; char*end = NULL;...
2019-04-26 15:53:01 129
翻译 关于验证身份证号码是否为真实有效
以下代码仅供参考void number() { char buf[] = "身份证号码"; int per[] = {7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2}; char ver[] = "10X98765432"; int i,count; printf("\n%d\n",s...
2019-04-19 21:10:17 3369
原创 用C语言实现去字符串两端的空格
用C语言实现去字符串两端的空格int delspace(char*str) { char* p1,*pp; char buf[1024]; pp = str; while(*pp == ' '||*pp == '\t') pp++; ...
2019-04-19 21:03:33 649
翻译 Linux开机过程
linux开机过程是打开电源开关到登录用户界面1、加载BIOS打开电源开关,计算机会加载BIOS信息,因为BIOS中包含CPU信息、设备启动顺序信息、硬盘信息、内存信息、时钟信息、PnP特性等。2、读取MBR硬盘第0磁道第一扇区称为MBR,也就是Master Boot Record,即主引导记录,大小是512字节,存放预启动信息、分区信息。可分两部分:1、引导(PRE-BOOT)区,占44...
2019-03-31 18:00:38 87
原创 单例模式(懒汉与饿汉模式)
单例饿汉模式class m_idler{private:m_idler(){}m_idler(const m_idler&amp;amp;amp;){}private:static m_idlern;public:static m_idlerget(){return n;}};m_idler* m_idler::n = new m_idler;单例懒汉模式class m_idler...
2019-02-26 21:14:22 83
原创 使用c语言实现字符串的拷贝、追加与计算长度
手动实现strcpy与strlenchar* mystrcpy(char* str,const char* buf){ if(NULL==str||NULL==buf) { return NULL; } char*p = str; while((*str++ = *buf++)! = '\0'); return p;}int mystrlen(const char*bu...
2018-09-23 17:13:53 1782 6
原创 使用C语言对有空格的字符串反转
例如将语句“change is importance”进行反转,反转后的语句“importance is change“ 用C语言代码编写:#include<stdio.h>#include<stdlib.h>#include<string.h>void change(char* st){ if(NULL==st) { re...
2018-09-06 22:41:05 1326
原创 TCP/IP四层模型
TCP/IP网络协议分为应用层、传输层、网络层、和网络接口层(链路层)。应用层:Telent、HTTP、ftp和e_mail等 传输层:tcp和udp; 网络层:IP、ICMP和IGMP 网络接口层:ARP协议、RARP协议...
2018-08-30 21:08:08 139
原创 OSI的七层模型
1、物理层:主要定义物理设备标准,如网线的接口、光纤的接口类型、各种传输介质的传输速率等。它的是主要作用是传输比特流(即数模转换和模数转换)。这一层数据叫做比特。 2、数据链路层:定义如何格式化数据以帧为单位进行传输,以及如何让控制对物理介质的访问。这一层通常还提供错误检测和纠正,以确保数据的可靠传输。 3、网络层:位于不同地理位置的网络中的两个主机系统之间提供连接和路径。 4、传输层:...
2018-08-30 20:59:18 181
翻译 IP段格式
IP数据报的首部长度和数据长度都是可变长的,但总是4字节的整数倍。对于IPV4,4位版本字段是4.4位首部长度的数值是以4字节为单位,最小值为5,也就是说收部最小是4*5=20字节,也就是不带任何选项的IP首部,4位能表示的最大值是15,也就是说首部长度最大是60字节。8位TOS字段有3个位用来指定IP数据报的优先级(目前已经废弃不用),还有4位可以表示可选的服务类型(最小延迟、最大吞吐量、最...
2018-08-30 20:43:22 1983
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人