Page 1 of 2 12>
Topic Options
#75949 - 2003-07-18 11:31 AM Error in expression.!
Viggen Offline
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 [Wink] )

Top
#75950 - 2003-07-18 11:41 AM Re: Error in expression.!
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
turn around 180 degrees and bang your backhead against the wall. Repeat that step frequently enough to keep your sanity [Big Grin]

Serious:

$dsq = shell "dsquery group OU=Some_school,OU=Schools,DC=school,DC=mycompany,DC=com -scope subtree -name Students"

can't be done this way !

Shell is a command and not a function [Wink]

[edit: so get rid of '$dsq =' ]

[ 18. July 2003, 11:46: Message edited by: Jochen ]
_________________________



Top
#75951 - 2003-07-18 11:49 AM Re: Error in expression.!
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11628
Loc: CA
Jochen

Actually I think that the file dsquery is a command line program he is running to get back this information.

Viggen,

Try using the line alone without the SHELL command and a GET $ on the next line so that the script waits for a key press. Then verify that the command line is not broken up and is being presented as it should be.

Also look at some of the COM methods on the board. I'm sure it can be done without shelling to an external program.

Please post your script inside the [code] tags and maybe we can help you with another method to get what you're looking for.

Top
#75952 - 2003-07-18 11:50 AM Re: Error in expression.!
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Ron ?

Yeah I know what dsquery is but still you can't assign a KiXtart command to a variable, no ?
_________________________



Top
#75953 - 2003-07-19 12:13 AM Re: Error in expression.!
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
I think J the captain is onto something here [Wink]

simply change:
code:
$dsq = shell "dsquery group OU=Some_school,OU=Schools,DC=school,DC=mycompany,DC=com -scope subtree -name Students"

to:
code:
shell "dsquery group OU=Some_school,OU=Schools,DC=school,DC=mycompany,DC=com -scope subtree -name Students"

_________________________
!

download KiXnet

Top
#75954 - 2003-07-19 12:19 AM Re: Error in expression.!
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
as already said, yeah !
_________________________



Top
#75955 - 2003-07-19 12:29 AM Re: Error in expression.!
Viggen Offline
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... [Confused]

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]

[ 18. July 2003, 12:36: Message edited by: Viggen ]

Top
#75956 - 2003-07-19 12:44 AM Re: Error in expression.!
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
try to append the following to your shell statement :

shell '%ComSpec% /c ... >nul 2>nul'

[edit: afterwards, if that worked out you might check the @error macro for successful execution]

[ 18. July 2003, 12:47: Message edited by: Jochen ]
_________________________



Top
#75957 - 2003-07-19 12:54 AM Re: Error in expression.!
Viggen Offline
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 [Frown]

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
#75958 - 2003-07-18 01:19 PM Re: Error in expression.!
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
so, if you want to have it in text file:

shell ' %comspec% /c dsquery "group OU=Some_school,OU=Schools,DC=school,DC=mycompany,DC=com -scope subtree -name Students" > c:\myfile.txt'
_________________________
!

download KiXnet

Top
#75959 - 2003-07-18 01:40 PM Re: Error in expression.!
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Yap,

sorry for that inconvenience... didn't understood that you actually wanted that to get redirected to file [Roll Eyes]
_________________________



Top
#75960 - 2003-07-18 03:15 PM Re: Error in expression.!
Viggen Offline
Starting to like KiXtart

Registered: 2002-03-22
Posts: 110
close, but no cigarr Lonkero [Smile]

Your line didn't work either, but it got me thinking.
(finally... [Wink] )

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!! [Big Grin] [Big Grin]

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
#75961 - 2003-07-18 03:20 PM Re: Error in expression.!
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
quote:
Heck, now it even works without the "%ComSpec% /C"

This I find very hard to believe. You cannot redirect to file without %comspec% unless dsquery supports >c:\myfile.txt'
internally.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#75962 - 2003-07-18 03:21 PM Re: Error in expression.!
Howard Bullock Offline
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 ]
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#75963 - 2003-07-18 03:29 PM Re: Error in expression.!
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
You should be able to use an LDAP query to check for the existance of a group called "Students".

Howard, that's your area of expertise. [Smile]
_________________________
There are two types of vessels, submarines and targets.

Top
#75964 - 2003-07-18 03:41 PM Re: Error in expression.!
Viggen Offline
Starting to like KiXtart

Registered: 2002-03-22
Posts: 110
LLigetfa:
I don't know how it works, but it does...
on the other hand since I'm going to use a few of these lines i have added the following:
$cmd = "%ComSpec% /C
shell '$cmd dsquery...

just in case

Howard Bullock:
As I wrote in an earlier post.
I'm trying to search AD for an specific group and if the group exist, then fine, but if it's not there, then I want to create it.

If it can be done with only kix that's good,
but since I'm an "old DOS habbits die hard" guy, I'm struggeling along with "shell"

Top
#75965 - 2003-07-18 03:42 PM Re: Error in expression.!
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
it won't work as you miss a " [Wink]

[ 18. July 2003, 15:43: Message edited by: Jochen ]
_________________________



Top
#75966 - 2003-07-18 03:45 PM Re: Error in expression.!
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
viggen.
I'm with les here.

I'm about 99% sure that it does not work.
remove the text file and run the code without comspec.
_________________________
!

download KiXnet

Top
#75967 - 2003-07-18 04:06 PM Re: Error in expression.!
Viggen Offline
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  [Wink]

I removed "$cmd" and " > C:\dsquery.txt"
still worked. [Razz]

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...) [Roll Eyes] [Wink]

anyways
It works now, so thanks guys

/V

Top
#75968 - 2003-07-18 04:10 PM Re: Error in expression.!
Howard Bullock Offline
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 ]
_________________________
Home page: http://www.kixhelp.com/hb/

Top
Page 1 of 2 12>


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

Who's Online
1 registered (Allen) and 1198 anonymous users online.
Newest Members
M_Moore, BeeEm, min_seow, Audio, Hoschi
17883 Registered Users

Generated in 0.076 seconds in which 0.027 seconds were spent on a total of 13 queries. Zlib compression enabled.

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