MoonPoint Support Logo

 

Shop Amazon Warehouse Deals - Deep Discounts on Open-box and Used ProductsAmazon Warehouse Deals



Advanced Search
August
Sun Mon Tue Wed Thu Fri Sat
   
   
2017
Months
Aug


Sun, Aug 27, 2017 11:14 pm

Displaying date and time information on a Microsoft Windows system

You can use the date and time commands on a Microsoft Windows system to display current date and time information:

C:\Users\Lila>date /t
Sat 08/26/2017

C:\Users\Lila>time /t
02:07 PM

C:\Users\Lila>

Placing /t after the commands results in the current date and time information being displayed without an accompanying prompt to change the current settings.

You can display the information in a different format using the Windows Management Instrumentation Command-line (WMIC) command shown below:

C:\Users\Lila>wmic path win32_utctime get * /format:list


Day=26
DayOfWeek=6
Hour=18
Milliseconds=
Minute=16
Month=8
Quarter=3
Second=19
WeekInMonth=4
Year=2017




C:\Users\Lila>

[ More Info ]

[/os/windows/commands] permanent link

Sat, Aug 26, 2017 9:29 pm

Querying a MariaDB or MySQL database using Python

On a CentOS Linux system, I have a MariaDB (MariaDB is a fork of MySQL) database named "Books" that contains a table named "Amazon" where I've stored information on books that includes their Amazon Standard Identification Number (ASIN). I want to be able to run a Python script to which I provide a word as a command line argument and have the script find all books in that database table that have a title containing that word and to print the title, which is stored in a column named "Description" along with the ASIN, which is stored in a column named "ASIN". To do so, I use a script with the following code:

#!/usr/bin/python

import mysql.connector, sys

def executeSQL(conn, queryTerm):
    cursor = conn.cursor()
    query = "select ASIN, Description from Amazon where Description like " + queryTerm
    cursor.execute(query)
    result = cursor.fetchall()    
    for row in result:
       print row[0], row[1]

hostname = 'localhost'
username = 'myAcctName'
password = 'ThePassword'
database = 'Books'

try:
   sys.argv[1]
except IndexError:
   print "Error - missing query word! Usage ./findBook queryWord"
   sys.exit(1)
else:
   queryWord = "'%" + sys.argv[1] + "%'" 

connection = mysql.connector.connect( host=hostname, user=username, passwd=password, db=database )
executeSQL(connection,queryWord)
connection.close()

[ More Info ]

[/languages/python] permanent link

Fri, Aug 25, 2017 11:11 pm

Wireshark - bandwidth usage and bytes by protocol

The free and open source packet analysis tool Wireshark provides many capabilities for analyzing network traffic. Among its capabilities is the capability to provide statistical information regarding captured network traffic. Looking at a pcap file with Wireshark for traffic captured during a data flow test, I saw what seemed to be a fair amount of Simple Network Management Protocol (SNMP) and Secure Shell (SSH) traffic with systems on an external network. I wanted to determine the actual percentage that traffic represented within the overall traffic during the test period. Fortunately, that is easy to do within Wireshark. One way to view statistics on bandwidth utilization by protocol while viewing captured data is by clicking on Statistics then selecting Protocol Hierarchy. Note: you may need to wait a little while for the statistics to be displayed if the amount of data to be processed is large.

[ More Info ]

[/network/tools/sniffing/wireshark] permanent link

Thu, Aug 24, 2017 11:01 pm

Firefox - Detect Captive Portal

When you start the Firefox web browser, it will attempt to determine if the network connection available to it when it starts is via a captive portal. If you use a hotel's Wi-Fi service, a free WiFi service provided by a restaurant or other business, or some other public WiFi service, when you first open your browser you may see a web page asking you to accede to terms of service, an acceptable use policy, or to provide some authentication information, e.g., perhaps your name and room number for a hotel, or to provide payment information if you are accessing a wireless service that is not free. You won't be able to go elsewhere on the web, at least not easily, until you deal with the demands/conditions specified on the captive portal page.

