Posts
49
Comments
83
Trackbacks
0
December 2005 Entries
vmsh-model.el: v0.2 Emacs major mode for MSH (Monad) scripts

Here is a simple mode for editing MSH (monad) script files in Emacs.

The syntax is easy to edit so if you need to add keywords or change highligthing, go for it! There isn't any indentation support yet, so you'll have to use the good old tab key for now.

To use it, put the file (remove the .txt extension first) in emacs\site-lisp or your local lisp directory. Place the following in your .emacs to activate it: (require 'vmsh-mode) Enjoy!

[update 1/17/06: Updated the file to version v0.2. The new version improves the syntax table] [update 1/21/06: Lee points out that this works fine in XEmacs, but in non-cvs versions of emacs, the character class \s is not recognized for some reason. So I've patched the file above to accept space instead of \s] [update 7/05/06: Mode has been updated to reflect powershell name change. Old file is linked here for reference, here is the new one]

posted @ Friday, December 23, 2005 3:12 PM | Feedback (0)
Exchange 12 Beta 1 is out

Betanews says: [snip]…A lot of work on Exchange 12 has been focused on administrative tools. The new release has been componentized and administrators can choose to install only the pieces they need. Exchange will also be able to automatically detect and configure end-user systems.Microsoft’s new command line shell, known as Monad, will make its first appearance in Exchange 12. The scriptable shell can be used for automating tasks, essentially providing command line control of Exchange that goes beyond the standard Exchange System Manager…[snip]

Zdnet says: [snip]…The company is also adding a scripting tool that enables power users to write code to automate repeated tasks, such as building new email accounts for each new employee. The tool is based on Monad, Microsoft’s next-generation scripting shell and is the first product to incorporate Monad technology.“In the past that was something you could do, but it was not that easy,” Kidd said…[snip] That’s totally awesome….

I can’t wait till we start getting customer feedback on all the new features: brand new OWA, Calendaring, Scripting, Cmdline, new ESM, Clustering, Mobility… and much more.

posted @ Wednesday, December 14, 2005 12:12 PM | Feedback (0)
Serving up pages, MSH style
Well, blame this one on extreme boredom. I wish I could post all my Exchange 12 scripts… but now is apparently not the time. So I’ll post some of my Monad only tricks for now. If you think this is crazy / cool / useful / interesting… wait till we show you what you can do in Exchange using Monad. Stay tuned. The caveat on this script is: make sure to run this in a seperate MSH instance. Once you’re done serving up pages, close that instance. That way there isn’t a process thread lying around locking port 80. If you wrote an exe you could simply hit CTRL-C to make the listener thread go away, but in script, MSH.exe is hosting the thread, so it needs to go away for the port to be unblocked.
 
param($port=80)   
$webroot = “x:”
[reflection.Assembly]::LoadWithPartialName(“System.Net.Sockets”)  [reflection.Assembly]::LoadWithPartialName(“System.Text”
function SendResponse([string]$string, [net.sockets.socket]$sock) 
{
     if ($sock.Connected)
     {
         $bytesSent = $sock.Send( [text.Encoding]::Ascii.GetBytes($string)
     )
     if ( $bytesSent -eq -1 )       
     {
             “LOG: Send failed to ” + $sock.RemoteEndPoint
     } else
     {
             “LOG: Sent $bytesSent bytes to ” + $sock.RemoteEndPoint
     }
     }
 }
function SendHeader($httpVersion, $mimeHeader, $statusCode, [net.sockets.socket] $sock, $bytes)
{
     $response = ”$httpVersion $statusCode\r\nServer: Localhost\r\nContent-Type: $mimeHeader\r\nAccept-Ranges: bytes\r\nContent-Length: \r\n\r\n” 
    SendResponse $response $sock       “Header sent” 
}
$listener = [System.Net.Sockets.TcpListener]$port
$listener.Start()
$buffer = new-object byte[] 1024 
while($true)
{
     if($listener.Pending())
     {
             [net.sockets.socket] $socket = $listener.AcceptSocket()
     }
     if ( $socket.Connected )
     {
             “Connection at {0} from {1}.” -f (get-date), $socket.RemoteEndPoint         
             $bytesRecv = $socket.Receive($buffer, $buffer.Length, “0″)          
             $inStr = [Text.encoding]::Ascii.getString($buffer)
             if ($instr.SubString(0,3) -eq “GET”)
             {
             if ($inStr -match “(HTTP/.+)”)              
             {
                 $httpVersion = $matches[0]
             }
             if ($inStr -match “(/.*) ”)
             {
                 $outStr = get-childitem ($webroot + ($matches[0] - replace “%20″,“ ”)) | convert-html | out-string
                 $outStr.Length
                 SendHeader $httpVersion “text/html” “200 OK” $socket ($str.Length)                  SendResponse $outStr $socket
             }
      }
      $socket.Close()
} }
posted @ Thursday, December 08, 2005 12:12 PM | Feedback (0)
News
A little slow these days as I'm busy working on exchangelabs.com. I will try and post tidbits when I get some time. Enjoy the older posts till then!