Page 1 of 3 123>
Topic Options
#171820 - 2006-12-20 06:03 PM @error handling? and redirection to a text file (append)
itdaddy Offline
Starting to like KiXtart

Registered: 2006-12-19
Posts: 145
Loc: Wisconsin
Hey kix gurus;
i made this program below all works but i cant do the @error very well.
i dont understand how i can through conditions (see commented out)
how to send the PCname which is $Element (local scope variable)
to its specific failure.txt or success.txt file to
be able to look at the next day on which connections failed and succeeded?
can anyone help me.?
thank you



_______________________________________________________
$FourthAveArray = "ftran1", "ftran2", "ftran3"

For Each $Element In $FourthAveArray


Shell "net use z: \\" + $Element + "\c$"
;if connection error, push pcname to failure.txt
;else if no error push pcname to success.txt
Shell "CMD.EXE /C copy c:\fspcopy\*.mdb z:\fsp\mdb /y"
Shell "CMD.EXE /C time /t"
Shell "net use z: /delete"


Next
_________________________________________________________
_________________________
Robert
A+, CCNA, MCP
Network Admin
Credit Union Wisconsin

Top
#171822 - 2006-12-20 06:16 PM Re: @error handling? and redirection to a text file (append) [Re: itdaddy]
Benny69 Offline
Moderator
*****

Registered: 2003-10-29
Posts: 1036
Loc: Lincoln, Ne
Hi ITDaddy, and welcome to the board.

You should place your code between code tags.

Is the code you are posting part of a logon script or is it part of a utility?

The reason I ask is because if this is a logon script there would be not reason to loop thru all your PC's and you could use the @WKSTA macro to retrieve the PC name.

If this is part of a utility to look at each PC, it will be hard to find out if it had trouble logging in or whatever.

It might be best if you post your entire code so that we can better help you.
_________________________
Wait don't order yet,... get KiXforms Designer .NET 2.0 (Beta)
KiXforms Designer .NET 2.0 (Beta)

Top
#171832 - 2006-12-20 07:35 PM Re: @error handling? and redirection to a text file (append) [Re: itdaddy]
Anonymous
Unregistered


Hey benny69
thanks! i tried to look for quotes are the image tags here the same as quotes
where are they?? the buttons i mean? thanks

"Is the code you are posting part of a logon script or is it part of a utility?"

No; it is a program executed from a batch file like kix32 filename.kix.
I run it on a server through the schedular.
reason being is we run it at night while all workstations are on.
It is for copying some mdb files to workstations. user dink around
while they are downloading these and they get corrupt so we leave
PCs on and run on schedule at night and we want to see which ones fail
and which ones succeed thus the two txt files redirected to.
I made a program in DOS batch that works with ERRORLEVEL just fine
but it is hard to loop through arrays in DOS; i cant find how to do arrays in DOS? nicely! heheeee. Everything works great but i dont know how to redirector PC name to each file upon conditon met. The kicker is
it creates the mapped drive from one admin server thus the /delete
switch so i can go to each pc with mapped drive. i need to do it this way due to after hours.

not logging on i need a failure to connect error like error 53 or 67
in dos i heard in kix if the mapped command fails @Error is set to non zero which is fail? this is the entire code minus the batch file that kix it off. thanks



The reason I ask is because if this is a logon script there would be not reason to loop thru all your PC's and you could use the @WKSTA macro to retrieve the PC name.

If this is part of a utility to look at each PC, it will be hard to find out if it had trouble logging in or whatever.

It might be best if you post your entire code so that we can better help you.

Top
#171834 - 2006-12-20 07:43 PM Re: @error handling? and redirection to a text file (append) [Re: ]
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Wazzup with the duaal personality idaddy/itdaddy?

