UserLastName=`$plistbuddy -c "Print dsAttrTypeStandard:LastName:0" $tempFile` UserCity=`$plistbuddy -c "Print dsAttrTypeStandard:City:0" $tempFile` UserEmail=`$plistbuddy -c "Print dsAttrTypeStandard:EMailAddress:0" $tempFile` read /Users/$loggedInUser EMailAddress City RealName LastName FirstName > $tempFile #!/bin/bashĪDUserHomeCity=$(dscl /Active Directory/DOMAIN -read /Users/$CurrentUserName | awk '$1 = "City:" ')ĭscl -plist. Yes the real time is a fraction of a second, but this example is tiny and as mentioned all this will add up (and remember, not only will it increase the time taken to recon, but someone is probably trying to use the machine at the same time, so think about what you are scripting). dscl was run only once and is calling the local files which has the same data.So the script is over 50% larger and yet ran in 2/3 the time. In fact the original script is only 7 lines of code, whilst the faster is 11. If you take the basics of these examples (as shown below) you can see that there is a distinct difference it timing between the initial posted script and the supplied alternative. In fact I've only just linked to an example of what was alluding to, regarding overhead on scripts. Try and avoid it as it will reduce the efficiency. Piping is for plumbers and cake decoration. Here is mine, which is only a small amount of the ones we use on our JSS, but there are many other repos out there: It may only shave off a fraction of a second, but when you multiply things by 100+ it all adds in addition to the resource for Extension Attributes here on JAMFNation, some of us maintain our own github repos for EAs. I've been known to go back and rewrite some of our older ones once I learn about a faster method of getting the piece of data I'm looking for. IOW, the faster a script runs when run locally in Terminal, the better it will be as an Extension Attribute. One important thing to keep in mind when writing EAs is to endeavor to make the script as fast and efficient as possible. Honestly, the ones we have we need to comb through and determine which are really needed at this point so we can clean out a few and speed up our recons. We have around 130! And yes, it does add a bit of time to your recon's, so truthfully, the least amount you can use the better.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |