#75949 - 2003-07-18 11:31 AM
Error in expression.!
|
Viggen
Starting to like KiXtart
Registered: 2002-03-22
Posts: 110
|
Here's all of the message:
quote:
ERROR : Error in expression.! Script: C:\Temp\Users.kix Line : 350
This is line 350: $dsq = shell "dsquery group OU=Some_school,OU=Schools,DC=school,DC=mycompany,DC=com -scope subtree -name Students"
The script worked perfekt until I added this line to check for a group in AD.
I have tried with "%COMSPEC /C" --> no result... I have tried to do it manually in the console --> works perfectly
If i comment out the line the script runs smooth again
note. This is done on an Win2k3 DC
My forehead is starting to hurt and the wall I'm sitting next to is starting to get dents, from me banging the head against it.
Can some one tell me what the heck I'm doing wrong? (With the line... not the wall/head )
|
|
Top
|
|
|
|
#75950 - 2003-07-18 11:41 AM
Re: Error in expression.!
|
Jochen
KiX Supporter
   
Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
|
|
|
Top
|
|
|
|
#75955 - 2003-07-19 12:29 AM
Re: Error in expression.!
|
Viggen
Starting to like KiXtart
Registered: 2002-03-22
Posts: 110
|
I have tried this: shell "dsquery group OU=Some_school,OU=Schools,DC=school,DC=mycompany,DC=com -scope subtree -name Students"
And that works. The problem is that I get the result on screen and I need the script to work with the result.
I have tried the following: shell "dsquery group OU=Some_school,OU=Schools,DC=school,DC=mycompany,DC=com -scope subtree -name Students > C:\Temp\query.txt"
Thought I'd do a Readline after that, but again the command works only at the console. If I try to let kix do it I get an dsquery error stating that '>' is an unknown command, so it seems that it doesn't get passed to dos correctly?? strange...
note. What i'm trying to do is search AD to see if a specific group exist. If it does... fine If it doesn't... create it I thought to myself that "hehe... there's a builtin tool for this in win2k3, why not be lazy and use it" But NO... not a snowballs chance in hell that it should work ![[Big Grin]](images/icons/grin.gif) [ 18. July 2003, 12:36: Message edited by: Viggen ]
|
|
Top
|
|
|
|
#75957 - 2003-07-19 12:54 AM
Re: Error in expression.!
|
Viggen
Starting to like KiXtart
Registered: 2002-03-22
Posts: 110
|
and the result is...
"dsquery failed: '>' is an unknown parameter"
Darn! that didn't work
I don't understan what could be wrong here? it's a simple quoted statement. I mean, if i copy it from the script, paste it into the console, then it works. Very strange...
[edit:] When I use "%ComSpec% /C" it doesn't give an error message, and the "? @serror @error" gives me "The command completed successfully.0" So far so good... ... but I don't get any .txt-file. [/edit:] [ 18. July 2003, 13:03: Message edited by: Viggen ]
|
|
Top
|
|
|
|
#75960 - 2003-07-18 03:15 PM
Re: Error in expression.!
|
Viggen
Starting to like KiXtart
Registered: 2002-03-22
Posts: 110
|
close, but no cigarr Lonkero
Your line didn't work either, but it got me thinking. (finally... )
I changed your line from: quote:
shell ' %comspec% /c dsquery "group OU=Some_school,OU=Schools,DC=school,DC=mycompany,DC=com -scope subtree -name Students" > c:\myfile.txt'
To this: quote:
shell '%comspec% /c dsquery group OU=Some_school,OU=Schools,DC=school,DC=mycompany,DC=com -scope subtree -name Students > c:\myfile.txt'
And finally...
It WORKS!!
The solution was so simple... it was the singel quotes that was missing. Never even thought about them until you used them. Heck, now it even works without the "%ComSpec% /C"
How could I have missed them? It's like: Glasses on --> "Hi Clark Kent" Glasses off --> "Who's that?!? Oh! it's Superman!"
Thanks a bunch guys for putting up with my stupid questions
/V
|
|
Top
|
|
|
|
#75962 - 2003-07-18 03:21 PM
Re: Error in expression.!
|
Howard Bullock
KiX Supporter
   
Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
|
What are you actually trying to accomplish? There may be ways to get there without shelling out to dsquery and writing the output to a text file. [ 18. July 2003, 15:34: Message edited by: Howard Bullock ]
|
|
Top
|
|
|
|
#75967 - 2003-07-18 04:06 PM
Re: Error in expression.!
|
Viggen
Starting to like KiXtart
Registered: 2002-03-22
Posts: 110
|
Maaan... Why did you have to do that... now you have messed up my script
I removed "$cmd" and " > C:\dsquery.txt" still worked.
but since I trust you guys, I dug a little deeper...
Restarted the server started the console and fired away... ... No go...
now I can't reproduce this even if I put the "$cmd" back and then remove it again.
It won't work without the "$cmd"
conclusion: You were right... (again...)
anyways It works now, so thanks guys
/V
|
|
Top
|
|
|
|
#75968 - 2003-07-18 04:10 PM
Re: Error in expression.!
|
Howard Bullock
KiX Supporter
   
Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
|
Viggen, use TranslateName() UDF to determine if your group exists. If it does then the UDF will return the DN of the group.
code:
call "%tmp%\libr-prd.kix" $DN = TranslateName (3, "", 3, "@LDomain\administrators", 1) ? "DN = " + $DN[0] ? "Error = " + $DN[1] ? "ErrorText = " + $DN[2]
DN = CN=Administrators,CN=Builtin,DC=EmptyRoot Error = 0 ErrorText = The operation completed successfully.
If not, you receive:
DN = Error = 1 ErrorText = COM exception error "Set" ((null) - (null)) [1/1]
Do you want to create the group in a particular OU? Will it always be the same? Will the OU be input somehow? [ 18. July 2003, 16:12: Message edited by: Howard Bullock ]
|
|
Top
|
|
|
|
Moderator: Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart
|
1 registered
(Allen)
and 1198 anonymous users online.
|
|
|