At the top of the edit window are a bunch of squares with icons. If you hover your mouse over them you should get tooltips. the double curly quotes ["] one gives you quote tags, the pound [#] code tags.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#171835 - 2006-12-20 09:33 PM Re: @error handling? and redirection to a text file (append) [Re: Les]
Benny69 Offline
Moderator
*****

Registered: 2003-10-29
Posts: 1036
Loc: Lincoln, Ne
I would still like to see your script, but rather than looking for an @Error i would suggest you use something like Ping().
_________________________
Wait don't order yet,... get KiXforms Designer .NET 2.0 (Beta)
KiXforms Designer .NET 2.0 (Beta)

Top
#171836 - 2006-12-20 09:43 PM Re: @error handling? and redirection to a text file (append) [Re: Les]
Anonymous
Unregistered


Hey thanks

but when i first registered it would not let me
and then it said there was another itdaddy but when i looked
there was an idaddy; big diff....i am itdaddy..like whose your IT Daddy
and i dont know who is idaddy? there are no searches for anything that guy.
but please keep me as ITDADDY like my icon/avatar!
thanks

hey any tips on my question?S
thank les
love your avatar that is funny $h$$

Top
#171837 - 2006-12-20 09:51 PM Re: @error handling? and redirection to a text file (append) [Re: Benny69]
Anonymous
Unregistered


Quote:

FourthAveArray = "ftran1", "ftran2", "ftran3"

For Each $Element In $FourthAveArray


Shell "net use z: \\" + $Element + "\c$"
;if connection error, push pcname to failure.txt
;else if no error push pcname to success.txt
Shell "CMD.EXE /C copy c:\fspcopy\*.mdb z:\fsp\mdb /y"
Shell "CMD.EXE /C time /t"
Shell "net use z: /delete"


Next


benny69 this is my coding!
except the lines commented out.

it loops until array is empty and
at each loop it runs shell commands (or dos commands)
like this:
maps drive z
copies mdb files
removed mapped drive
loop back and do for next pcname
get it

Top
#171839 - 2006-12-20 09:55 PM Re: @error handling? and redirection to a text file (append) [Re: ]
Benny69 Offline
Moderator
*****

Registered: 2003-10-29
Posts: 1036
Loc: Lincoln, Ne
look an the linky i posted, i think that it is what you are wanting. it will allow you to try to connect to the pc and will give back an error if it can not.
_________________________
Wait don't order yet,... get KiXforms Designer .NET 2.0 (Beta)
KiXforms Designer .NET 2.0 (Beta)

Top
#171841 - 2006-12-20 10:37 PM Re: @error handling? and redirection to a text file (append) [Re: ]
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11624
Loc: CA
Well you tell me what's going on. I changed your Display name to ITDADDY as it shows in the very top post here.

But now it shows you posting as IDADDY so I would assume both accounts are yours, or you sure can imitate the other one pretty good.



Quote:
Profile for idaddy
Member #: 9764
Title: stranger
Total Posts: 4
Registered on: 02/14/06 07:06 AM
vandyker@becu.net


Profile for itdaddy
Picture
Member #: 11768
Title: stranger
Total Posts: 2
Registered on: Yesterday at 07:09 AM
vandyker@charter.net



.


Edited by NTDOC (2006-12-20 10:39 PM)

Top
#171842 - 2006-12-20 10:41 PM Re: @error handling? and redirection to a text file (append) [Re: ]
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11624
Loc: CA
As for posting and editing of your posts it should be pretty easy, but for those that need a visual.




.

Top
#171843 - 2006-12-20 10:42 PM Re: @error handling? and redirection to a text file (append) [Re: NTDOC]
Anonymous
Unregistered


you are right maybe some how i messed up when i first registered?
delete idaddy
keep itdaddy; sorry for about the mess up ! i am half blind and maybe i messed up; it looks like i messed up; thanks
sorry

Top
#171844 - 2006-12-20 10:44 PM Re: @error handling? and redirection to a text file (append) [Re: NTDOC]
Anonymous
Unregistered


yes they are both mine becu is my work and charter is my home
delete idaddy yeah that is me; i must have some how register from work and home
sorry just keep itdaddy at the charter.net
thanks sorry for bing a cluts!
my bad!

Top
#171845 - 2006-12-20 10:44 PM Re: @error handling? and redirection to a text file (append) [Re: Anonymous]
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11624
Loc: CA
And GONE it is.
Top
#171846 - 2006-12-20 11:21 PM Re: @error handling? and redirection to a text file (append) [Re: Benny69]
itdaddy Offline
Starting to like KiXtart

Registered: 2006-12-19
Posts: 145
Loc: Wisconsin
Code:
$FourthAveArray = "ftran1", "ftran2", "ftran3"

Global $Element

For Each $Element In $FourthAveArray
         
	 
         Shell "net use z: \\" + $Element + "\c$"  
      	 IF @ERROR <> 0
	    REDIRECTOUTPUT (failure.txt, 0)
	    ? $Element
	 Endif     
	
	 ;Shell "CMD.EXE /C copy c:\fspcopy\*.mdb z:\fsp\mdb /y"
	 Shell "CMD.EXE /C time /t"
	 Shell "net use z: /delete"
	 

Next


NTDOC and benny69 sorry for being so blind; i dont see very well
i have glasses and and my fonts are big so sometimes i mess up;

but benny69 here is my code that works; i finally go it to append my failure.txt file; that ping() code was nice but way to complex for me as a beginner but this code puts @Error <> 0 into failure.txt and I will add
30 more computers in my array and give her a final test but i think she is ready; simple yet powerful enough to keep my boss home while this copies mdb files to each pc in the domain effortlessly and keep track of failure to connect network mappings
yeah! merry christmas t you all
robert;D
_________________________
Robert
A+, CCNA, MCP
Network Admin
Credit Union Wisconsin

Top
#171847 - 2006-12-20 11:21 PM Re: @error handling? and redirection to a text file (append) [Re: Benny69]
itdaddy Offline
Starting to like KiXtart

Registered: 2006-12-19
Posts: 145
Loc: Wisconsin
Code:
$FourthAveArray = "ftran1", "ftran2", "ftran3"

Global $Element

For Each $Element In $FourthAveArray
         
	 
         Shell "net use z: \\" + $Element + "\c$"  
      	 IF @ERROR <> 0
	    REDIRECTOUTPUT (failure.txt, 0)
	    ? $Element
	 Endif     
	
	 Shell "CMD.EXE /C copy c:\fspcopy\*.mdb z:\fsp\mdb /y"
	 Shell "CMD.EXE /C time /t"
	 Shell "net use z: /delete"
	 

Next


NTDOC and benny69 sorry for being so blind; i dont see very well
i have glasses and and my fonts are big so sometimes i mess up;

but benny69 here is my code that works; i finally go it to append my failure.txt file; that ping() code was nice but way to complex for me as a beginner but this code puts @Error <> 0 into failure.txt and I will add
30 more computers in my array and give her a final test but i think she is ready; simple yet powerful enough to keep my boss home while this copies mdb files to each pc in the domain effortlessly and keep track of failure to connect network mappings
yeah! merry christmas t you all
robert;D
_________________________
Robert
A+, CCNA, MCP
Network Admin
Credit Union Wisconsin

Top
#171849 - 2006-12-21 01:36 AM Re: @error handling? and redirection to a text file (append) [Re: itdaddy]
Witto Offline
MM club member
*****

Registered: 2004-09-29
Posts: 1828
Loc: Belgium
Why do you Shell for things that can be native KiXtart?
Why map to Z: if yo can also copy to an UNC style path?
Code:
If NOT @LOGONMODE
	Break On
EndIf
Dim $FourthAveArray, $Element
$FourthAveArray = "ftran1", "ftran2", "ftran3"
For Each $Element In $FourthAveArray
	Copy "C:\fspcopy\*.mdb" "\\" + $Element + "\c$\fsp\mdb" /c /h /r
	;? @TIME ;Why display the time?
Next

Top
#171853 - 2006-12-21 02:52 AM Re: @error handling? and redirection to a text file (append) [Re: Witto]
itdaddy Offline
Starting to like KiXtart

Registered: 2006-12-19
Posts: 145
Loc: Wisconsin
Code:
 If NOT @LOGONMODE
	Break On
EndIf
Dim $FourthAveArray, $Element
$FourthAveArray = "ftran1", "ftran2", "ftran3"
For Each $Element In $FourthAveArray
	Copy "C:\fspcopy\*.mdb" "\\" + $Element + "\c$\fsp\mdb" /c /h /r
	;? @TIME ;Why display the time?
Next


Hi witto

not sure what the IF NOT @LOGONMODE if statement is for?
but i really like your copy/map line of code; i will try that on
my code i sent in. if it maps a drive and then deletes the mapped drive does it? is that what the /c/h/r switches are for is any a drive letter?
i need it to map a drive and then delete it? is that what it does? your code that is? the reason i need it to show time; is i want to see how long it takes to copy to each workstation. but i will try you copy/map line
but it has to create map drive and the delete it for the next pc in the array. and i want it to post all error<>0 items(pcnames) to the text file failure.txt
thanks witto

ps. i am not logging on to these workstations; that is why it is not a logon script; it is a script that is scheduled to run off of a member server that has Domain Admin rights; i made this program so my boss doesnt stay late and have to manaully copy these mdb files to all 100 workstations
it just does it iself and keeps track of the failed network mappings (hopefully indicating the PC is off) so the next day my boss can review and manually update only a few vs 100 pcs. trying to get brownie points using my scripting skills;D


ps. i am just learning kix and i am limited but know how dos works.
;D thanks for teaching me your art!
itdaddy;D


Edited by itdaddy (2006-12-21 02:56 AM)
_________________________
Robert
A+, CCNA, MCP
Network Admin
Credit Union Wisconsin

Top
#171854 - 2006-12-21 04:21 AM Re: @error handling? and redirection to a text file (append) [Re: itdaddy]
Gargoyle Offline
MM club member
*****

Registered: 2004-03-09
Posts: 1597
Loc: Valley of the Sun (Arizona, US...
Why are you mapping to drives at all?

If you are member of the local machines admin group (And if you are running in an AD enviroment and are a Domain Admin you are automatically one), you can just copy the file directly via UNC No mapping required. The @error will tell you if was successful or not and generally why (use @Serror)

Code:
$Time = @msec
copy c:\fscopy\*.mdb "\\"+$element+"\c$\fsp\mdb" /c /h /r
If not @error
  ;Write error to logfile
EndIf
$Time = @msec - $time
;Now you have exactly how long it took


Edited by Gargoyle (2006-12-21 04:24 AM)
_________________________
Today is the tomorrow you worried about yesterday.

Top
#171857 - 2006-12-21 05:56 AM Re: @error handling? and redirection to a text file (append) [Re: itdaddy]
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11624
Loc: CA
If these are mdb files why not just share them from one location?

Even Access can handle up to about 250 users (though not very fast).

Top
#171860 - 2006-12-21 06:47 AM Re: @error handling? and redirection to a text file (append) [Re: Gargoyle]
itdaddy Offline
Starting to like KiXtart

Registered: 2006-12-19
Posts: 145
Loc: Wisconsin
NTDOC

yeah, i am worried about speed though that is a smart idea!

Gargoyle, nice coding; duh on my part..i guess you can UNC it
it will probably run alot faster...and less code..
and the time calc nice! i will use them and let you know.
you guys are awesome. i love kix!
_________________________
Robert
A+, CCNA, MCP
Network Admin
Credit Union Wisconsin

Top
Page 1 of 3 123>


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 718 anonymous users online.
Newest Members
Timothy, Jojo67, MaikSimon, kvn317, kixtarts2025
17874 Registered Users

Generated in 0.084 seconds in which 0.03 seconds were spent on a total of 14 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org