Firefox makes a determination on whether there is a captive portal constraint by attempting to download the file success.txt from http://detectportal.firefox.com/success.txt (there is only one word in that file, the word "success". If it can successfully retrieve that file, it can assume that it is not constrained by a captive portal. You can see such attempts using the free and open-source (FOSS) Wireshark packet analyzer utility by specifying a filter of "http.request.method == "GET".

[ More Info ]

[/network/web/browser/firefox] permanent link

Wed, Aug 23, 2017 11:36 pm

Determining a file's type from within a Python script

I needed a way to determine a file's type within a Python script when I can't rely on the file's extension to determine the file format. I'll be running the script on a MacBook Pro laptop running the OS X El Capitan operating system. OS X/macOS, like Linux, comes with the file command, so I could run that command at a shell prompt to have the utility check the magic number in the files I'm interested in, but I want to do some additional processing of the files within the Python script, so I want to perform the format check within Python. Python provides the subprocess module that provides the capability to "spawn new processes, connect to their input/output/error pipes, and obtain their return codes." So I can call the file utility from within Python using that module. To get the results from running a shell command, you use suprocess.Popen(). You can then set a variable to hold the results of .communicate() and print the contents of that variable as shown below. The script expects the name of the file to be checked to be provided as an argument on the command line.

#!/usr/bin/python

import subprocess as sub, sys

try:
   sys.argv[1]
except IndexError:
   print "Error - missing input file name! Usage ./filetype.py infile"
   sys.exit(1)
else:
   fileName = sys.argv[1]

p = sub.Popen(['file',fileName],stdout=sub.PIPE,stderr=sub.PIPE)
output, errors = p.communicate()
print output

[ More Info ]

[/languages/python] permanent link

Tue, Aug 22, 2017 11:18 pm

Signing out of Amazon on a system with a low resolution display

Sometimes I encounter difficulties signing out of an account on Amazon's website when I need to sign into another account, if the resolution of the display isn't great enough to allow me to see the bottom of Amazon's list of choices where the sign out option appears. If I need to logon on such a system, there's no problem. If I visit Amazon's home page, I can click on "Hello. Sign in Accounts & Lists" where I see a "Sign in" button.

Amazon account and lists

[ More Info ]

[/network/web/shopping] permanent link

Mon, Aug 21, 2017 11:15 pm

Find all occurrences of a string in a file using Python

I need to download and view Excel workbooks, Portable Document Format (PDF), and sometimes other types of documents related to work requests from a website. When I view a webpage for a particular work request, some of the documents may have been posted weeks or months ago while some are more recent, but when I download them they all get the timestamp of the time I downloaded them, but I would like to change the timestamps to match the timestamps on the website. On the webpage for a particular work request, I see the following information for files:

Type Name Site Modified Modified By
xlsm icon CRQ000000884164_PDSO -None- 3/6/2017 4:53 PM Smith, Gary
pdf icon CRQ000000884164_PDSO -None- 3/6/2017 4:52 PM Smith, Gary
pdf icon CRQ000000884164_DCS -None- 6/12/2017 9:29 AM Doe, Mike
xlsm icon CRQ 884164_SDP -None- 6/12/2017 9:30 AM Doe, Mike

[ More Info ]

[/languages/python] permanent link

Sun, Aug 20, 2017 10:05 pm

Remotely Restarting Windows Services or Systems

After a power outage, I found I was unable to connect to a Microsoft Windows 10 system from a Windows Server 2012 system on the local area network (LAN) using the Remote Desktop Protocol (RDP). When I tried to connect, I saw the message "Remote Desktop can't connect to the remote computer for one of these reasons..."

Remote Desktop Connection - can't connect

I knew the system had rebooted after the power outage, because I could ping it and see its shared folders using the command net view systemName where systemName is the system's name.

[ More Info ]

[/os/windows] permanent link

Fri, Aug 18, 2017 10:41 pm

Importing data from a text file into an SQLite database with Python

I need to track work requests that are associated with particular projects. The work requests are submitted through a website, but I want to be able to run queries on the data that aren't available to me from the website. So I decided to add a projects table to an existing SQLite database I have on my MacBook Pro laptop. I didn't want to manually enter a list of about 200 projects into the table, however, so I copied the projects list from the website into a text file. The webpage that lists all of the projects includes projects that are no longer valid and I want to include those in my database table, but note that they are longer valid. When I copy the data from the web page, I have lines like the following ones:

