免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
楼主: jhgzzq
打印 上一主题 下一主题

如何在ping 命令结果前面加上时间日期!!! [复制链接]

论坛徽章:
0
11 [报告]
发表于 2005-09-19 07:37 |只看该作者

如何在ping 命令结果前面加上时间日期!!!

slash001 GG的脚本的确8错!   

论坛徽章:
0
12 [报告]
发表于 2005-09-19 09:52 |只看该作者

如何在ping 命令结果前面加上时间日期!!!

还是vbs功能强大,呵呵,谁用perl来一个?

论坛徽章:
0
13 [报告]
发表于 2005-09-19 11:25 |只看该作者

如何在ping 命令结果前面加上时间日期!!!

perl的代码\r\n
  1. \r\n#!/usr/bin/perl\r\nopen(PING, \"ping 192.168.0.249|\");\r\nwhile (<PING>)\r\n{\r\n        if ($_ =~ /^Reply|^Request/)\r\n        {\r\n                my @date=localtime(time);\r\n                printf(\"%d-%02d-%02d %02d:%02d:%02d %s\", $date[5]+1900, $date[4]+1, $date[3], $date[2], $date[1], $date[0], $_);\r\n        }\r\n}\r\nclose(PING);\r\n
复制代码
\n\n[ 本帖最后由 slash001 于 2005-11-15 11:41 编辑 ]

论坛徽章:
0
14 [报告]
发表于 2005-09-19 17:50 |只看该作者

如何在ping 命令结果前面加上时间日期!!!

C:\\>;cscript tping.vbs\r\nMicrosoft (R) Windows 脚本宿主版本 5.1 for Windows\r\n版权所有(C) Microsoft Corporation 1996-1999. All rights reserved.\r\n\r\nC:\\tping.vbs(4, 1) Microsoft VBScript 运行时错误: 对象不支持此属性或方法: \'shell\r\n.Exec\'

论坛徽章:
0
15 [报告]
发表于 2005-09-19 18:20 |只看该作者

如何在ping 命令结果前面加上时间日期!!!

我是在Win2000下测试的\r\nMicrosoft (R) Windows Script Host Version 5.6

论坛徽章:
0
16 [报告]
发表于 2005-09-20 08:41 |只看该作者

如何在ping 命令结果前面加上时间日期!!!

[quote]原帖由 \"slash001\"][/quote 发表:\n\r\n\r\n难不住你了,老弟再用C写一个?哈哈

论坛徽章:
0
17 [报告]
发表于 2005-09-20 08:44 |只看该作者

如何在ping 命令结果前面加上时间日期!!!

XP下也没问题\r\nC:\\>;cscript pt.vbs\r\nMicrosoft (R) Windows Script Host Version 5.6\r\nCopyright (C) Microsoft Corporation 1996-2001. All rights reserved.\r\n\r\n2005-9-20 8:43:21       Reply from 10.20.33.3: bytes=32 time=1ms TTL=64\r\n2005-9-20 8:43:22       Reply from 10.20.33.3: bytes=32 time<1ms TTL=64\r\n2005-9-20 8:43:23       Reply from 10.20.33.3: bytes=32 time<1ms TTL=64\r\n2005-9-20 8:43:24       Reply from 10.20.33.3: bytes=32 time<1ms TTL=64\r\n\r\nPerl下也不错\r\nC:\\>;perl pt2.pl\r\n2005-09-20 09:08:32 Reply from 10.20.33.3: bytes=32 time=1ms TTL=64\r\n2005-09-20 09:08:33 Reply from 10.20.33.3: bytes=32 time<1ms TTL=64\r\n2005-09-20 09:08:34 Reply from 10.20.33.3: bytes=32 time=1ms TTL=64\r\n2005-09-20 09:08:35 Reply from 10.20.33.3: bytes=32 time<1ms TTL=64

论坛徽章:
0
18 [报告]
发表于 2005-09-20 09:32 |只看该作者

如何在ping 命令结果前面加上时间日期!!!

[quote=\"b.s.d\"]C:\\>;cscript tping.vbs\r\nMicrosoft (R) Windows 脚本宿主版本 5.1 for Windows\r\n版权所有(C) Microsoft Corporation 1996-1999. All rights reserved.\r\n\r\nC:\\tping.vbs(4, 1) Microsoft VBScript 运行时错误: 对?.........[/quote]\r\n我的是2003

论坛徽章:
0
19 [报告]
发表于 2005-09-20 10:11 |只看该作者

如何在ping 命令结果前面加上时间日期!!!

C不怎么用,随便写了一个,呵呵\r\nWin2000 Cygwin下编译测试通过\r\n
  1. \r\n#include <stdio.h>;\r\n#include <string.h>;\r\n#include <time.h>;\r\n\r\nint main(int argc, char *argv[])\r\n{\r\n        time_t clock;\r\n        struct tm *tm;        \r\n        char tbuf[20];\r\n\r\n        FILE *res;\r\n        char buf[256];\r\n        res=popen(\"ping 192.168.0.249\", \"r\");\r\n\r\n        while (fgets(buf, sizeof(buf), res))\r\n        {\r\n                if (bcmp(buf, \"Reply\", 5) == 0 || bcmp(buf, \"Request\", 7) == 0)\r\n                {\r\n                        time(&clock);\r\n                        tm=localtime(&clock );\r\n                        strftime(tbuf, 20, \"%Y-%m-%d %H:%M:%S\", tm);\r\n                        printf(\"%s\\t%s\", tbuf, buf);\r\n                }\r\n        }\r\n        pclose(res);\r\n        return 0;\r\n}\r\n
复制代码

论坛徽章:
0
20 [报告]
发表于 2005-09-20 10:40 |只看该作者

如何在ping 命令结果前面加上时间日期!!!

原帖由 \"b.s.d\" 发表:\n\r\n我的是2003
\r\n将Windows脚本宿主升级到5.6试试
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP