我正在尝试使用此脚本创建一天的日志文件:
hostIp = WScript.Arguments(0)
logfilename = WScript.Arguments(1)
Set fso = CreateObject("Scripting.FileSystemObject")
Set Shell = CreateObject("WScript.Shell")
'OpenTextFile Method requires a Const value
'(Over)Write = 2 Append = 8
d = Day(Now)
m = Month(Now)
y = Year(Now)
myDateFormat= d & "-" & m & "-" & y
Set logfile = fso.OpenTextFile(logfilename & " " & myDateFormat & ".log", 8, True)
shellstring = "%comspec% /c ping -t -f -l 32 -w 1000 " & hostIP
Set oExec = Shell.Exec(shellstring)
WScript.Echo "Ping Error log With Timestamp - Ctrl + C to halt"
Do While oExec.StdOut.AtEndOfStream <> True
pingline = Date & " " & Time & " " & oExec.StdOut.ReadLine
'If InStr(pingline, "TTL=") = 0 Then
logfile.WriteLine(pingline)
'End If
Loop
我认为它很好,但是我已经运行了3天而且只有一个文件而不是3个。关于脚本错误的任何想法? 顺便说一下,我用CMD在CMD上运行这个脚本:
FileName ip logname.log
答案 0 :(得分:3)
嗯,好吧,是的,你的日志文件不会因为你的意思而神奇地改变。您需要实际告诉您的代码执行此操作。
由于你基本上是在运行一个无限循环(由于// ==UserScript==
// @name so_test2
// @include https://www.google.dk/*
// @include https://www.daily.co.jp/*
// @include http://www.ahram.org.eg/*
// @include https://www.almesryoon.com/*
// @require http://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js
// @require http://ajax.googleapis.com/ajax/libs/jqueryui/1.11.1/jquery-ui.min.js
// @version 1
// @grant none
// ==/UserScript==
// dialog DIV
$("body").append ('<div id="mydialog" style="display: none">'
+'<p>This is a jQuery Dialog.</p></div>');
$("head").append(
'<link '
+ 'href="//ajax.googleapis.com/ajax/libs/jqueryui/1.11.1/themes/le-frog/jquery-ui.min.css" '
+ 'rel="stylesheet" type="text/css">'
);
// custom CSS for dialog
$("head").append(
'<style type="text/css">'
+'#mydialog { '
+'margin: 0; padding: 0; border: 0;'
+'height:100%; max-height:100%;'
+'color:#f00 !important;'
+'font: normal 3em "Open Sans", sans-serif;'
+'font-size: 32px;'
+'vertical-align: baseline;'
+'line-height: 1; }'
+'#mydialog table { '
+'border-collapse: collapse;'
+'border-spacing: 0; }'
+'.ui-dialog-titlebar { font: italic 2em "Open Sans", sans-serif; }'
+'</style>'
);
// options for dialog, for help look in jQuery docs
var opt = {
width: 500,
minWidth: 400,
minHeight: 200,
modal: false,
autoOpen: false,
title: "Draggable, sizeable dialog",
zIndex: 1
};
$("#mydialog").dialog(opt).dialog("open");
// alternative way to position a dialog
$("#mydialog").parent().css({
position: "fixed",
top: "4.2em",
left: "4em",
width: "75ex"
});
),你需要检查里面的日期循环并在日期改变时打开一个新文件:
ping -t