450 SN/GN Tech  Edit Delete
ACE     Edit Delete
ADO     Edit Undelete
AGO     Edit Delete
AGS     Edit Delete
AIM     Edit Delete
Artemis         Edit Undelete
ASF     Edit Delete
ATSC    Edit Undelete
AXAF    Edit Undelete
BATSE/Gro       Edit Undelete
CANDOS  Edit Undelete
CARA    Edit Delete
CD Manager      Edit Delete
CMF     Edit Undelete
CMOC    Edit Delete
CMS     Edit Undelete

The entries that are no longer valid have "Undelete" at the end of the line indicating the projects were deleted, but they can be undeleted.

I created a table in the database with the following columns all of which contain text data:

NameDescription AddedRemoved DeletedNotes

[ More Info ]

[/languages/python] permanent link

Thu, Aug 17, 2017 11:09 pm

Obtaining information on a system's motherboard with PowerShell

You can obtain information on the motherboard in a computer running Microsoft Windows using PowerShell by means of the Get-Ciminstance cmdlet with the command Get-Ciminstance Win32_Baseboard. E.g., the following example is from a Microsoft Windows 10 system.

PS C:\> get-ciminstance win32_baseboard


Manufacturer : Gigabyte Technology Co., Ltd.
Model        :
Name         : Base Board
SerialNumber :
SKU          :
Product      : GA-78LMT-S2P



PS C:\>

The manufacturer, model number, serial number, SKU, and product number will be displayed if that information can be queried from the motherboard. Note: not all parameters will be available for every motherboard as shown above. For another system, the serial number is available.

PS C:\> get-ciminstance win32_baseboard


Manufacturer : Dell Inc.
Model        :
Name         : Base Board
SerialNumber : .7XCTZ12.CN7016346F0331.
SKU          :
Product      : 088DT1



PS C:\>

You can restrict the displayed information to particular parameters by piping the output to select-object. E.g.:

PS C:\> get-ciminstance win32_baseboard | select-object manufacturer

manufacturer
------------
Gigabyte Technology Co., Ltd.


PS C:\> get-ciminstance win32_baseboard | select-ojbect manufacturer, product

manufacturer                  product
------------                  -------
Gigabyte Technology Co., Ltd. GA-78LMT-S2P


PS C:\>

Another command line alternative to using PowerShell is to use WMIC to determine motherboard information.

[/os/windows/PowerShell] permanent link

Wed, Aug 16, 2017 10:59 pm

Recovering a Comic Life file

My wife uses Comic Life 3 from Plasq. On a couple of occasions recently, when she was using the program on one Microsoft Windows 10 system while editing a Comic Life file stored on another Windows 10 system, when she tried to save the file over the local area network (LAN) to the other system, she saw "Finalizing Save. Please Wait." but the save operation didn't complete.

Comic Life 3 finalizing save

After a long period of time had gone by, I finally rebooted the system on which Comic Life was running, since I couldn't kill it with the Windows Task Manager. Fortunately, all of her work was not lost, however. When I checked the system on which the Comic Life file was stored, I saw a file with a comiclife.latest extension in addition to the one with the .comiclife extension Comic Life uses for files.

C:\> dir "C:\Users\Public\2017\08\2017-08-18\*comiclife*"
 Volume in drive C has no label.
 Volume Serial Number is 5C60-1B61

 Directory of C:\Users\Public\2017\08\2017-08-18

08/15/2017  12:34 PM        40,099,848 Week33.comiclife
08/15/2017  12:51 PM        48,691,208 Week33.comiclife.latest
               2 File(s)     88,791,056 bytes
               0 Dir(s)  2,766,325,518,336 bytes free

C:\>

I moved the file with the .comiclife extension to another directory and renamed the Week33.comiclife.latest file to Week33.comiclife - I received the normal warning Windows displays when changing a filename extension, but proceeded.

Warning for changing file extension

I was then able to open the renamed file in Comic Life and recover the latest changes she had made to the file. This is the second time I've had to go through this process to recover her work in Comic Life due to Comic Life not completing the "finalizing save" step, but the incidences may have been due to a network issue.

