October 26, 2005 at 8:48 pm
Hey,
I'm not quite sure what subject my question would fall under, but wanted help..
Here is what I'm trying to achieve..
I was some kinda .vbs script that can keep monitoring a file in a folder and trigger a event ONLY when the file is changed.. Hope someone has had a similar situation and figure a solution or article that could help..
hope to see some reply.. This is on a windows 2000 server box.
Thank you
October 28, 2005 at 1:07 am
Here is a C#, VB, C++ .NET example:
Andy
October 28, 2005 at 10:27 am
Hi,
this is a script that sends an email if files in a certain directory get older than 10 minutes. You might adapt it for your purposes by storing the filedate in a table and comparing to that...
regards karl
CREATE PROCEDURE usp_le_austausch_testen
@transfer_pfad varchar(500)
AS
SET NOCOUNT ON
SET DATEFORMAT ymd
DECLARE
@cmd varchar(4000)
, @transfer_dir varchar(500)
, @m int
,@status int
-- create temp table for results of xp_getfiledetails
CREATE TABLE #fileinfo
(
altname varchar(255),
groesse int,
erstelldatum varchar(8),
erstellzeit int,
zuletztgeschriebendatum varchar(8),
zuletztgeschriebenzeit int,
zuletztZugriffDatum varchar(8),
zuletztZugriffZeit int,
Attribute int
)
CREATE TABLE #DirOut
(
id INT IDENTITY(1,1),
[Output] varchar(255)
)
SET @status = 1
SET @transfer_dir = @transfer_pfad + '\Export\'
SET @cmd = 'dir "' + @transfer_dir + '*.xml" /B /OD'
print @cmd
INSERT #DirOut EXEC master..xp_cmdshell @cmd
DELETE FROM #DirOut WHERE Output IS NULL
--select * from #DirOut
IF (SELECT OutPut FROM #DirOut WHERE id = 1 ) 'File Not Found' BEGIN
SELECT @m = MIN(id) FROM #DirOut
select @cmd = 'master.dbo.xp_getfiledetails ''' + @transfer_dir + Output + '''' FROM #DirOut WHERE id = @m
insert into #fileinfo exec (@cmd)
select * FROM #DirOut WHERE id = @m
select * from #fileinfo
select @cmd = ltrim(str(zuletztgeschriebenzeit)) from #fileinfo
if len(@cmd) 10 AND @status = 1
SET @status = -1
select @cmd = ltrim(str(zuletztgeschriebendatum)) from #fileinfo
if datediff(hh, convert(datetime, left(@cmd,4)+'/'+SUBSTRING(@cmd,5,2)+'/'+right(@cmd,2)), getdate()) > 24 AND @status = 1
SET @status = -1
IF @status = -1
BEGIN
Print 'Difference for Export > 10'
exec master.dbo.xp_smtp_sendmail
@FROM= N'SQLAgent.server@domain.de',
@FROM_NAME= N'Automagically OPUS',
@TO = N'reciepients',
@replyto = N'sender email address',
@cc= N'',
@BCC= N'',
@priority= N'HIGH',
@subject= N'Problem',
@message= N'Exchange of files stopped for more than 10 minutes!!!',
@messagefile= N'',
@type= N'text/plain',
@attachment= N'',
@attachments= N'',
@codepage= 0,
@server = N'mailserver.domain.de'
END
else
Print 'Differenz fuer Export kleiner 10'
DELETE FROM #DirOut
DELETE FROM #fileinfo
END ELSE
Print 'No files in export directory.'
DROP TABLE #fileinfo
DROP TABLE #DirOut
SET NOCOUNT OFF
GO
Best regards
karl
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply