<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; VBS: Поиск данных в обновляемом файле]]></title>
	<link rel="self" href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=11975&amp;type=atom" />
	<updated>2016-09-12T23:59:45Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=11975</id>
		<entry>
			<title type="html"><![CDATA[Re: VBS: Поиск данных в обновляемом файле]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=107609#p107609" />
			<content type="html"><![CDATA[<p>Я понимаю, что однократно, но приходится каждую строку читать с начала вместо нормального чтения с конца.</p>]]></content>
			<author>
				<name><![CDATA[Flasher]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27593</uri>
			</author>
			<updated>2016-09-12T23:59:45Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=107609#p107609</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBS: Поиск данных в обновляемом файле]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=107606#p107606" />
			<content type="html"><![CDATA[<p><strong>Flasher</strong>, не понял. <em>OpenTextFile</em> вызывается однократно.</p>]]></content>
			<author>
				<name><![CDATA[wisgest]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=3850</uri>
			</author>
			<updated>2016-09-12T23:55:59Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=107606#p107606</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBS: Поиск данных в обновляемом файле]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=107605#p107605" />
			<content type="html"><![CDATA[<p>За 40 минут там приличный лог набьётся, я бы OpenTextFile не мучал.</p>]]></content>
			<author>
				<name><![CDATA[Flasher]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27593</uri>
			</author>
			<updated>2016-09-12T23:48:25Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=107605#p107605</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBS: Поиск данных в обновляемом файле]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=107603#p107603" />
			<content type="html"><![CDATA[<p>1) JScript.<br />2) Ловится строка, начинающаяся со «STARTED_SUCCESSFULLY» с возможным продолжением.<br />3) Строки должны разделятся символами LF или CR+LF.<br />4) Если файл в кодировке UTF-8 начинается с BOM и искомая строка — самая первая, то она не будет отловлена и скрипт не завершится.<br /></p><div class="codebox"><pre><code>var LogFileSpec = &quot;D:\\test\\startup.log&quot;;
var FS = new ActiveXObject(&quot;Scripting.FileSystemObject&quot;);
while (!FS.FileExists(LogFileSpec)) WScript.Sleep(1);
var LogFile = FS.OpenTextFile(LogFileSpec, 1 /*ForReading*/);
var line = &quot;&quot;;
do {
	while (LogFile.AtEndOfStream) WScript.Sleep(1);
	var char = LogFile.Read(1);
	if (char == &#039;\n&#039;) {line = &quot;&quot;; continue;} else line += char;
} while (line != &quot;STARTED_SUCCESSFULLY&quot;);
LogFile.Close();
WScript.Echo(&quot;Сервер запущен&quot;);
</code></pre></div><p>P.S. Если файл создаётся программно путём последовательной дозаписи, то, скорее всего, он не содержит BOM.</p>]]></content>
			<author>
				<name><![CDATA[wisgest]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=3850</uri>
			</author>
			<updated>2016-09-12T23:32:31Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=107603#p107603</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBS: Поиск данных в обновляемом файле]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=107549#p107549" />
			<content type="html"><![CDATA[<p>2. С ВОМ / без?<br />3. Пока не надо. Открываем файл, жмём Ctrl+End. Курсор встаёт на конец последней строки или на пустую строку?</p>]]></content>
			<author>
				<name><![CDATA[Flasher]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27593</uri>
			</author>
			<updated>2016-09-12T15:45:14Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=107549#p107549</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBS: Поиск данных в обновляемом файле]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=107546#p107546" />
			<content type="html"><![CDATA[<p>1. Он создается при запуске отдельно, замещая предыдущий. Просто файл startup.log, который дополняется информацией до тех пор, пока сервис полностью не запустится.<br />2. в кодировке UTF-8<br />3. Не совсем понимаю о чем речь... Если нужно - я могу кинуть ссылку на сам файл.</p>]]></content>
			<author>
				<name><![CDATA[space-manometr]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=34171</uri>
			</author>
			<updated>2016-09-12T14:40:49Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=107546#p107546</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBS: Поиск данных в обновляемом файле]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=107430#p107430" />
			<content type="html"><![CDATA[<p>А <em>IsServiceRunning</em>? И то, что служба в статусе &quot;Выполняется&quot;, не значит, что во всех случаях <em>CanStartStopService</em> показывает одно и то же.</p><p>По поводу лога.<br />1. Он каждый раз обновляется при старте или дописывается?<br />2. В какой он кодировке?<br />3. В конце текста может быть возрат каретки и/или перевод строки, или там всегда строчный символ?</p>]]></content>
			<author>
				<name><![CDATA[Flasher]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27593</uri>
			</author>
			<updated>2016-09-09T15:56:01Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=107430#p107430</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBS: Поиск данных в обновляемом файле]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=107422#p107422" />
			<content type="html"><![CDATA[<p>CanStartStopService ведет себя одинаково, т.к. служба уже в статусе &quot;Выполняется&quot; и дальнейшие процессы не отслеживаются скриптом.</p>]]></content>
			<author>
				<name><![CDATA[space-manometr]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=34171</uri>
			</author>
			<updated>2016-09-09T07:57:47Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=107422#p107422</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBS: Поиск данных в обновляемом файле]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=107322#p107322" />
			<content type="html"><![CDATA[<p><strong>space-manometr</strong><br />Служба может запускаться когда угодно, и знать о времени запуска совершенно не требуется, методы проверяют состояние.<br />Т.е. если служба была ранее запущена и IsServiceRunning возвращает <em>False</em>, то в цикле ждём, когда вернёт <em>True</em>.<br />Если сразу возвращает <em>True</em>, то вариант, конечно, не годится.<br />CanStartStopService стоит проверить на то, как он себя ведёт до/после полноценного старта.</p>]]></content>
			<author>
				<name><![CDATA[Flasher]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27593</uri>
			</author>
			<updated>2016-09-05T14:11:34Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=107322#p107322</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBS: Поиск данных в обновляемом файле]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=107307#p107307" />
			<content type="html"><![CDATA[<p><strong>Flasher</strong></p><p>Нет, так как сама служба запускается при старте системы, а сам сервис (в частности речь о Tomcat) дает знать о запуске только в логах, при появлении записи Started_successful.</p>]]></content>
			<author>
				<name><![CDATA[space-manometr]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=34171</uri>
			</author>
			<updated>2016-09-04T14:57:53Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=107307#p107307</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBS: Поиск данных в обновляемом файле]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=107288#p107288" />
			<content type="html"><![CDATA[<p><strong>space-manometr</strong><br />Т.е. до истечения 40 мин <a href="http://script-coding.com/WSH/Shell.html#3.20.">эти проверки</a> не справляются?</p>]]></content>
			<author>
				<name><![CDATA[Flasher]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27593</uri>
			</author>
			<updated>2016-09-03T11:59:37Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=107288#p107288</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[VBS: Поиск данных в обновляемом файле]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=107269#p107269" />
			<content type="html"><![CDATA[<p>Доброго времени суток.<br />После перезагрузки сервера запускается некий сервис в течении 40 минут. Нужно получить сообщение, когда он полностью стартовал. Во время всей процедуры запуска создается некий лог, в котором пишутся все этапы запуска, и окончание запуска оканчивается записью STARTED_SUCCESSFULLY. Пробовал использовать код по аналогии в<br /><a href="http://forum.script-coding.com/viewtopic.php?id=6661">http://forum.script-coding.com/viewtopic.php?id=6661</a></p><div class="codebox"><pre><code>
option explicit
Dim objFSO, txtFile, x, done
Set objFSO = Createobject(&quot;Scripting.FileSystemObject&quot;)
Set txtFile = objFSO.OpenTextFile(&quot;D:\test\startup.log&quot;,1)

Do
Do While Not txtFile.AtEndOfStream
  x=txtFile.Readline
  If InStr(x, &quot;STARTED_SUCCESSFULLY&quot;) Then
      MsgBox &quot;Сервер запущен&quot;
	  done = true
      Exit Do
  End If  
 Loop
Loop</code></pre></div><p>Не знаю, что надо указать, чтобы скрипт постоянно мониторил изменения в файле до тех пор, пока не найдет соответствующую фразу, после чего выдал сообщение и закрылся. Спасибо за возможную помощь.</p>]]></content>
			<author>
				<name><![CDATA[space-manometr]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=34171</uri>
			</author>
			<updated>2016-09-02T18:30:58Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=107269#p107269</id>
		</entry>
</feed>