[/software/comics/comiclife] permanent link

Tue, Aug 15, 2017 10:07 pm

Saving an email message to a file in mutt

Mutt is a text-based email client for Linux and Unix-like systems. If you want to save a particular message to a file in mutt, you can select the message then hit the v (the lowercase letter) key. In mutt, the letter is used for "view-attachments", but you can also use it to save the body of an email message to a file. If you hit the s key with the message selected or while viewing the message, you will see "<no description>" next to the number 1. If the email has any attachments they will be numbered from 2 upwards. With the first entry, i.e. the one labeled "<no description>" selected, if you hit the letter s (lowercase letter), you will see "Save to file:"

Mutt - save to file

Type the file name you wish the message to be saved under after "Save to file:" After saving the file, you can hit q several times to get back to the shell prompt. The message will be in the current directory. The file will only contain the contents of the message, not the message header, i.e., you won't see from, to, and subject lines.

[/network/email/clients/mutt] permanent link

Sun, Aug 13, 2017 10:24 pm

Symantec OCSP - gn.symcd.com

I opened HTTPNetworkSniffer, a packet capture tool developed by Nir Sofer and available from his NorSoft site, today on a Microsoft Windows system. While it was open I visited this website using the Firefox browser on the system and happened to switch back to the HTTPNetworkSniffer window where I noticed an unexpected connection to gn.symcd.com.

HTTPNetwork Sniffer - gn.symcd.com

[More Info ]

[/network/ocsp] permanent link

Sat, Aug 12, 2017 11:03 pm

Using SFC to troubleshoot missing or corrupted system files on Windows Vista

The System File Checker (SFC) tool (sfc.exe) will check the operating system for missing or corrupted files. To use the tool on a Windows Vista system, take the following steps:
  1. Obtain a command prompt by clicking on the Windows logo button normally at the lower left-hand corner of the screen, then select Programs, Accessories, right-click on Command Prompt and choose "Run as administrator". When prompted for permission to continue, click on the Continue button.
  2. At the command prompt, type the command sfc /scannow and hit Enter.

At the conclusion of the scanning process, you will be informed whether any problems were detected.

C:\Windows\system32>sfc/scannow

Beginning system scan.  This process will take some time.

Beginning verification phase of system scan.
Verification 100% complete.

Windows Resource Protection did not find any integrity violations.

C:\Windows\system32>

If there were problems that could not be repaired, you can find information on them by checking the log file produced by the System File Checker tool. The log file is %windir%\Logs\CBS\CBS.log. On most systems, %windir% will be C:\Windows. Typing echo %windir% at a command prompt will show you the directory for the variable. You can open the file in Notepad by typing the command notepad %windir%\Logs\CBS\CBS.log at the command prompt you got by following the steps above.

Or you can use the following steps To determine which files could not be repaired by the System File Checker tool:

  1. Obtain a command prompt with administrator privileges as above by right-clicking on Command Prompt, which is found under Programs then Accessories, and choosing "Run as administrator."
  2. Then type the command findstr /c:"[SR]" %windir%\Logs\CBS\CBS.log >%userprofile%\Desktop\sfcdetails.txt and hit Enter. That will extract relevant entries from the CBS.log file and place them in the file sfcdetails.txt on the Desktop of the user account you are using when you run the command.

    Microsoft Windows [Version 6.0.6002]
    Copyright (c) 2006 Microsoft Corporation.  All rights reserved.
    
    C:\Windows\system32>
    
    Microsoft Windows [Version 6.0.6002]
    Copyright (c) 2006 Microsoft Corporation.  All rights reserved.
    
    C:\Windows\system32>findstr /c:"[SR]" %windir%\Logs\CBS\CBS.log >%userprofile%\D
    esktop\sfcdetails.txt

Note The Sfcdetails.txt file contains details from every time that the System File Checker tool has been run on the computer. The file includes information about files that were not repaired by the System File Checker tool. Verify the date and time entries to determine the problem files that were found the last time that you ran the System File Checker tool. You can find the file on the Windows desktop or click on the Windows Start button, select Search, then For Files or Folders, then type sfcdetails.txt in the search field to search for the file.

