Posted on 06-10-2011 11:12 AM
Happy Friday Everyone,
We have several scripts that are run on Windows XP/7 systems on login time for our desktops. However, I am trying to take advantage of some of these scripts for the Mac. I am not a scripter but have always wanted to learn more in this area. With that being said, is there a way to convert or re-write the script for the Mac? Are there any good reference books for learning scripting for the Mac so I can use pre and post image scripts?
Thanks in advance again for your response.
Mick
Posted on 06-10-2011 11:16 AM
AppleScript, Python, Perl, Shell... take your pick. If it's an installed interpreter, fire away. It may help us out if you let us know what these scripts are supposed to do.
j
---
Jared F. Nichols
Desktop Engineer, Client Services
Information Services Department
MIT Lincoln Laboratory
244 Wood Street
Lexington, Massachusetts 02420
781.981.5436
Posted on 06-10-2011 11:20 AM
Oreilly books are awesome for this sort of thing:
On Jun 10, 2011, at 11:12 AM, Michael D Conners wrote:
http://search.oreilly.com/?q=bash
I have the "Learning the bash Shell" and "bash Cookbook" books. Both are highly recommended...
Posted on 06-10-2011 11:41 AM
I suggest you consider shell scripting and AppleScript. Shell scripts are
On 6/10/11 1:12 PM, "Michael D Conners" <MConners at matcmadison.edu> wrote:
executable from the command line and don't require a user to be logged in
to the console to run. AppleScript will only run under a user session but
many Mac applications are AppleScriptable, which you can use to tie
processes from different applications together.
--
William Smith
Technical Analyst
Merrill Communications LLC
(651) 632-1492
Posted on 06-10-2011 01:14 PM
Here. This will do the trick. Customize for your environment.
Posted on 06-10-2011 03:09 PM
I should mention that this project is a work in progress. Some features don't work, and I don't know most VBScript features; I only implemented the ones our scripts use. You might have to implement additional features to make it work in your environment.
The goal of these scripts is to convert the appropriate VBScripts to Python, and then run them within the environment they need to operate. The main scripts are vbs2py.py and runbat.py. Their job is to convert each VBScript, and to execute them, respectively. There are also several auxiliary scripts to help set up the environment for execution.
runbat.py:
The main entry point. Its purpose is to convert and run the appropriate VBScripts within the appropriate execution environment. Depending on the options passed to it, it can be instructed to mount the NETLOGON network share (where our login scripts are stored) and/or figure out which .bat needs to be run. It stores the converted scripts in a cache in the user's home folder by default, and recreates them as needed.
vbs2py.py:
Performs the actual conversion from .vbs to .py. It generally converts things as-is, so it adds a hook at the beginning of the output script to load the contents of the builtins module, which provides the global variables and objects that the script expects to find.
builtins.py:
Provides global constants, variables, and objects to each converted VBScript to allow them to function.
WScript:
Provides the global WScript object and CreateObject function.
NOTE: The domain is currently hardcoded in this file, because I haven't yet found a way to detect it. That's fine in our environment, but might not be in yours.
Scripting:
Provides the Scripting.FileSystemObject and Scripting.Dictionary objects.
CaselessDict:
Provides a Python dict class that is case-insensitive.
Logger:
Provides advanced logging facilities.
Err.py:
Provides the global Err object.
GetObject:
Provides the global GetObject function.
dscl.py:
Provides AD lookups via the 'dscl' command. Can also be run standalone to query AD for information about one or more users. (Actually not quite standalone; it imports Logger.py, but for its standalone functionality, that can safely be skipped.)
IncludeScript.py:
A rewritten converted version of our IncludeScript.vbs, which provides all of the support functions that our other VBScripts use. Your environment will likely (hopefully) have something similar that you will need to convert and rewrite.
EndScript.py:
A modified converted version of our EndScript.vbs. I use this because our EndScript.vbs has some calls occurring before their functions are defined (which is invalid in Python).
It appears I left out one file:
Posted on 06-13-2011 06:51 AM
Chiming in a bit late here, but I do probably 90% of my scripting in shell (bash) and the other 10% are usually a mixture of a little bit of Apple Script, perl, python, and on occasion some C stuff. Apple has a lot of built in command line binaries specifically for their platform. A lot of GUI apps have a command line equivalent. There is not a lot you cannot do when it comes to Sys Admin type stuff from the command line.
-Tom