Jaide
(Fresh Scripter)
2003-11-19 08:32 PM
Overwriting Files and Deleting Files

I have a script that pings all the servers on my network and writes that output to a file upon login for Admins:

If RedirectOutput("ping.log") = 0

Then emails that file to the group. I want to overwrite that file on every login and/or delete that file after login.

Any ideas?


MCA
(KiX Supporter)
2003-11-19 08:41 PM
Re: Overwriting Files and Deleting Files

Dear,

Use following code
Code:

$nul=RedirectOutput("ping.log",1)
;
; your code
;
; script completed and delete now the 'ping.log' file
$nul=RedirectOutput("")
DELETE ping.log


We suggest to use something like %tmp%\ as prefix for the filename 'ping.log'.
greetings.


Les
(KiX Master)
2003-11-19 08:43 PM
Re: Overwriting Files and Deleting Files

You're going to have to post more than one line of code for us to understand what you are doing. My crystal ball is in the shop.

Jaide
(Fresh Scripter)
2003-11-19 09:28 PM
Re: Overwriting Files and Deleting Files

Here it is:
Code:
  

$nul=RedirectOutput("ping.log",1)
For $i = 101 TO 108
If ping("192.168.1."+$i)
? "192.168.1."+$i+" is online"
Else
? "192.168.1."+$i+" is offline. Please check network connection."
EndIf
$nul=RedirectOutput("")



Then I want to mail the file using blat (works sometimes) and then delete the file after being mailed. Hope that helps!


Les
(KiX Master)
2003-11-19 09:48 PM
Re: Overwriting Files and Deleting Files

Guess MCA's crystal ball is working just fine. Maybe in the future I will try to have a seance with him before posting.