References:

  1. How to use the System File Checker tool to troubleshoot missing or corrupted system files on Windows Vista or on Windows 7
    Microsoft Support

[/os/windows/vista] permanent link

Fri, Aug 11, 2017 8:42 pm

Using SQL Inner Join

I have an SQLite database stored on my MacBook Pro laptop that I use to track work requests. The database file is named CRQ.db, since it tracks work done under a Change Request (CRQ). Within that database are several tables two of which are "Equipment" and "Device". For every CRQ that I need to deal with, I store information on equipment that is affected by the CRQ. The equipment table has the following structure:

NameType
CRQText
DeviceText
ProjectText
NotesText

The device field holds a unique name assigned to the particular device. A device may be affected by more than one CRQ, so it can, potentially, occur multiple times in the table. A CRQ can affect multiple pieces of equipment.

The device table has the following structure:

NameType
DescriptionText Unique
ManufacturerText
ModelText
SiteText
BuildingText
RoomText
NotesText

[ More Info ]

[/software/database/sql] permanent link

Thu, Aug 10, 2017 9:26 pm

Using PowerShell to obtain process information

You can use the Get-CimInstance cmdlet at a PowerShell prompt to obtain information on processes running on a Microsoft Windows system. E.g., to see a list of all the processes currently running on a system, the command gcim win32_process can be used; gcim is an alias for Get-CimInstance, so you can use the shorter alias or Get-CimInstance. The name of the process, its process identifier (PID), handle count, working set size, and virtual memory size are displayed.

[ More Info ]

[/os/windows/PowerShell] permanent link

Wed, Aug 09, 2017 10:26 pm

Installing the Evernote extension for Microsoft Edge

If you wish to be able to save webpages with the Evernote web clipper inside the Microsoft Edge browser, you can install the Evernote extension using the following steps:
  1. Inside the Edge browser, click on the row of 3 dots that appears at the upper, right-hand corner of the browser window.
  2. Select Extensions.
  3. Then click on Get extensions from the Store.
  4. Look for Evernote in the list of extensions and click on it to install the Evernote extension for Edge.
  5. You will then see details on the extension, which is free. Click on Get.
  6. Once it is installed, you can click on the Launch button.

[ More Info ]

[/network/web/browser/edge] permanent link

Tue, Aug 08, 2017 8:39 pm

Windows 10 stuck on scanning and repairing drive

To check on a potential file system corruption issue on a Microsoft Windows 10 system, I opened a command prompt window with administrator privileges and used the chkdsk command to check and repair the file system on drive C with chkdsk /r c:. The chkdsk operation got to "Scanning and repairing drive (C:): 10% complete", but then stayed there for hours. I finally powered the system off and on again which prompted it to restart the drive scan again. It quickly got to the 10% point again and then, again, stayed there, so I powered the system off and on again. When I powered the system off and on again, I saw "Preparing automatic repair" and then "Diagnosing your PC." I then saw the following:

Automatic Repair

Your PC did not start correctly

Press "Restart" to restart your PC, which can sometimes fix the problem. You can also press "Advanced options" to try other options to repair your PC.

 

I clicked on Advanced options which led to a "Choose an option" display where I could choose from the following options:

Choose an option

I clicked on Continue. I then saw a message advising I could skip the disk check by pressing the space key within a number of seconds that counted downwards; I hit the space bar before it got to zero and the system rebooted normally.

[/os/windows/win10] permanent link

Sun, Aug 06, 2017 5:05 pm

COUNTIF incompatibility between OpenOffice Calc and Microsoft Excel

I have an Apache OpenOffice Calc spreadsheet that I use to track deposits to bank accounts. I loaned a friend money some time ago for a used car; when I get a check from him, I note it in a worksheet in the Calc workbook. I also get checks from him sometimes unrelated to the auto loan repayment and have received some checks that include the auto loan payment plus reimbursement for other expenses. I have a "note" column in the worksheet where I'll always have "75", if the check applies to the auto loan repayment, though there may be other text before and after the "75" in the cell. So I thought it would be easy to count the number of checks I've received from him that apply to the auto loan repayment by using the formula below, since the note column is column F and the deposits start in row 2 (the first row is a heading line) and go through row 32:

