#172649 - 2007-01-10 10:42 PM
@ERROR giving false positives?
|
itdaddy
Starting to like KiXtart
Registered: 2006-12-19
Posts: 145
Loc: Wisconsin
|
$ThisMyArray
For Each $Element In $ThisMyArray "PC1", "PC2", "PC3"
tcGetEvent($Element, $Task) ; load the bad task data
tcDefineTask("SUS=0") ; (disable = 1, enable = 0)
tcSetEvent($Element, $Task) ; update the task on the target
IF @ERROR <> 0
$RC = REDIRECTOUTPUT (failure.txt, 0)
? $Element
Else if @ERROR = 0
$RC = REDIRECTOUTPUT (success.txt, 0)
? $Element
Endif Endif
Next
Hey anyone or Glenn,
I got this to work thanks so much. But my error trap works on all my other scripts but for somereason @ERROR keeps giving me false positves (back and forth whether a 0 or 1). Why? and how can I correct this. I like and need to see which PCs failed and which succeeded. This is crucial. Thanks guys
Happy New you to you all!
_________________________
Robert A+, CCNA, MCP Network Admin Credit Union Wisconsin
|
Top
|
|
|
|
#172653 - 2007-01-10 11:19 PM
Re: @ERROR giving false positives?
[Re: itdaddy]
|
Benny69
Moderator
Registered: 2003-10-29
Posts: 1036
Loc: Lincoln, Ne
|
You have to define the array before you can use it:
$ThisMyArray = "PC1", "PC2", "PC3"
For Each $Element In $ThisMyArray
tcGetEvent($Element, $Task) ; load the bad task data
tcDefineTask("SUS=0") ; (disable = 1, enable = 0)
tcSetEvent($Element, $Task) ; update the task on the target
IF @ERROR <> 0
$RC = REDIRECTOUTPUT (failure.txt, 0)
? $Element
Else if @ERROR = 0
$RC = REDIRECTOUTPUT (success.txt, 0)
? $Element
Endif Endif
Next
|
Top
|
|
|
|
#172687 - 2007-01-11 02:17 PM
Re: @ERROR giving false positives?
[Re: Lonkero]
|
Benny69
Moderator
Registered: 2003-10-29
Posts: 1036
Loc: Lincoln, Ne
|
The @ERROR macro only contains the most recent error code, you are only checking for an error after the third function you are calling, you should be checking after each one. It would be easier for us to help you if you post the ENTIRE script and not expect us to try to guess what is happening.
|
Top
|
|
|
|
#172741 - 2007-01-12 09:53 PM
Re: @ERROR giving false positives?
[Re: Glenn Barnas]
|
itdaddy
Starting to like KiXtart
Registered: 2006-12-19
Posts: 145
Loc: Wisconsin
|
call "tcLib.kxf"
tcInit(1)
; just disable each PC on network
$Task = "FSPinstall"
$ThisMyArray = "PC1", "PC2, "PC3"
For Each $Element In $ThisMyArray
tcGetEvent($Element, $Task) ; load the bad task data
tcDefineTask("SUS=0") ; set it to Suspend (disable = 1, enable = 0)
tcSetEvent($Element, $Task) ; update the task on the target
IF @ERROR <> 0
$RC = REDIRECTOUTPUT (failure.txt, 0)
? $Element
Else if @ERROR = 0
$RC = REDIRECTOUTPUT (success.txt, 0)
? $Element
Endif Endif
Next
Sorry, here it is and it works slick like (Glenn thanks). But it gives false positives and false negatives. I have this same error handling scheme for shell commands in Kixtart and it handles them correctly; I have tested it ushering failures to failure.txt and successes to success.txt. Could you explain a bit more on why (Glenn please)the errors traps are hit and miss. I think I understand what you say; can you detail it a bit more? Thanks so much to you all for you help! Thanks Jooel! Yeah, it is hard without entire code.
I made this cause i didnt want to go to each workstation behind the scense just to disable this task; script worked slick did what could have taken 1 hour took only 3 minutes! bam!!!!!!!!!! I love scripts!
Edited by itdaddy (2007-01-12 09:59 PM)
_________________________
Robert A+, CCNA, MCP Network Admin Credit Union Wisconsin
|
Top
|
|
|
|
#172751 - 2007-01-12 11:22 PM
Re: @ERROR giving false positives?
[Re: itdaddy]
|
itdaddy
Starting to like KiXtart
Registered: 2006-12-19
Posts: 145
Loc: Wisconsin
|
call "tcLib.kxf"
tcInit(1)
; just disable each PC on network
$Task = "FSPinstall"
$ThisMyArray = "ftran1", "ftran2", "ftran3"
For Each $Element In $ThisMyArray
tcGetEvent($Element, $Task) ; load the bad task data
@SERROR ?
tcDefineTask("SUS=0") ; set it to Suspend (disable = 1, enable = 0)
@SERROR ?
tcSetEvent($Element, $Task) ; update the task on the target
@SERROR ?
;IF @ERROR <> 0
; $RC = REDIRECTOUTPUT (failure.txt, 0)
; ? $Element
; Else if @ERROR = 0
; $RC = REDIRECTOUTPUT (success.txt, 0)
; ? $Element
; Endif Endif
sleep 30
Next
Glenn, I did what you said and the message out was (The operation completed successfully). This means that @ERROR = 0 correct and if it @ERROR = 1 then it should say it failed. All three functions SUCCESSFUL? So why doesn't this work well. It doesn't work. I tried it. With ftran2. I shut the workstation off to see if it would usher failed workstation names to the failure.txt? sometime its worked other times they all went into the failure.txt bucket even though all of them succeeded?
So why is it not doing what normally works in this scheme. It does work on my other script where it maps the drive and upon success or failure adds workstation names accordingly? thanks.
Yes, guys I know the error trap is commented out for a reason this time. Thanks if you guys try to correct me. Thanks
Edited by itdaddy (2007-01-12 11:23 PM)
_________________________
Robert A+, CCNA, MCP Network Admin Credit Union Wisconsin
|
Top
|
|
|
|
#172761 - 2007-01-14 03:26 AM
Re: @ERROR giving false positives?
[Re: itdaddy]
|
Benny69
Moderator
Registered: 2003-10-29
Posts: 1036
Loc: Lincoln, Ne
|
itdaddy, Don't piss Jooel off! He knows what he talking about, and i suggest you listen to his suggestions.
|
Top
|
|
|
|
#172763 - 2007-01-14 05:10 AM
Re: @ERROR giving false positives?
[Re: itdaddy]
|
NTDOC
Administrator
Registered: 2000-07-28
Posts: 11623
Loc: CA
|
If Not @ERROR
$RC = RedirectOutPut('success.txt', 0)
$Element ?
Else
$RC = RedirectOutPut('failure.txt', 0)
$Element ?
Endif
|
Top
|
|
|
|
#172791 - 2007-01-15 05:21 PM
Re: @ERROR giving false positives?
[Re: NTDOC]
|
itdaddy
Starting to like KiXtart
Registered: 2006-12-19
Posts: 145
Loc: Wisconsin
|
Benny69
Hey Bud, with comments like Jooel's below, I don't care if your the President of the United States.
uhm. but you still keep the double "if" there? horrifying.
I am new to Kixtart. And I am not an expert programmer like you all. But I want to get there. Sealeopard did a good thing by explaining what horrifying meant. I can take slams, but just tell me where I am going wrong or why my code (sucks) isn't ethereal! But code is code sometimes; I have it in many other situations and it works well with NO errors. But I welcome all better code than what I produce that is why this forum is cool!
"Don't kick a baby down when he/she is trying to walk. Just clap for them for just walking even though it is wabbling!" Now noone tear up after I said this! hahahhaha!
Sealeopard,
thanks for the explain on horrifying!
NTDOC thank you as well for you help on my code!
happy new year!
Sealeopard, benny69 and Jooel,
Glenn knows what the traps are for or what I am trying to do. In my other programs it works well. I am not checking errors twice for the sake of checking errors. I am sending computer names to two separate files. failures.txt and success.txt. If no errors occur, send screen output which is $Element ? to success.txt and if errors occur, send screen output ($Element ?) or computer name of the action that failed to failure.txt.
So I can have a list of failures and successes for the next days evaluation . It has worked flawlessly in other programs that I have made. But I welcome any better code (I listen to anything you guys say that helps me and I hope I can help you out some day! Thanks guys!
Edited by itdaddy (2007-01-15 05:29 PM)
_________________________
Robert A+, CCNA, MCP Network Admin Credit Union Wisconsin
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
1 registered
(Allen)
and 466 anonymous users online.
|
|
|