Expand a Logical Drive using existing free space on a DS3200.

Here is the command for smcli to expand an existing Logical Drive. I had to mix documentation from Dell, IBM, and SANtricity to get a working command line. The ; at the end of the line is required. i just ran smcli localhost and pasted the below command.

This is not the same as add capacity in the GUI.

Here is the command information to expand the drive in windows.

set logicaldrive["name or label of logical drive"] addCapacity=SizeinBytes;

Hidden Logon Script

This little vbscript wrapper will let you start a logon script hidden. Our logon scripts are batch and perl files and they all start with the black box. If you launch the script like hidelaunch.vbs logon.bat it will start the logon script hidden.

Set wshShell = CreateObject("WScript.Shell")
set args = wscript.arguments

command = ""

for each strArg in args
 command = strArg + " "
next

wshshell.run command, 0, false

iMail aliases.txt to csv converter.

This will convert iMails aliases.txt file to a csv to import into outlook or similar.

'Convert imail alias.txt to something that is not useless.

Const ForReading = 1, ForWriting = 2, ForAppending = 8 

Set filesys = CreateObject("Scripting.FileSystemObject")
Set filetxt = filesys.OpenTextFile("aliases.txt", ForReading) 

Set filetxtOUT = filesys.OpenTextFile("aliasesOUT.csv", ForWriting, TRUE) 
Set filetxtBAD = filesys.OpenTextFile("aliasesBAD.txt", ForWriting, TRUE) 

'get name
Set nameRegex = New RegExp
nameRegex.IgnoreCase = True
nameRegex.Pattern = """(.*?)"""

'get email
Set emailRegex = New RegExp
emailRegex.IgnoreCase = True
emailRegex.Pattern = "<(.*?)>"

filetxtOUT.WriteLine "Name, Email Address"
Do until filetxt.AtEndofStream
 txtline = filetxt.Readline
 
 'get name if 0 name is bad
 Set namevar = nameRegex.Execute(txtline)
 if namevar.Count = 0 then
  name = ""
 else
  name = namevar(0).Value
 end if

 'get email address if 0 email is bad
 Set emailvar = emailRegex.Execute(txtline)
 if emailvar.Count = 0 then
  email = ""
 else
  email = emailvar(0).Value
 end if

 'record bad lines to bad file
 if namevar.count = 0 AND emailvar.count = 0 then
  filetxtBAD.writeline txtline
 else
  if len(name) > 2 then
   filetxtOUT.writeline name & "," & email
  else
   filetxtOUT.writeline """" & name & """," & email
  end if
 end if
 
  
  
loop

filetxt.Close
msgbox "DONE"

Logon Tracker

This is the client part of a script that collects the username and computer name and sends it to a database for tracking purposes, when I find the server side of the script I will post that also.

#!/usr/bin/perl
#Grabs Certain local data and send it to an ICC database.

$user = $ENV{'USER'};
use Sys::Hostname;

use LWP::UserAgent; 
my $ua = new LWP::UserAgent;

my $response
= $ua->post('http://web.url.com/getlinfo.asp',
{ user => $user,
machine => hostname,
});

my $content = $response->content; 

Using perl to Parse AD’s UserAccountControl field

To parse the UserAccountControl field in Active Directory you have to use a bit-wise and of “&” and not “&&” to check the value. Below are some examples Here is a MSDN page that has more information.

This MS site also has more values listed.

#Check if the account is Disabled
$strStatus & 2

#Check if the account is Locked
$strStatus & 16

Serv-U Helm3 Quota Interface

'Serv-u Account Management
ver="V2.0"
'servudiskq.vbs

'Server Settings
'Helm SQL/MSDE Server Location
HelmDB="vicky\helm"

'Serv-U Domain Instance, this is located in the registry
SUDomain=1

'ServuDaemon File Location
ServuDaemon="C:\Program Files\Serv-U\ServUDaemon.ini"

'Operations: True is for enabled, Fales is for disabled.
'This will enabled writing the quota to the serv-u registry
SetQuota=True
'This will enabled or disabled the account based on the user account status
SetStatus=True

WScript.Echo "Serv-u Helm Qouta " & ver

'Check if Serv-U ini Exists.
Set filesys = CreateObject("Scripting.FileSystemObject")
If NOT filesys.Fileexists(ServUDaemon) Then
 wscript.echo "ERROR... ServuDaemon.ini does not exist"
 Set filesys = nothing
 wscript.quit(5)
end if