=COUNTIF(F2:F32,"*75*")

That works in Microsoft Excel, but it doesn't work in OpenOffice Calc (I'm using version 4.1.1). The count is always zero, if I use the formula above. I found I have to use the formula below, instead, which correctly reports 21 occurrences of 75 in column F at the moment:

=COUNTIF(F2:F32;".*75.*")

Excel will treat the first asterisk as representing a character or any number of characters before the "75" and the asterisk after "75" as representingany number of characters appearing in the cell after "75". However, Calc doesn't view the asterisks that way. Instead, I need to use a regular expression. In a regular expression (regexp), a period represents any character and an asterisk represents zero or more occurrences of the preceding element. For example, ab*c matches "ac", "abc", "abbc", "abbbc", and so on. So the ".*" represents any character appearing zero or more times in the cell. If I try using the formula I use in Calc in Excel, it will report zero occurrences just as Calc reports zero occurrences when I use the formula that works in Excel in Calc.

Since I want to obtain the total amount he has repaid so far, which is the count of the number of occurrences of 75 in column F by $75, I use the forumula below in Calc to obtain that amount, which returns 1575 as of today:

=COUNTIF(F2:F32;".*75.*") * 75

[/software/openoffice] permanent link

Sat, Aug 05, 2017 10:47 pm

List Installed Security Patches with PowerShell

If you want to know which security patches were installed on a Microsoft Windows system within a specific time period, e.g., the last month or the last 3 months, you can use a Get-CimInstance command in a PowerShell window. E.g.:

PS C:\Users\Lila> Get-CimInstance -Class win32_quickfixengineering | Where-Object { $_.InstalledOn -gt (Get-Date).AddMonths(-1) }

Source        Description      HotFixID      InstalledBy          InstalledOn
------        -----------      --------      -----------          -----------
              Security Update  KB4025376     NT AUTHORITY\SYSTEM  7/12/2017 12:00:00 AM
              Security Update  KB4025342     NT AUTHORITY\SYSTEM  7/12/2017 12:00:00 AM


PS C:\Users\Lila> Get-CimInstance -Class win32_quickfixengineering | Where-Object { $_.InstalledOn -gt (Get-Date).AddMonths(-3) }

Source        Description      HotFixID      InstalledBy          InstalledOn
------        -----------      --------      -----------          -----------
              Security Update  KB4020821     NT AUTHORITY\SYSTEM  6/17/2017 12:00:00 AM
              Update           KB4021572     NT AUTHORITY\SYSTEM  6/17/2017 12:00:00 AM
              Update           KB4022405     NT AUTHORITY\SYSTEM  6/17/2017 12:00:00 AM
              Security Update  KB4025376     NT AUTHORITY\SYSTEM  7/12/2017 12:00:00 AM
              Security Update  KB4025342     NT AUTHORITY\SYSTEM  7/12/2017 12:00:00 AM


PS C:\Users\Lila>

[ More Info ]

[/os/windows/PowerShell] permanent link

Fri, Aug 04, 2017 10:51 pm

Calculating working days in PHP

I have an SQLite database that I use to track work requests. Some requests are time sensitive, i.e. they need to be completed within a certain number of days from the time they are approved. So I have an "Approved" and an "Implemented" column in the database to record the date I approved a request and the date it was implemented. All requests should be completed within 5 business days, so when I display the data on a webpage with PHP, I want to see the number of elapsed working days between the time I approved a request and the time it was implemented. To do so, I use some code provided by George John at Calculate business days with a slight modification. The code I use appears below:

function getWorkingDays($startDate, $endDate)
{
    $begin = strtotime($startDate);
    $end   = strtotime($endDate);
    if ($begin > $end) {

        return 0;
    } else {
        $no_days  = 0;
        while ($begin <= $end) {
            $what_day = date("N", $begin);
            if (!in_array($what_day, [6,7]) ) // 6 and 7 are weekend
                $no_days++;
            $begin += 86400; // +1 day
        };

        return $no_days - 1;
    }
}

[ More Info ]

[/languages/php] permanent link

Valid HTML 4.01 Transitional

Privacy Policy   Contact

Blosxom logo