Posted on 11-06-2012 08:13 AM
I am from Windows and I know some VBScript and some native CMD stuff but I am not a Unix head. Three things:
1) Does anyone have a site that contains a bunch of Unix script to manipulate Mac's?
2) Does anyone have a Unix script that will run on a Mac and then write to a file all users profiles from that Mac?
3) How do you run a Unix script on a Mac remotely?
Thanks.
Posted on 11-06-2012 08:22 AM
I would head over to Github. There are lots of repos that will get you started on what you are trying to accomplish.
Posted on 11-06-2012 08:25 AM
1) While not as comprehensive as some other places, right here on JAMFNation is a good place to start looking at scripts or asking questions.
However, you might also want to check out a few other sites to get your feet wet with it.
I learned a lot of the basics years back from this page-http://hayne.net/MacDev/Notes/unixFAQ.html There are many others.
2) Can yo be more specific about what you're looking to "write" to all user folders? I'm sure there are existing threads right here that address your need, but wanted to be clear about what you want to do.
3) If using Casper, the script can be run remotely via a policy, or Casper Remote, just as two examples. If you have ARD (Apple Remote Desktop) it has a "Send Unix Command" function that allows you to copy/paste in a script to un remotely on targeted Macs.
Posted on 11-06-2012 08:43 AM
If I understand #2 correctly, you want to pull user profiles and write those to a file? The JSS does log a few things about the user accounts on each machine. What information are you trying to glean?
Posted on 11-06-2012 08:55 AM
Honestly, the best way to learn is by using the man and help options since they list all the switches. I always search google for terminal or unix terms and then man or help them to get what I need. Also, having your work checked here helps :D
Posted on 11-06-2012 09:06 AM
All, thank you. Yes, for #2 I want to know which user accounts are on each machine. Our assests is not up to date so we are trying to find out which Mac is assigned to which user. Can the JSS web portal tell you that? I've run some of the inventory files and it does not give much user info, only machine and application info.
Posted on 11-06-2012 09:11 AM
Are you collecting user accounts in your Inventory Collection Preferences? That should be capturing all accounts on your Macs, even if they are AD based with cached local home folders.
Posted on 11-06-2012 09:14 AM
Lots of good threads on this forum...
https://jamfnation.jamfsoftware.com/discussion.html?id=3736
...watch out for the "my script is shorter than yours" guys, you can't win! :)
Don
Posted on 11-06-2012 09:42 AM
Wow, someone referenced Hayne's site. I know that guy from like 10 years ago from other Mac sites, ha! That is actually pretty cool.
Here are some things I have used to learn bash, awk/sed, and some python.
http://www.tldp.org/HOWTO/Bash-Prompt-HOWTO/index.html
http://www.tldp.org/HOWTO/Bash-Prog-Intro-HOWTO.html
http://www.gnu.org/software/bash/manual/bashref.html
http://learnpythonthehardway.org/
There are some really good scripters here as well at JAMF Nation. I was asked to post these links in our JNUC presentation thread and just have not gotten around to it yet. I recommend you just start with a simple project and then see if you can build a scripting solution for it. Then see if you can move it into production. I will say that learning these tools is great and powerful, but a lot of times not needed. I encourage everyone to learn, but also at the same time use scripts when they are applicable. Don't create more work for yourself.
I hope you all find these links helpful. I have probably 50+ bash scripting links bookmarked in my browser plugins. I can provide more, but these are the links I used to get started.
Thanks,
Tom
Posted on 11-06-2012 09:51 AM
Yes, in our Inventory Collection Prefs we have the following selected.
Accounts:
Collect Accounts is Checked
Include hidden accounts is Checked
I then ran an Advanced Inventory Search. I picked User Name, then Real Name and ran the report. It did not return any User info at all.
What am I missing?
Posted on 11-06-2012 09:56 AM
I would also suggest to try not to just use a script blindly. Make an attempt at understanding the script as best you can. At the very least, you won't learn much just by copying/pasting. At the very worst, you could cause unwanted problems running a script without knowing what its actually doing. Though generally speaking, any script coming from a reputable site should be safe, its better to be sure. :)
@Tom - yeah, Hayne. :) I had almost forgotten about him actually and had to dig that link up. He was a frequent resource on the MacOSXHints.com forum years ago, but I haven't really seen him around in a while.
Posted on 11-06-2012 10:01 AM
Hi mqh7,
You can see what user last logged in by looking at the usage logs for each computer individual. If you want a report of all user accounts you can do so in the inventory collection and inventory display preferences in the JSS.
Are these accounts local accounts, or are they network accounts? Do they use LDAP credentials to authenticate to any sort of LDAP server, and is that LDAP server connection set up in the JSS?
Thanks,
Tom
Posted on 11-06-2012 10:03 AM
That setting does not necessarily capture the Real Name and other info in the Location section. You need to enable other options to capture that. Under Inventory Collection Preferences, go to the Location tab and make sure the option there is checked on.
In the interim, you can run an Advanced Search and look under the Receipts Information section for Local User Accounts. I know, its not obvious it would be located there, but those collected items are considered receipts, so that's why they get placed there. That should let you search for any Macs that have an account you enter present on them.
Edit: Never mind. Misread what you were looking for. Follow Tom's suggestion to generate a report of the last user on each Mac across your inventory.
Posted on 11-06-2012 12:02 PM
@mqh7 JSS is only going to show data gathered when the JAMF binary runs recon. We gather inventory every 7 days, so if we flicked those switches, we'd have to wait 7 days. As a test, run this on one of the Macs so inventory is gathered/submitted, then check JSS again:
sudo jamf recon
Posted on 11-06-2012 01:25 PM
how do you view all Usage Logs at once? I see that I can do it for 1 machine but is there a report that shows all computers and all user data?