Getting IP address by using AWK

The AWK utility is a data extraction and reporting tool that uses a data-driven scripting language consisting of a set of actions to be taken against textual data (either in files or data streams) for the purpose of producing formatted reports.

ifconfig | awk '/inet addr:.* B/ {split($2,a,":"); print a[2] }'
Advertisements

Get Spot Price History by using aws-lib

We are going to get the pricing history for t1.micro instances by using aws-lib (Extensible Node.js library for the Amazon Web Services API):

var aws = require("aws-lib");
var ec2 = aws.createEC2Client(accessKeyId, secretAccessKey);
var iType = 't1.micro';
ec2.call('DescribeSpotPriceHistory', {'InstanceType.1':iType}, function(result) {
    console.log(result.spotPriceHistorySet.item); 
  } 
);

PowerShell: Wait for SQL Server is ready for client connections

The useful PowerShell script waiting SQL server is ready.
I found that waiting for starting service

while((get-service MSSQL`$INSTANCENAME).Status -ne 'Running'){Sleep 3}

is not enough.
Better to check the event log entry EventID = 17126: SQL Server is now ready for client connections. This is an informational message; no user action is required.

$ew = new-object system.management.ManagementEventWatcher                                                         
$ew.query = "Select * From __InstanceCreationEvent Where TargetInstance ISA 'Win32_NTLogEvent'"                   
while(!(get-eventlog -logname 'Application' -Source 'MSSQL$INSTANCENAME' | ? {$_.EventId -eq 17126})){
	$ew.WaitForNextEvent()
}