'Check for Servu-Domain In Registry
Set objShell = WScript.CreateObject("WScript.Shell")
SUDomainChk=""
On Error Resume Next
SUDomainChk=objShell.RegRead("HKLM\SOFTWARE\Cat Soft\Serv-U\Domains\DomainList\" & SUDomain)
On Error Goto 0
If SUDomainChk = "" Then
 wscript.echo "ERROR... Serv-U Domain Not Found"
 Set objshell = nothing
 wscript.quit(5)
end if

Set rsOBJ = CreateObject ("ADODB.Recordset")
strConnect = "Driver={SQL Server}; Server=" & HelmDB & "; Database=helmdb;"

'Open Helm
WScript.Echo "Connecting to Helm Database..."
rsOBJ.Open "Select FTPAccount.FTPUserName, COALESCE(HostDomain.CurrentDiskspaceUsage,0) AS CurrentDiskSpaceUsage, SUM(Limit.LimitValue) AS DSTotal, Account.AccountStatus From FTPAccount,HostDomain,Package, Limit, Account WHERE FTPAccount.DomainId=HostDomain.DomainId  AND HostDomain.PackageId = Package.PackageId  AND Limit.LimitPropertyId=3 AND Package.AccountNumber = Account.AccountNumber AND(Package.PackageTypeId=Limit.ItemId OR HostDomain.PackageId=Limit.ItemId) GROUP BY FTPAccount.FTPUserName, HostDomain.CurrentDiskspaceUsage, Account.AccountStatus", strConnect
Do While Not rsOBJ.EOF
 CurrentDiskSpace_Bytes=rsObj("CurrentDiskspaceUsage")
 
 'Error Checking
 WScript.Echo "Found User " & rsObj("FTPUserName") & " Used/Total " & FormatNumber(cstr(rsObj("CurrentDiskspaceUsage"))/1024) & "MB/" & FormatNumber(cstr(rsObj("DSTotal"))) & "MB"
 
 If rsObj("AccountStatus") = 0 Then
  wscript.echo vbTab & "Account is Enabled"
  If SetStatus Then
   objShell.RegWrite "HKLM\SOFTWARE\Cat Soft\Serv-U\Domains\" & SUDomain & "\UserSettings\" & rsObj("FTPUserName") & "\Enable", "1", "REG_SZ"
   wscript.echo vbTab & "Writing Account Status"
  else
   wscript.echo vbTab & "Skipping Status..."
  end if
 else 
  wscript.echo vbTab & "Account is Disabled"
  If SetStatus then
   objShell.RegWrite "HKLM\SOFTWARE\Cat Soft\Serv-U\Domains\" & SUDomain & "\UserSettings\" & rsObj("FTPUserName") & "\Enable", "0", "REG_SZ"
   wscript.echo vbTab & "Writing Account Status, Account Disabled"
  else
   wscript.echo vbTab & "Skipping Status..."
  end if
 end if    

 If SetQuota Then
  'Update Serv-U Registry
  SUQuota="1|" & cstr(rsObj("DSTotal"))*1048576 & "|" & cstr(rsObj("CurrentDiskspaceUsage"))*1024
  objShell.RegWrite "HKLM\SOFTWARE\Cat Soft\Serv-U\Domains\" & SUDomain & "\UserSettings\" & rsObj("FTPUserName") & "\DiskQuota", SUQuota, "REG_SZ"
  WScript.Echo vbTab & "Writing Serv-u Qouta for " & rsObj("FTPUserName")
 else
  Wscript.Echo vbTab & "Skipping Quota..."
 end if
 rsOBJ.MoveNext
loop

objShell.run "cmd /c echo ReloadSettings=True >> """ & ServuDaemon & """",0
Wscript.Echo "Forcing Serv-U to reload settings."
Wscript.echo "Done."

'Close Us Down
rsOBJ.Close
set rsObj = nothing
Set filesys = nothing
set objshell = nothing
WScript.quit

This is an OLD vb script that I wrote for HELM3 to read the FTP users and their quota from a SQL database and writes the data to the registry to enforce the quota from the FTP Server.

This is a Email to Google Calendar Quickadd gateway.

You can email a special address and it will take the subject of the email and send it to googles quickadd feature. This is a simple way to add events to your google calendar via email.
http://www.google.com/calendar
http://framework.zend.com/download/gdata
http://www.google.com/support/calendar/bin/answer.py?hl=en&answer=36604

  • You need to have Zend’s Gdata framework installed.
  • The first code example you need to add your google calendar information
  • the 2nd peice of code parses the email and calls the the quickadd function
  • In cpanel setup a forwarder and pipe it to a program of TOGcal.php
<?php //GoogleCal-Functions.php

require_once 'Zend/Loader.php';
Zend_Loader::loadClass('Zend_Gdata');
Zend_Loader::loadClass('Zend_Gdata_ClientLogin');
Zend_Loader::loadClass('Zend_Gdata_Calendar');

// Enter your Google account credentials
$email = '[email protected]';
$passwd = 'MyPass';
$ourCal = 'Cal Name';
$ourCalUrl = '';
try {
 $client = Zend_Gdata_ClientLogin::getHttpClient($email, $passwd, 'cl');
 }
catch(Zend_Gdata_App_AuthException $ex)
{
    echo "Unable to authenticate";
    exit(1);
 }

$cal = new Zend_Gdata_Calendar($client);

$calFeed = $cal->getCalendarListFeed();

foreach ($calFeed as $calendar)
{
    if ($calendar->title->text == $ourCal)
 {
  //$ourCalUrl = explode('/',$calendar->id);
  //$ourCalUrl = 'http://www.google.com/calendar/feeds/'. $ourCalUrl[6] . '/private/full';
  $ourCalUrl = $calendar->getSelfLink()->getHref() . '/private/full';
  $ourCalUrl = str_replace("default/", "",$ourCalUrl);
 }
 //echo $calendar->title->text . " || " . $calendar->getSelfLink()->getHref() . "
";
}
 //echo $ourCalUrl;
 //echo $client->getUri(true);
 //createQuickAddEvent ($client ,$ourCalUrl,'WO Test at Jun 2, 2008 8:00am - Jun 6, 2008 5:00pm');
 //createEvent($client,$ourCalUrl);

function createQuickAddEvent ($client, $URI = NULL, $quickAddText) {
  $gdataCal = new Zend_Gdata_Calendar($client);
  $event = $gdataCal->newEventEntry();
  $event->content = $gdataCal->newContent($quickAddText);
  $event->quickAdd = $gdataCal->newQuickAdd(true);

  $newEvent = $gdataCal->insertEvent($event,$URI);
  return $newEvent->id->text;
}

/**
 * Creates an event on the authenticated user's default calendar with the
 * specified event details.
 *
 * @param  Zend_Http_Client $client    The authenticated client object
 * @param  string           $title     The event title
 * @param  string           $desc      The detailed description of the event
 * @param  string           $where
 * @param  string           $startDate The start date of the event in YYYY-MM-DD format
 * @param  string           $startTime The start time of the event in HH:MM 24hr format
 * @param  string           $endDate   The end date of the event in YYYY-MM-DD format
 * @param  string           $endTime   The end time of the event in HH:MM 24hr format
 * @param  string           $tzOffset  The offset from GMT/UTC in [+-]DD format (eg -08)
 * @return string The ID URL for the event.
 */
function createEvent ($client, $URI = NULL, $title = 'Tennis with Beth', $desc='Meet for a quick lesson', $where = 'On the courts',$startDate = '2008-06-20', $startTime = '9:00',$endDate = '2008-06-20', $endTime = '14:00', $tzOffset = '-04')
{
  $gc = new Zend_Gdata_Calendar($client);
  $newEntry = $gc->newEventEntry();
  $newEntry->title = $gc->newTitle(trim($title));
  $newEntry->where  = array($gc->newWhere($where));

  $newEntry->content = $gc->newContent($desc);
  $newEntry->content->type = 'text';

  $when = $gc->newWhen();
  $when->startTime = "{$startDate}T{$startTime}:00.000{$tzOffset}:00";
  $when->endTime = "{$endDate}T{$endTime}:00.000{$tzOffset}:00";
  $newEntry->when = array($when);

  echo $URI."||".$title."||".$desc."||".$where."||".$startDate."||".$startTime."||".$endDate."||".$endTime."||".$tzOffset;
  $createdEntry = $gc->insertEvent($newEntry, $URI);
  return $createdEntry->id->text;
}
?>
#!/usr/bin/php -q
<?php
//TOGcal.php
//Takes the subject and uses quickadd to create an event.
include "GoogleCal-Functions.php";

$msg = "";
$email ='';
$fd = fopen("php://stdin", "r");
while (!feof($fd))
{
 $email .= fread($fd, 1024);
}
fclose($fd);
$msg .= "got Email || ";

$mail = mailparse_msg_create();
mailparse_msg_parse($mail,$email);
$struct = mailparse_msg_get_structure($mail);
$section = mailparse_msg_get_part($mail, "1");
$info = mailparse_msg_get_part_data($section);

$msg .= $info['headers']['from'] . " || " . $info['headers']['subject']  . " || ";

//valid sending domains
if (preg_match('/@mydomain\.com/', $info['headers']['from']))
{
 createQuickAddEvent($client,$ourCalUrl,$info['headers']['subject']);
 $msg .= "regex matched || ";
} 
mailparse_msg_free($mail);

//emailError($msg);


?>