#39087 - 2003-04-12 12:38 AM
Adding Printer Mare
|
Jac
Fresh Scripter
Registered: 2003-04-11
Posts: 11
Loc: UK
|
New to Kix and from a Shell scripting background. I have hundreds of printers to add using kix scripts and instead of consecutive if statements i would like to use a for loop. My problem is now A i need to get a list of groups the user is a member of, and B need to be able to querry a line in a config file for fields. That way i can execute the for loop to querry a printer file for names matching groups and install the printer... Any help would be gr8! tnx
|
|
Top
|
|
|
|
#39089 - 2003-04-11 03:32 PM
Re: Adding Printer Mare
|
Jac
Fresh Scripter
Registered: 2003-04-11
Posts: 11
Loc: UK
|
thanks the exe is version 3,62,0,0 I get the if ingroup ("Blob")=1 if setdefaultprinter(\\server1\blobprn")=0 endif but i need to extract groups from logged in user, check a config file for matching groups and then add the printer thats in the next column in the config file. (still stuck in grep, sed and awk mode sorry!) so a for each loop could be run against the users groups to find the matching one and then make default
P.S. Any good docs on Kix?
|
|
Top
|
|
|
|
#39091 - 2003-04-11 04:14 PM
Re: Adding Printer Mare
|
Jac
Fresh Scripter
Registered: 2003-04-11
Posts: 11
Loc: UK
|
OK, so how do i extract a list of groups a user is a member of? Is the a way of executing NT commands within Kix? Still looking for a good Document on Kix!
|
|
Top
|
|
|
|
#39093 - 2003-04-11 04:58 PM
Re: Adding Printer Mare
|
Jac
Fresh Scripter
Registered: 2003-04-11
Posts: 11
Loc: UK
|
RTFQ! can you get a list of Groups the user is in, was my question? Not in the Manual! that i can see. I dont want to ask what group he's in, I want a list of them like showgrps on reskit. I am trying to avoid constant if statements and just create a loop with a config file. If you have another suggestion go ahead. I already have groups created for printers, now i need to script it to make the default one. I have just started kix today and the document aint exactly "in a nutshell" Thanks for the help!
|
|
Top
|
|
|
|
#39096 - 2003-04-11 05:16 PM
Re: Adding Printer Mare
|
Jac
Fresh Scripter
Registered: 2003-04-11
Posts: 11
Loc: UK
|
DOH! The School of hard knocks really is a mean teacher, the wood is now much clearer from the tree's thnx.
PS. Go easy i'm a kix newbie
|
|
Top
|
|
|
|
#39099 - 2003-04-15 03:34 PM
Re: Adding Printer Mare
|
Jac
Fresh Scripter
Registered: 2003-04-11
Posts: 11
Loc: UK
|
Thanx but not an option at present due to every printer having its own group.
Question If $ Group returns my group within a loop to get them all. How would i go about appending them to a var to make an array. Along the lines of $Groups = $Groups + $Group. Used Enum to get group in a do until 0 loop to get them all now i need to either get the list of them all in an array! am i confused or what. Or should i output them to a temp file, but then i'd need a command to search for occurances.
|
|
Top
|
|
|
|
#39101 - 2003-04-16 10:07 AM
Re: Adding Printer Mare
|
Jac
Fresh Scripter
Registered: 2003-04-11
Posts: 11
Loc: UK
|
Exactly that! eg Group: Printer HP1 Printer: HP1
current an if in statement does all the printer 1000's the scripts are huge. i want to get the groups id the printer group and assign a printer from a file listing all the printers.
I was thinking my do until could be done till the group contained the word printer and then strip "printer " search the txt file for hp1 and assign as default. This maybe a bit much for kixstart or may be easy. Dunno which yet.
eg. printer.txt //server1/printer HP1
|
|
Top
|
|
|
|
#39102 - 2003-04-16 10:51 AM
Re: Adding Printer Mare
|
Richard H.
Administrator
   
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
Easy as a very easy thing indeed.
Final question, are the printers all attached to the same print server?
If so you are in for a real treat.
Here is some sample code which assumes: 1) The print server is static. 2) The group names areformal and consistant. 3) So are the printer names.
Given that your print server is "\\MyPrintServer", your groups are "Printer: HP1", "Printer: Colour_HP2" etc the following (untested) should work:
$sPrintServer="\\MyPrintServer" $iIndex = 0 $sGroup=EnumGroup($iIndex) While $sGroup ; Not interested in domain. If InStr($sGroup,'\') $sGroup=SubStr($sGroup,InStr($sGroup,'\')+1) EndIf If Instr($sGroup,"Printer: ")=1 $sPrinter=SubStr($sGroup,10) If AddPrinterConnection($sPrintServer+"\"+$sPrinter) "ERROR "+@ERROR+": "+@SERROR+@CRLF+"While mapping "+$sPrintServer+"\"+$sPrinter ? Else "Printer "+$sPrintServer+"\"+$sPrinter+" mapped ok." ? EndIf EndIf $iIndex=$iIndex+1 $sGroup=EnumGroup($iIndex) Loop
|
|
|
Top
|
|
|
|
#39103 - 2003-04-16 11:18 AM
Re: Adding Printer Mare
|
Jac
Fresh Scripter
Registered: 2003-04-11
Posts: 11
Loc: UK
|
Richard Thankyou very much, unfortunately my printers are all on different print servers. The file i had in mind currently had this make up. Printers.ini or txt \\server1\printer1 \\server2\printer4 and so on. if a better setup would make it easier for me im open to suggestions. just thought i could search the file for printer and pull the whole line as my variable. then assign as default.
Thanks again i have a lot to work at now and any progress i'll put back on here.
|
|
Top
|
|
|
|
#39104 - 2003-04-16 11:29 AM
Re: Adding Printer Mare
|
Richard H.
Administrator
   
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
Don't despair, it only requires a few tweaks.
Have an ini file on your netlogon share in the format:
code:
[PrinterMap] HP1=\\server1\HP1 ColourHP2=\\otherserver\ColourHP2
Now, change the script slightly so that it reads:
$sPrintServer="\\MyPrintServer" $sPrinterMap=@LSERVER+"\netlogon\PrinterMap.ini" $iIndex = 0 $sGroup=EnumGroup($iIndex) While $sGroup ; Not interested in domain. If InStr($sGroup,'\') $sGroup=SubStr($sGroup,InStr($sGroup,'\')+1) EndIf If Instr($sGroup,"Printer: ")=1 $sPrinter=ReadProfileString($sPrinterMap,"PrinterMap",SubStr($sGroup,10)) If $sPrinter If AddPrinterConnection($sPrintServer+"\"+$sPrinter) "ERROR "+@ERROR+": "+@SERROR+@CRLF+"While mapping "+$sPrintServer+"\"+$sPrinter ? Else "Printer "+$sPrintServer+"\"+$sPrinter+" mapped ok." ? EndIf Else "ERROR: Could not find printer mapping for "+$sPrinter ? EndIf EndIf $iIndex=$iIndex+1 $sGroup=EnumGroup($iIndex) Loop
|
|
|
Top
|
|
|
|
#39105 - 2003-04-22 10:38 AM
Re: Adding Printer Mare
|
Jac
Fresh Scripter
Registered: 2003-04-11
Posts: 11
Loc: UK
|
Thanks again Giving it a go today.
|
|
Top
|
|
|
|
#39106 - 2003-04-22 01:20 PM
Re: Adding Printer Mare
|
Jac
Fresh Scripter
Registered: 2003-04-11
Posts: 11
Loc: UK
|
in the line If InStr($sGroup,'\') what does the '\' look for as far as i know its not returned in the group names so im a little confused
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
1 registered
(Allen)
and 483 anonymous users online.
|
|
|