Sunday, June 29, 2014

Mastering Windows 7 enterprise zero-touch installation

This is third edition of mastering windows 7 zero touch installation
Here is the first one. In the second tutorial i found out how to run RunOnce commands:

The third edition uses Windows 7 enterprise evolution.
This edition with trial key entered you can use for 90-days.
Later you can reset trial to use another 90 days. And another 90 days. And another..

Here is 64-bit image:
http://care.dlservice.microsoft.com/dl/download/evalx/win7/x64/EN/7600.16385.090713-1255_x64fre_enterprise_en-us_EVAL_Eval_Enterprise-GRMCENXEVAL_EN_DVD.iso
1d0d239a252cb53e466d39e752b17c28
15ddabafa72071a06d5213b486a02d5b55cb7070

Here is 32-bit image:
http://care.dlservice.microsoft.com/dl/download/evalx/win7/x86/EN/7600.16385.090713-1255_x86fre_enterprise_en-us_EVAL_Eval_Enterprise-GRMCENEVAL_EN_DVD.iso
62675a3b76d21815367f372961b71a56
971fc00183a52c152fe924a6b99fdec011a871c2

Use universal usb installer to push he image to USB drive
https://googledrive.googledrive.com/host/0BxmEiwnrWfmmSHh2bkg2OWRMYWc/Universal-USB-Installer-1.9.5.2.exe

Open USB root drive and go to sources

Create a sub-folders $OEM$\$$\Setup\Scripts

Go to scripts directory and create FirstRun.cmd that contains:
for %%i in (b c d e f g h i j k l m n o p q r s t u v w x y z) do (
if exist %%i:\FirstRun\FirstRun.bat %%i:\FirstRun\FirstRun.bat
)

Go to USB root and create Folder FirstRun

This is my example FirstRun.bat file. Do not blindly copy it! You can create you own and figure out to edit fields.
@echo off
set path=%path%;%~dp0

echo Stop Windows Update service
net stop wuauserv

powercfg -setactive 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c
powercfg -setacvalueindex 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c 7516b95f-f776-4464-8c53-06167f40cc99 3c0bc021-c8a8-4e07-a973-6b14cbcb2b7e 0

echo Diasable hide system tray icons
reg delete "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer" /v EnableAutoTray /f > nul 2>&1
reg add "HKLM\Software\Microsoft\Windows\CurrentVersion\Explorer" /v EnableAutoTray /t REG_DWORD /d 0 /f > nul 2>&1

echo Turn On [Open Command windows here from Right Click]
reg delete "HKCR\Drive\shell\cmd" /v "Extended" /f > nul 2>&1
reg delete "HKCR\Directory\shell\cmd" /v "Extended" /f > nul 2>&1
reg delete "HKCR\Directory\Background\shell\cmd" /v "Extended" /f > nul 2>&1

echo Remove action center icon
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer" ^
/v HideSCAHealth /t REG_DWORD /d 1 /f


echo Hibernate Off
powercfg -h off > nul 2>&1

echo Notepad++
for /f %%a in ('dir /b "%~dp0npp\npp.*.Installer.exe"') do start /wait "" "%~dp0npp\%%a" /S

echo .NET 4
start /wait "" "%~dp0dotnet\dotNetFx40_Full_x86_x64.exe" /q /norestart

echo VirtualBox
pushd "%~dp0"
cd "%~dp0VirtualBox"
certutil -addstore "TrustedPublisher" oracle-vbox.cer > nul 2>&1
for /f %%a in ('dir /b "%~dp0VirtualBox\*.msi"') do msiexec /i "%~dp0VirtualBox\%%a" /qn
popd

echo ClipX
for /f %%a in ('dir /b "%~dp0ClipX\clipx-*-setup.exe"') do start /wait "" "%~dp0ClipX\%%a" /S
if not ("%ProgramFiles(x86)%"=="") (
set pf=%programfiles(x86)%
) else set pf=%programfiles%
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Run" /v ClipX /t reg_sz /d "\"%pf%\ClipX\clipx.exe\"" /f

for /f %%a in ('dir /b "%~dp0SumatraPDF\SumatraPDF-*-install.exe"') do start /wait "" "%~dp0SumatraPDF\%%a" /S

echo Java Runtime Environment
for /f %%a in ('ls -d "%~dp0JRE\*" ^| grep -v "x64"') do for /f %%b in ('dir /b "%%a\*.msi"') do msiexec /i %%a\%%b /qn
for /f %%a in ('ls -d "%~dp0JRE\*" ^| grep "x64"') do for /f %%b in ('dir /b "%%a\*.msi"') do msiexec /i %%a\%%b /qn

echo WinRAR
for /f %%a in ('dir /b "%~dp0WinRAR\*.exe"') do "%~dp0WinRAR\%%a" /S

echo Firefox
for /f "tokens=*" %%a in ('dir /b "%~dp0Firefox\*.exe"') do echo "%~dp0Firefox\%%a" /S

echo HandBrake
for /f %%a in ('dir /b "%~dp0HandBrake\HandBrake-*-x86_64-Win_GUI.exe"') do start /wait "" "%~dp0HandBrake\%%a" /S

echo RAM Disk
start /wait "" "%~dp0ramdisk\ramdisk_setup.exe" /SILENT

echo ImgBurn
for /f %%a in ('dir /b "%~dp0ImgBurn\*.exe"') do "%~dp0ImgBurn\%%a" /S

echo Google Chrome
for /f %%a in ('dir /b "%~dp0Chrome\*.msi"') do msiexec /i "%~dp0Chrome\%%a" /qn

echo Launchy
"%~dp0\Launchy\Launchy.exe"

echo Cisco VPN Client
pushd "%~dp0"
cd "%~dp0vpnclient"
msiexec /i vpnclient_setup.msi /qn /norestart
popd

echo Apostrofs
pushd "%~dp0"
cd "%~dp0apostrofs-punkts"
msiexec /i Apos_amd64.msi /qn
popd

echo Daemon Tools Lite
for /f %%a in ('dir /b "%~dp0DaemonToolsLite\*.exe"') do "%~dp0DaemonToolsLite\%%a" /S /nogadget /sptd

echo 7-zip
for /f %%a in ('dir /b "%~dp07-zip\*.msi"') do msiexec /i "%~dp07-zip\%%a" /qn

net stop wuauserv
rd %systemroot%\SoftwareDistribution /Q /S

echo Windows Updates
pushd "%~dp0"
cd "%~dp0wsusoffline\client\cmd"
DoUpdate.cmd
popd
In the last step i use folder name wsusoffline to prepare update installing using www.wsusoffline.net service

grep.exe and ls.exe is needed if you want to include JRE installation via msi file

As you can see the commands are quite flexible so you can create a folder Firefox and inside FirsRun directory and place latest firefox installer.
You can create Handbrake directory and place latest Handbrake installer inside

Here is autounattend.xml. It is ready for boot 32-bit and 64-bit systems. I cut out the part about automatically delete all partitions without prompting but if you are interested in the read Windows 7 Enterprise autounattend.xml
<?xml version="1.0" encoding="utf-8"?>
<unattend xmlns="urn:schemas-microsoft-com:unattend">
    <settings pass="windowsPE">
        
 <component name="Microsoft-Windows-International-Core-WinPE" processorArchitecture="x86" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
            <SetupUILanguage>
                <UILanguage>en-US</UILanguage>
            </SetupUILanguage>
            <InputLocale>en-US</InputLocale>
            <SystemLocale>en-US</SystemLocale>
            <UILanguage>en-US</UILanguage>
            <UserLocale>en-US</UserLocale>
        </component>
  
 <component name="Microsoft-Windows-International-Core-WinPE" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
            <SetupUILanguage>
                <UILanguage>en-US</UILanguage>
            </SetupUILanguage>
            <InputLocale>en-US</InputLocale>
            <SystemLocale>en-US</SystemLocale>
            <UILanguage>en-US</UILanguage>
            <UserLocale>en-US</UserLocale>
        </component>
  
        <component name="Microsoft-Windows-Setup" processorArchitecture="x86" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
            <DiskConfiguration>
                <Disk wcm:action="modify">
                    <CreatePartitions>
                        <CreatePartition wcm:action="modify">
                            <Order>1</Order>
                            <Type>Primary</Type>

                        </CreatePartition>
                    </CreatePartitions>
                    <ModifyPartitions>
                        <ModifyPartition wcm:action="modify">
                            <Active>true</Active>
                            <Format>NTFS</Format>
                            <Order>1</Order>
                            <PartitionID>1</PartitionID>
                            <Extend>false</Extend>
                        </ModifyPartition>
                    </ModifyPartitions>
                    <DiskID>0</DiskID>
                    <WillWipeDisk>true</WillWipeDisk>
                </Disk>
                <WillShowUI>OnError</WillShowUI>
            </DiskConfiguration>
            <ImageInstall>
                <OSImage>
                    <InstallTo>
                        <DiskID>0</DiskID>
                        <PartitionID>1</PartitionID>
                    </InstallTo>
                    <WillShowUI>OnError</WillShowUI>
                    <InstallFrom>
                        <MetaData wcm:action="add">
                            <Key>/IMAGE/NAME</Key>
                            <Value>Windows 7 ENTERPRISE</Value>
                        </MetaData>
                    </InstallFrom>
                </OSImage>
            </ImageInstall>
            <UserData>
                <AcceptEula>true</AcceptEula>
                <FullName></FullName>
                <Organization></Organization>
                <ProductKey>
                    <WillShowUI>Never</WillShowUI>
                </ProductKey>
            </UserData>
        </component>
  
 <component name="Microsoft-Windows-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
            <DiskConfiguration>
                <Disk wcm:action="modify">
                    <CreatePartitions>
                        <CreatePartition wcm:action="modify">
                            <Order>1</Order>
                            <Type>Primary</Type>

                        </CreatePartition>
                    </CreatePartitions>
                    <ModifyPartitions>
                        <ModifyPartition wcm:action="modify">
                            <Active>true</Active>
                            <Format>NTFS</Format>
                            <Order>1</Order>
                            <PartitionID>1</PartitionID>
                            <Extend>false</Extend>
                        </ModifyPartition>
                    </ModifyPartitions>
                    <DiskID>0</DiskID>
                    <WillWipeDisk>true</WillWipeDisk>
                </Disk>
                <WillShowUI>OnError</WillShowUI>
            </DiskConfiguration>
            <ImageInstall>
                <OSImage>
                    <InstallTo>
                        <DiskID>0</DiskID>
                        <PartitionID>1</PartitionID>
                    </InstallTo>
                    <WillShowUI>OnError</WillShowUI>
                    <InstallFrom>
                        <MetaData wcm:action="add">
                            <Key>/IMAGE/NAME</Key>
                            <Value>Windows 7 ENTERPRISE</Value>
                        </MetaData>
                    </InstallFrom>
                </OSImage>
            </ImageInstall>
            <UserData>
                <AcceptEula>true</AcceptEula>
                <FullName></FullName>
                <Organization></Organization>
                <ProductKey>
                    <WillShowUI>Never</WillShowUI>
                </ProductKey>
            </UserData>
        </component>  
  
    </settings>
 
    <settings pass="specialize">
        <component name="Microsoft-Windows-Shell-Setup" processorArchitecture="x86" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
            <RegisteredOrganization></RegisteredOrganization>
            <TimeZone>Pacific Standard Time</TimeZone>
            <RegisteredOwner></RegisteredOwner>
            <AutoLogon>
                <Password>
                    <Value></Value>
                    <PlainText>true</PlainText>
                </Password>
                <Username>administrator</Username>
                <LogonCount>3</LogonCount>
                <Enabled>true</Enabled>
            </AutoLogon>
            <ComputerName />
        </component>
  
 <component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
            <RegisteredOrganization></RegisteredOrganization>
            <TimeZone>Pacific Standard Time</TimeZone>
            <RegisteredOwner></RegisteredOwner>
            <AutoLogon>
                <Password>
                    <Value></Value>
                    <PlainText>true</PlainText>
                </Password>
                <Username>administrator</Username>
                <LogonCount>3</LogonCount>
                <Enabled>true</Enabled>
            </AutoLogon>
            <ComputerName />
        </component>
  
    </settings>
 
    <settings pass="oobeSystem">
        <component name="Microsoft-Windows-Shell-Setup" processorArchitecture="x86" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
            <OOBE>
                <ProtectYourPC>1</ProtectYourPC>
                <NetworkLocation>Work</NetworkLocation>
            </OOBE>
            <UserAccounts>
                <LocalAccounts>
                    <LocalAccount wcm:action="add">
                        <Password>
                            <Value></Value>
                            <PlainText>true</PlainText>
                        </Password>
                        <Name>administrator</Name>
                        <Group>Administrators</Group>
                    </LocalAccount>
                </LocalAccounts>
            </UserAccounts>
            <AutoLogon>
                <Enabled>true</Enabled>
                <Username>Administrator</Username>
                <LogonCount>3</LogonCount>
            </AutoLogon>
            <RegisteredOrganization></RegisteredOrganization>
            <RegisteredOwner></RegisteredOwner>
   <FirstLogonCommands>
            <SynchronousCommand wcm:action="add">
            <Order>1</Order>
            <Description>Run FirstRun.cmd</Description>
            <CommandLine>%WINDIR%\Setup\Scripts\FirstRun.cmd</CommandLine>
            </SynchronousCommand>
   </FirstLogonCommands>
        </component>
  
 <component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
            <OOBE>
                <ProtectYourPC>1</ProtectYourPC>
                <NetworkLocation>Work</NetworkLocation>
            </OOBE>
            <UserAccounts>
                <LocalAccounts>
                    <LocalAccount wcm:action="add">
                        <Password>
                            <Value></Value>
                            <PlainText>true</PlainText>
                        </Password>
                        <Name>administrator</Name>
                        <Group>Administrators</Group>
                    </LocalAccount>
                </LocalAccounts>
            </UserAccounts>
            <AutoLogon>
                <Enabled>true</Enabled>
                <Username>Administrator</Username>
                <LogonCount>3</LogonCount>
            </AutoLogon>
            <RegisteredOrganization></RegisteredOrganization>
            <RegisteredOwner></RegisteredOwner>
   <FirstLogonCommands>
            <SynchronousCommand wcm:action="add">
            <Order>1</Order>
            <Description>Run FirstRun.cmd</Description>
            <CommandLine>%WINDIR%\Setup\Scripts\FirstRun.cmd</CommandLine>
            </SynchronousCommand>
   </FirstLogonCommands>
        </component>  
  
    </settings>
</unattend>
Here is additional steps to integrate drivers:
1) Integrate USB3/HECI drivers into boot.wim.
Install WAIK
create offline and drivers directory on r: disk. Paste all drivers inside this directory.
copy boot.wim on r:\ disk
dism /mount-wim /wimfile:r:\boot.wim /index:2 /mountdir:r:\offline
dism /image:r:\offline /add-driver /driver:r:\drivers /recurse
dism /commit-wim /mountdir:r:\offline
2) Integrate drivers into install.wim
dism /mount-wim /wimfile:r:\install.wim /index:1 /mountdir:r:\offline
dism /image:r:\offline /add-driver /driver:r:\drivers /recurse
dism /commit-wim /mountdir:r:\offline
Related:
Windows 7 enterprise 90 days trial
Integrate drivers into Windows 7 installation source
Integrate LAN drivers into install.wim

Friday, June 27, 2014

IBM Sametime Connect 9.0 silent install

This silent install script includes detection method for version 9.0.0_20130911-1333
@echo off
setlocal EnableDelayedExpansion
set sw=HKLM\SOFTWARE
set u=Microsoft\Windows\CurrentVersion\Uninstall
set k={C02B8B94-966D-4369-B288-4E6BF2BA4E37}
if not "%ProgramFiles(x86)%"=="" set x=Wow6432Node\
reg query "%sw%\%x%%u%\%k%" > nul 2>&1
if not !errorlevel!==0 (
call "%~dp0setup.bat"
)
endlocal

Thursday, June 26, 2014

Windows XP alternative

This is POSReady 2009.
POS means point of sale.
This system was created for checkout registers in shops.
There are included Internet Explorer and Notepad out of the box. Nothing more.
The security updates for this system will work till year 2019.
The system is created on same kernel as windows xp so you are ready to use same drivers as xp.
Trial key you can get for free by logging into microsoft account at:
http://www.microsoft.com/windowsembedded/en-us/download-standard-2009.aspx
You must fill few additional fields :)

Here is CD image:
http://download.microsoft.com/download/6/3/6/636E5B38-EA04-4F25-A059-CA6EDF773F79/POSready2009_CD.iso
mirror: https://googledrive.com/host/0B50FZvUdHgZcNlVpemQzTEZoRUU
c25d9a8e56f18b328c5a16fd6b0358f3
143cb58be71e000cc205757c9965ce486189a589

Screenshot:

Wednesday, June 25, 2014

Get security updates for XP after April 2014

reg add HKLM\SYSTEM\WPA\PosReady /v Installed /d 1 /t REG_DWORD /f
I believe that reseting Windows Update state can be also good idea. This is possible with:
net stop wuauserv
rd %systemroot%\SoftwareDistribution /Q /S
SC sdshow wuauserv
SC sdset wuauserv D:(A;;CCLCSWRPWPDTLOCRRC;;;SY)(A;;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;BA)(A;;CCLCSWLOCRRC;;;AU)(A;;CCLCSWRPWPDTLOCRRC;;;PU)
wuauclt.exe /detectnow
To detect Windows XP operating system and deploy the key
@echo off
setlocal EnableDelayedExpansion
reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" ^
/v ProductName | find "Windows XP" > nul 2>&1
if !errorlevel!==0 (
reg add HKLM\SYSTEM\WPA\PosReady /v Installed /d 1 /t REG_DWORD /f
)
endlocal
Screenshot:

Source:
http://betanews.com/2014/05/26/how-to-continue-getting-free-security-updates-for-windows-xp-until-2019/

Query windows 8.1 workstations, system center

Query all Windows 8.1 workstations
select SMS_R_SYSTEM.ResourceID,SMS_R_SYSTEM.ResourceType,SMS_R_SYSTEM.Name,SMS_R_SYSTEM.SMSUniqueIdentifier,SMS_R_SYSTEM.ResourceDomainORWorkgroup,SMS_R_SYSTEM.Client from SMS_R_System where SMS_R_System.OperatingSystemNameandVersion = "Microsoft Windows NT Workstation 6.3"
Query all Windows 8 workstations
select SMS_R_SYSTEM.ResourceID,SMS_R_SYSTEM.ResourceType,SMS_R_SYSTEM.Name,SMS_R_SYSTEM.SMSUniqueIdentifier,SMS_R_SYSTEM.ResourceDomainORWorkgroup,SMS_R_SYSTEM.Client from SMS_R_System where SMS_R_System.OperatingSystemNameandVersion = "Microsoft Windows NT Workstation 6.2"

Tuesday, June 24, 2014

Upload file to google drive using python

I found this brilliant code at
http://jeremyblythe.blogspot.ae/2012/06/motion-google-drive-uploader-and.html

This will let you use python to upload files to google drive

Here is what you need to do:
1) install python
sudo apt-get install python
2) install gdata module
wget http://gdata-python-client.googlecode.com/files/gdata-2.0.18.tar.gz
tar -xvf gdata-2.0.18.tar.gz
cd gdata-2.0.18/
sudo python setup.py install
3) create config file howyoudoin.cfg
[gmail]
# GMail account credentials
name = My Name
user = gmailusername
password = gmailpassword
sender = me@gmail.com

# Recipient email address (could be same as from_addr)
recipient = me@gmail.com

# Subject line for email
subject = Motion detected

# First line of email message
message = Video uploaded

[docs]
# Folder (or collection) in Docs where you want the videos to go
folder = howyoudoin

[options]
# Delete the local video file after the upload
delete-after-upload = true

# Send an email after the upload
send-email = true
4) Go to this google drive account and at the root create this "howyoudoin" folder

5) Create main program uploader.py. No need to change even one line :)
#!/usr/bin/python2
'''
Created on 6 Jun 2012

@author: Jeremy Blythe

Motion Uploader - uploads videos to Google Drive

Read the blog entry at http://jeremyblythe.blogspot.com for more information
'''

import smtplib
from datetime import datetime

import os.path
import sys

import gdata.data
import gdata.docs.data
import gdata.docs.client
import ConfigParser

class MotionUploader:
    def __init__(self, config_file_path):
        # Load config
        config = ConfigParser.ConfigParser()
        config.read(config_file_path)
        
        # GMail account credentials
        self.username = config.get('gmail', 'user')
        self.password = config.get('gmail', 'password')
        self.from_name = config.get('gmail', 'name')
        self.sender = config.get('gmail', 'sender')
        
        # Recipient email address (could be same as from_addr)
        self.recipient = config.get('gmail', 'recipient')        
        
        # Subject line for email
        self.subject = config.get('gmail', 'subject')
        
        # First line of email message
        self.message = config.get('gmail', 'message')
                
        # Folder (or collection) in Docs where you want the videos to go
        self.folder = config.get('docs', 'folder')
        
        # Options
        self.delete_after_upload = config.getboolean('options', 'delete-after-upload')
        self.send_email = config.getboolean('options', 'send-email')
        
        self._create_gdata_client()

    def _create_gdata_client(self):
        """Create a Documents List Client."""
        self.client = gdata.docs.client.DocsClient(source='motion_uploader')
        self.client.http_client.debug = False
        self.client.client_login(self.username, self.password, service=self.client.auth_service, source=self.client.source)
               
    def _get_folder_resource(self):
        """Find and return the resource whose title matches the given folder."""
        col = None
        for resource in self.client.GetAllResources(uri='/feeds/default/private/full/-/folder'):
            if resource.title.text == self.folder:
                col = resource
                break    
        return col
    
    def _send_email(self,msg):
        '''Send an email using the GMail account.'''
        senddate=datetime.strftime(datetime.now(), '%Y-%m-%d')
        m="Date: %s\r\nFrom: %s <%s>\r\nTo: %s\r\nSubject: %s\r\nX-Mailer: My-Mail\r\n\r\n" % (senddate, self.from_name, self.sender, self.recipient, self.subject)
        server = smtplib.SMTP('smtp.gmail.com:587')
        server.starttls()
        server.login(self.username, self.password)
        server.sendmail(self.sender, self.recipient, m+msg)
        server.quit()    

    def _upload(self, video_file_path, folder_resource):
        '''Upload the video and return the doc'''
        doc = gdata.docs.data.Resource(type='video', title=os.path.basename(video_file_path))
        media = gdata.data.MediaSource()
        media.SetFileHandle(video_file_path, 'video/avi')
        doc = self.client.CreateResource(doc, media=media, collection=folder_resource)
        return doc
    
    def upload_video(self, video_file_path):
        """Upload a video to the specified folder. Then optionally send an email and optionally delete the local file."""
        folder_resource = self._get_folder_resource()
        if not folder_resource:
            raise Exception('Could not find the %s folder' % self.folder)

        doc = self._upload(video_file_path, folder_resource)
                      
        if self.send_email:
            video_link = None
            for link in doc.link:
                if 'video.google.com' in link.href:
                    video_link = link.href
                    break
            # Send an email with the link if found
            msg = self.message
            if video_link:
                msg += '\n\n' + video_link                
            self._send_email(msg)    

        if self.delete_after_upload:
            os.remove(video_file_path)

if __name__ == '__main__':         
    try:
        if len(sys.argv) < 3:
            exit('Motion Uploader - uploads videos to Google Drive\n   by Jeremy Blythe (http://jeremyblythe.blogspot.com)\n\n   Usage: uploader.py {config-file-path} {video-file-path}')
        cfg_path = sys.argv[1]
        vid_path = sys.argv[2]    
        if not os.path.exists(cfg_path):
            exit('Config file does not exist [%s]' % cfg_path)    
        if not os.path.exists(vid_path):
            exit('Video file does not exist [%s]' % vid_path)    
        MotionUploader(cfg_path).upload_video(vid_path)        
    except gdata.client.BadAuthentication:
        exit('Invalid user credentials given.')
    except gdata.client.Error:
        exit('Login Error')
    except Exception as e:
        exit('Error: [%s]' % e)
6) set the file executable
chmod +x uploader.py
7) upload files to "howyoudoin" directory with
./uploader.py /path/to/howyoudoin.cfg /path/to/upload/file

Monday, June 23, 2014

ImportError: No module named gdata.data, python

import gdata.data
ImportError: No module named gdata.data
To solve this situation download gdata module
wget http://gdata-python-client.googlecode.com/files/gdata-2.0.18.tar.gz
Unpack archive
tar -xvf gdata-2.0.18.tar.gz
Move to the directory
cd gdata-2.0.18/
Install module
sudo python setup.py install
Related:
https://code.google.com/p/gdata-python-client/
Other versions:
https://code.google.com/p/gdata-python-client/downloads/list

Sunday, June 22, 2014

Thursday, June 19, 2014

Command line audit using CPU-Z

@echo off
set log_destination=%~dp0
set l=%log_destination%\%computername%_%username%.cpuz
if not exist "%l%.htm" (
if not "%ProgramFiles(x86)%"=="" goto x64
:x86
"%~dp0cpuz_x32.exe" -html=%l%
goto end
:x64
"%~dp0cpuz_x64.exe" -html=%l%
)
:end
Replace set log_destination= to some path without spaces.
If you leave it unattended then it will not work from windows xp cause there is spaces in path:
"C:\Documents and settings\.."

This will generate html reports similar to this:

Related:
http://www.cpuid.com/softwares/cpu-z.html

Latest K-Lite, binary file (standard input) matches, grep

In this example i try to output content of .torrent file.
Then i try to search specific content with grep and i get:
binary file (standard input) matches
To solve this situation grep -a must be used

Here is whole example:

url.lst
http://www.codecguide.com/download_k-lite_codec_pack_basic.htm 
http://www.codecguide.com/download_k-lite_codec_pack_standard.htm 
http://www.codecguide.com/download_k-lite_codec_pack_full.htm
http://www.codecguide.com/download_k-lite_codec_pack_mega.htm
This program will try to search for latest K-Lite installers at www.codecguide.com
# remove existing k-lite installers
# this is necessary if you sometimes brake the script in the middle point
rm K-Lite* -f

# check if exist the log file of all versions
# this log file will keep all old version file names inside
# basically this is needed for the first run only
if [ ! -e "klite.lst" ]
then
touch klite.lst
fi

# set array. it contains four lines
var=$(cat url.lst)

# read one lime per time. download it and search direct link in torrent file
printf %s "$var" | while IFS= read -r line
do {
torrent=$( \
wget -qO- $line | \
sed "s/\d034\|\d039\|<\|>/\n/g" | \
grep "\.torrent" | \
head -1 | \
sed "s/^/http:\/\/www.codecguide.com\//")

# search for direct link inside torrent file
directlink=$( \
wget -qO- $torrent | \
sed "s/http/\nhttp/g;s/\.exe/\.exe\n/g" | \
grep -a "^http.*\.exe")

filename=$( \
echo $directlink | \
sed "s/^.*\///g")

echo $directlink
echo $filename

# search if this is a new version of k-lite
cat klite.lst | grep "$filename"

# if it really is a new file then
if [ $? -ne 0 ]
then
wget $directlink -O $filename
md5=$(md5sum $filename | sed "s/\s.*//g")
sha1=$(sha1sum $filename | sed "s/\s.*//g")
# sendEmail -f "klite@rpi.com" -t "@gmail.com" -u "$filename" -m "$directlink \n$md5\n$sha1" -s "smtp.address.com" -o tls=no

# optional to backup all downloaded files
# mv $filename ~/archive

# set this file as noted
echo $filename>>klite.lst
fi

# take the next file in url.lst
}
done

Wednesday, June 18, 2014

Scheduled task to look for adobe reader patches

python-mechanize must be installed before start
sudo apt-get install python-mechanize
Python script getdlpage.py to get download page. This is necessary cause the page is generated by javascript.
from mechanize import Browser
br = Browser()

br.set_handle_robots( False )
br.addheaders = [('User-agent', 'Firefox')]
dlpage = 'http://www.adobe.com/support/downloads/product.jsp?product=10&platform=Windows'
f = br.retrieve(dlpage,"patches.html")[0]
Whole program
rm patches.log
python getdlpage.py

# get all urls starting from updates section till version 9.4.7
# reverse the list from oldest patch to newest
x=$( \
cat patches.html | \
sed "/<html/,/Updates\/Programs/d" | \
sed "/Version\ 9\.4\.7/,/<\/html>/d" | \
sed "s/\d034/\n/g" | \
grep "^detail.*" | \
tac)

# check each url html content and take only none-multilanguage patches
printf %s "$x" | while IFS= read -r line
do { 
filename=$(wget -qO- http://www.adobe.com/support/downloads/$line | \
sed "s/\d034\|<\|>/\n/g" | \
grep -v "MUI\|mui\|Tier" | \
grep "AdbeRdr.*msp" )
if [ $? -eq 0 ]
then

# chech if the patch is new one
cat arpatches.lst | grep "$filename"
# if patch is not found in logged list
if [ $? -ne 0 ]
then

echo $filename

# go to actual patch download page there direct linkt is placed
ty=$( \
wget -qO- http://www.adobe.com/support/downloads/$line | \
sed "s/\d034\|<\|>/\n/g" | \
grep "^thankyou.*" | \
sed ihttp://www.adobe.com/support/downloads/) 

# fix for wget cause it can not download urls with ampersand
cl=$( \
echo $ty | \
sed "s/ //g" | \
sed "s/\&amp\;/\\\&/g" | \
sed "s/amp\;//g")

echo $cl

# find full url
url=$(wget -qO- $cl | \
sed "s/\d034/\n/g" | \
grep "http.*msp")
rm *.msp
wget $url -O $filename
md5=$(md5sum $filename | sed "s/\s.*//g")
sha1=$(sha1sum $filename | sed "s/\s.*//g")
#sendEmail -f "ar@rpi.com" -t "z@y.z" -u "$filename" -m "$url \n$md5\n$sha1" -s "smtp.com" -o tls=no
mv $filename ~/archive
# set the patch status to [already checked]
echo $filename>> arpatches.lst
fi
fi
}
done

Need to know about putty

1) To copy the text based content you need to select the part you need to copy and when you release the mouse button the content is automatically copied to clipboard.

2) To paste the content use mouse right button.
You can also paste the password and then press enter.

Send external ip address via cron, linux shell errorlevel

Create a new file
sudo nano /etc/checkip.sh
paste the content and change your@gmail.com and smtp.address.com
#!/bin/sh
exipa=$(wget -qO- http://online-nettools.com/ | sed "s/\d034/\n/g" | grep "^[0-9]*.\.[0-9]*.\.[0-9]*.\.[0-9]")
tail -1 /home/pi/ip.address.history.log | grep $exipa
if [ $? -eq 0 ]
then
  echo "IP address has not been changed"
else
  echo "New IP address detected. It is $exipa"
  echo $exipa>>/home/pi/ip.address.history.log
  sendEmail -f "pi@raspberry.com" -t "your@gmail.com" -u "New IP" -m ${exipa} -s "smtp.address.com" -o tls=no
fi
create this script executable
sudo chmod 755 /etc/checkip.sh
Enter cron configuration
sudo crontab -e
To check every 10 minutes add at the end
*/10 * * * * /etc/checkip.sh
Note that the sendEmail must be installed before
sudo apt-get install sendEmail

Tuesday, June 17, 2014

Record radio stations with streamripper, Raspberry Pi

On Wheezy Raspbian OS install streamripper application
sudo apt-get install streamripper
Since there are no silent fade between tracks i personally recommend to keep the track in order.
That is why i add -q 0001 and use 1q before artist name and track title

Record PolskajaStacja
streamripper http://188.165.23.150:80 -q 0001 -D "Radio/PolskajaStacja/%001q. %A - %T" --quiet &
& at the end means to leave the process in background.

To record Radio Paradise
streamripper http://stream-dc1.radioparadise.com:80/mp3-128 -q 0001 -D "Radio/RadioParadise/%001q. %A - %T" --quiet &
To record DI.fm Vocal Trance
streamripper http://pub5.di.fm/di_vocaltrance_aac -q 0001 -D "Radio/DI.fm-Vocal-Trance/%001q. %A - %T" --quiet &
To record Country radio
streamripper http://89.105.32.15:8128 -q 0001 -D "Radio/Country/%001q. %A - %T" --quiet &
Record "The best DnB, Dubstep, Chillstep & Neurofunk" radio
streamripper http://radio.zuluhosting.co.uk:8000//stream -o larger -D "Radio/XenFM/%A - %T" --quiet &
Since this radio mostly includes nicely silent fade we will use -o larger option which means overwrite the same track if the size is bigger.

To record 24 hours add -l 86400 for example
streamripper http://188.165.23.150:80 -l 86400 -q 0001 -D "Radio/PolskajaStacja/%001q. %A - %T" --quiet &
To record 3 days add -l 259200
streamripper http://usa-crash.dnbradio.com:10128 -l 259200 -q 0001 -D "Radio/DnBRadio/%001q. %A - %T" --quiet &
To list all streamripper instances use
ps x | grep "streamripper"
To kill one station use sudo pkill and process id

To kill all streamripper instances use
sudo pkill streamripper
To remotely access the files you have recorded set up samba server

Monday, June 16, 2014

Lumension Endpoint Security Client native silent install-uninstall

les-native-silent-install.cmd
@echo off
setlocal EnableDelayedExpansion
set sw=HKLM\SOFTWARE
set u=Microsoft\Windows\CurrentVersion\Uninstall
set k={26267D3B-3707-4A9D-9A8C-79A7A3BFC710}

if "%ProgramFiles(x86)%"=="" goto x86

:x64
reg query "%sw%\%u%\%k%" > nul 2>&1
if !errorlevel!==0 goto x64.ok
%systemroot%\system32\msiexec.exe /i "%~dp0LESClient64.msi" ^
TRANSFORMS="%~dp0LESClient64.mst" /qn /norestart /L*v "%~dp0LESClient_install.log"
:x64.ok
goto les.ok

:x86
reg query "%sw%\%u%\%k%" > nul 2>&1
if !errorlevel!==0 goto x86.ok
%systemroot%\system32\msiexec.exe /i "%~dp0LESClient.msi" ^
TRANSFORMS="%~dp0LESClient.mst" /qn /norestart /L*v "%~dp0LESClient_install.log"
:x86.ok

:les.ok

endlocal

les-native-silent-uninstall.cmd
@echo off
setlocal EnableDelayedExpansion
set sw=HKLM\SOFTWARE
set u=Microsoft\Windows\CurrentVersion\Uninstall
set k={26267D3B-3707-4A9D-9A8C-79A7A3BFC710}

if "%ProgramFiles(x86)%"=="" goto x86

:x64
reg query "%sw%\%u%\%k%" > nul 2>&1
if not !errorlevel!==0 goto x64.ok
%systemroot%\system32\msiexec.exe /x "%~dp0LESClient64.msi" /qn /norestart /L*v "%~dp0LESClient_uninstall.log"
:x64.ok
goto les.ok

:x86
reg query "%sw%\%u%\%k%" > nul 2>&1
if not !errorlevel!==0 goto x86.ok
%systemroot%\system32\msiexec.exe /x "%~dp0LESClient.msi" /qn /norestart /L*v "%~dp0LESClient_uninstall.log"
:x86.ok

:les.ok

endlocal

Detection method key {26267D3B-3707-4A9D-9A8C-79A7A3BFC710} is only for version 4.5.2242

Read line from file and put into variable, linux shell

var=$(cat "file.lst")
printf %s "$var" | while IFS= read -r line
do
   echo "$line"
done
To execute more commands use
var=$(cat "file.lst")
printf %s "$var" | while IFS= read -r line
do {
   echo "$line"

}
done

Sunday, June 15, 2014

Saturday, June 14, 2014

Install python mechanize on Raspberry Pi

Python methanize is command line web browser.
The main reason why i use this tool is to download JavaScript generated html.
For example this page is JavaScript generated:
http://www.adobe.com/support/downloads/product.jsp?product=10&platform=Windows

You can try download this page with wget.
wget "http://www.adobe.com/support/downloads/product.jsp?product=10\&platform=Windows" -O output.log
but there is so much content missing!

For a solution it is possible to install python mechanize
sudo apt-get install python-mechanize
To download this page with mechanize create a new file arlist.py with folowing code:
from mechanize import Browser
br = Browser()

br.set_handle_robots( False )
br.addheaders = [('User-agent', 'Firefox')]

f = br.retrieve('http://www.adobe.com/support/downloads/product.jsp?product=10&platform=Windows',"blah.log")[0]
To execute the code (download html with parsed JavaScript) use
python arlist.py
To search all available patches for windows here comes very dirty code
rm blah.log
python arlist.py

# get all urls starting from updates section till version 9.4.7
# reverse the list from oldest patch to newest
x=$( \
cat blah.log | \
sed "/<html/,/Updates\/Programs/d" | \
sed "/Version\ 9\.4\.7/,/<\/html>/d" | \
sed "s/\d034/\n/g" | \
grep "^detail.*" | \
tac)

# check each url html content and take only none-multilanguage patches
printf %s "$x" | while IFS= read -r line
do { 
filename=$(wget -qO- http://www.adobe.com/support/downloads/$line | \
sed "s/\d034\|<\|>/\n/g" | \
grep -v "MUI\|mui\|Tier" | \
grep "AdbeRdr.*msp" )
if [ $? -eq 0 ]
then

# chech if the patch is new one
cat arpatches.lst | grep "$filename"
# if patch is not found in logged list
if [ $? -ne 0 ]
then

echo $filename

# go to actual patch download page there direct linkt is placed
ty=$( \
wget -qO- http://www.adobe.com/support/downloads/$line | \
sed "s/\d034\|<\|>/\n/g" | \
grep "^thankyou.*" | \
sed ihttp://www.adobe.com/support/downloads/) 

# fix for wget cause it can not download urls with ampersand
cl=$( \
echo $ty | \
sed "s/ //g" | \
sed "s/\&amp\;/\\\&/g" | \
sed "s/amp\;//g")

echo $cl

# find full url
url=$(wget -qO- $cl | \
sed "s/\d034/\n/g" | \
grep "http.*msp")
rm *.msp
wget $url -O $filename
md5=$(md5sum $filename | sed "s/\s.*//g")
sha1=$(sha1sum $filename | sed "s/\s.*//g")
sendEmail -f "ar@rpi.com" -t "z@y.z" -u "$filename" -m "$url \n$md5\n$sha1" -s "smtp.com" -o tls=no
mv $filename ~/archive
# set the patch status to [already checked]
echo $filename>> arpatches.lst
fi
fi
}
done
Screenshot on output

Friday, June 13, 2014

Nagios XI plain text authorization

NSP: Sorry Dave, I can't let you do that
http://nagios.blah.com/nagiosxi/login.php?nsp=thisisrandmonsphexkey1234567890a&page=auth&pageopt=login&username=sony&password=ps4station&redirect=/nagiosxi/index.php
Translation
http://nagios.blah.com/nagiosxi/login.php?
nsp=thisisrandmonsphexkey1234567890a
&
page=auth
&
pageopt=login
&
username=sony
&
password=ps4station
&
redirect=/nagiosxi/index.php

Convert white png image background to transparent

This can be done with a little patience using Paint.NET
1. Select Magic tool
2. Use Tolerance Tools to find best automatic detection property
3. Hold down shift key and click at last white fields
4. Press delete

Tuesday, June 10, 2014

Find out version number using 7z and .rsrc/0/MANIFEST/1

To find out windows skype version number run from linux shell run
7z x filename.exe -y
cat .rsrc/0/MANIFEST/1 | \
sed "s/<dependency>/\n<dependency>\n/g" | \
sed "s/<\/assembly>/\n<\/assembly>\n/g" | \
sed "/<dependency>/,/<\/assembly>/d" | \
sed "s/\d034/\n/g" | \
grep "^[0-9]*.\.[0-9]*.\.[0-9]*.\.[0-9]"
On windows
@echo off
set path=%path%;%~dp0
7z x filename.exe -y
cat .rsrc\0\MANIFEST\1 | \
sed "s/<dependency>/\n<dependency>\n/g" | \
sed "s/<\/assembly>/\n<\/assembly>\n/g" | \
sed "/<dependency>/,/<\/assembly>/d" | \
sed "s/\d034/\n/g" | \
grep "^[0-9]*.\.[0-9]*.\.[0-9]*.\.[0-9]"
pause
To find out windows flash player version number run from linux shell run
7z x filename.exe -y
cat .rsrc/MANIFEST/1 | \
sed "s/<dependency>/\n<dependency>\n/g" | \
sed "s/<\/assembly>/\n<\/assembly>\n/g" | \
sed "/<dependency>/,/<\/assembly>/d" | \
sed "s/\d034/\n/g" | \
grep "^[0-9]*.\.[0-9]*.\.[0-9]*.\.[0-9]"
On windows
@echo off
set path=%path%;%~dp0
7z x filename2.exe -y
cat .rsrc\MANIFEST\1 |^
sed "s//\n\n/g" |^
sed "s/<\/assembly>/\n<\/assembly>\n/g" |^
sed "//,/<\/assembly>/d" |^
sed "s/\d034/\n/g" |^
grep "^[0-9]*.\.[0-9]*.\.[0-9]*.\.[0-9]"
pause
Missing files for windows:
http://gnu.catonrug.net/7z.dll
http://gnu.catonrug.net/7z.exe
http://gnu.catonrug.net/cat.exe
http://gnu.catonrug.net/grep.exe
http://gnu.catonrug.net/libiconv2.dll
http://gnu.catonrug.net/libintl3.dll
http://gnu.catonrug.net/regex2.dll
http://gnu.catonrug.net/sed.exe

Tested with:
http://www.skype.com/go/getskype-Full
http://download.macromedia.com/pub/flashplayer/current/support/install_flash_player_ax.exe
http://download.macromedia.com/pub/flashplayer/current/support/install_flash_player.exe

Raspberry Pi 7z support

Install 7-zip libraries for command line support
sudo apt-get install p7zip-full
To extract file use
7zr e filename.7z
To compress file use
p7zip filename

Monday, June 9, 2014

Use 7-zip to extract exe on linux

Install p7zip-full package to access 7z, 7za, 7zr and p7zip commands
sudo apt-get install p7zip-full
Now can extract with
7z e filename.exe

Sunday, June 8, 2014

Log the Alexa rank changes via cron

This will only log the change if the rank are different from previous rank in log
alexa.rank.sh
#!/bin/sh
ranko=$( \
wget -qO- http://www.alexa.com/siteinfo/catonrug.net#trafficstats | \
grep "Global.*metrics-data align-vmiddle" | \
sed "s/\d034>\|<\//\n/g" | \
grep "^[0-9,]")

tail -1 /home/pi/rank.alexa.log | grep $ranko

if [ $? -eq 0 ]
then
  echo "Rank has not changed"
else
  echo "New alexa rank is $ranko"
  echo $ranko>>/home/pi/rank.alexa.log
  sendEmail -f "pi@your.net" -t "your@gmail.com" -u "Alexa rank has change" -m ${ranko} -s "smtp.address.com" -o tls=no
fi
replace /home/pi/rank.alexa.log for log file destination
replace catonrug.net with your site
replace your@gmail.com with your email
replace smtp.address.com with yours
install sendEmail with
sudo apt-get install sendEmail
set the script executable
sudo chmod 755 alexa.rank.sh
Enter cron configuration
sudo crontab -e
To check every hour use
0 * * * * /path/to/alexa.rank.sh
To check every five minutes
*/5 * * * * /path/to/alexa.rank.sh
Restart cron service
sudo service cron restart

Saturday, June 7, 2014

schedule alexa rank query with cron

Enter crontab configuration
sudo crontab -e
At the end paste line
* 1 * * * wget -qO- http://www.alexa.com/siteinfo/catonrug.net#trafficstats | grep "Global.*metrics-data align-vmiddle" | sed "s/\d034>\|<\//\n/g" | grep "^[0-9,]" | sed s/^/"`date` "/>> /home/pi/catonrug.net.rank.log
Another useful times:
* * * * * - run every minute
*/10 * * * * - run every ten minutes
15,35,55 * * * * - run three times in hour in specified minute
0 * * * * - run every hour
0 */4 * * * - run every four hours
0 0 * * * - run in midnight

Restart cron service with
sudo service cron restart

Wednesday, June 4, 2014

Send email from Raspberry Pi terminal window

On Raspbian OS install sendEmail package with
sudo apt-get install sendEmail -y
Do not miss nice big E from name. sendmail is not the same as sendEmail

Now you can send email with
sendEmail -f "a@b.com" -t "to@gmail.com" -u "title" -m "msg" -s "smtpaddress" -o tls=no
sendEmail manual
NAME
       SendEmail - Lightweight, command line SMTP email client

SYNOPSIS
       SendEmail -f ADDRESS [options]

OPTIONS
       -f ADDRESS
              from (sender) email address

              * At least one recipient required via -t, -cc, or -bcc * Message body required via
              -m, STDIN, or -o message-file=FILE

              Common:

       -t ADDRESS [ADDR ...]
              to email address(es)

       -u SUBJECT
              message subject

       -m MESSAGE
              message body

       -s SERVER[:PORT]
              smtp mail relay, default is localhost:25

              Optional:

       -a     FILE [FILE ...]      file attachment(s)

       -cc    ADDRESS [ADDR ...]   cc  email address(es)

       -bcc ADDRESS [ADDR ...]
              bcc email address(es)

              [32;1mParanormal:[m

       -xu USERNAME
              authentication user (for SMTP authentication)

       -xp PASSWORD
              authentication password (for SMTP authentication)

       -l     LOGFILE               log to the specified file

       -v     verbosity, use multiple times for greater effect

       -q     be quiet (no stdout output)

       -o NAME=VALUE
              see extended help topic "misc" for details

              Help:

       --help TOPIC
              The following extended help topics are available:

       addressing
              explain addressing and related options

       message
              explain message body input and related options

       misc   explain -xu, -xp, and others

       networking
              explain -s, etc

       output explain logging and other output options


REPORTING BUGS
       Report bugs to <http://bugs.debian.org/sendemail>

AUTHOR
       sendemail was written by Brandon Zehm <caspian@dotconf.net> .

       This manual page was written by Brandon Zehm and improved by Alejandro Garrido Mota <gar‐
       ridomota@gmail.com>, for the Debian project (and may be used by others).

Get external IP address from command line

On windows computer download these libraries
http://gnu.catonrug.net/wget.exe
http://gnu.catonrug.net/sed.exe
http://gnu.catonrug.net/libiconv2.dll
http://gnu.catonrug.net/libintl3.dll
http://gnu.catonrug.net/regex2.dll
http://gnu.catonrug.net/awk.exe
http://gnu.catonrug.net/grep.exe

In directotry where all those libraries is having a good time create batch file with the code
@echo off
set path=%path%;%~dp0
wget -qO- http://echoip.com/ |^
sed "s/\d034/\n/g" |^
grep "^[0-9]*.\.[0-9]*.\.[0-9]*.\.[0-9]"
pause
set path=%path%;%~dp0 - let you use all binaries in current session placed in current directory
wget -qO- http://online-nettools.com/ - output html code
sed "s/\d034/\n/g" - substitute all double quotes with brake rule. This is a dirty trick to put a lot of useful content in single line
grep "^[0-9]*.\.[0-9]*.\.[0-9]*.\.[0-9]" - look for pattern with only contain numbers by delimited with three dots

To put IP address in variable use
@echo off
set path=%path%;%~dp0
for /f "tokens=*" %%i in ('^
wget -qO- http://echoip.com/ ^|
sed "s/\d034/\n/g" ^|
grep "^[0-9]*.\.[0-9]*.\.[0-9]*.\.[0-9]"') do (
echo %%i
)
pause
please note that |^ is replaced with ^|

With conditions try
@echo off
set path=%path%;%~dp0
for /f "tokens=*" %%i in ('^
wget -qO- http://echoip.com/ ^|
sed "s/\d034/\n/g" ^|
grep "^[0-9]*.\.[0-9]*.\.[0-9]*.\.[0-9]"') do (
for /f "tokens=*" %%p in ('type "%~dp0last.log"') do (
if not %%p==%%i (
echo %%i>"%~dp0last.log"
echo You got new IP Address and it is %%i
)
if %%p==%%i (
echo Your IP address is still the same
)
)
)
On linux use something like
#!/bin/sh
exipa=$(wget -qO- http://echoip.com/ | sed "s/\d034/\n/g" | grep "^[0-9]*.\.[0-9]*.\.[0-9]*.\.[0-9]")
echo $exipa
if [[ "${exipa}" != $(cat ~/.current_ip) ]]
then
echo "Your new IP address is ${exipa}" |
sendEmail -f "pi@raspberry.com" -t "your@gmail.com" -u "another ip" -m ${exipa} -s "smtpaddress" -o tls=no
echo ${exipa} >|~/.current_ip
fi
Credits goes to:
http://www.tuxradar.com/answers/516
http://www.raspberrypi.org/forums/viewtopic.php?f=36&t=49688

setup.exe and msi do the same


Sometimes when run some msi file or setup.exe it will do pretty mush the same. So why you need booth files?

Turns out the real difference is that setup.exe pretty much often calls that same msi file. Setup.exe also has integrated future to request administrator privileges before you really start installation wizard. If you use msi file instead it may let you go through installation wizard and only at the end will tell you that you got not enough privileges to do the thing.

There also are graphical difference to boot icons. setup.exe includes shield picture ()

On computer you can have user accounts which has administrator rights or NOT. setup.exe has invented for users without admin rights. Once the setup.exe is launched it will ask for admin permissions so you will not waste any second of installation wizard.

Monday, June 2, 2014

How to TinyCore on Raspberry Pi

Extract content from
http://tinycorelinux.net/5.x/armv6/releases/5.3/piCore-5.3-X.zip
29eb0fa21f32fc93479404631923a8c1
3424a720c3ad2466c73c518d1ce1d3321f53abe0

Use Win32DiskImager to push the piCore-5.3-X.img to flash disk

Plug SD card, mouse and keyboard and launch the Pi

Open terminal windows

Since the TinyCore is totally loaded in RAM it is possible to remaster the partition table of SD card
Open SD card for partitioning
sudo fdisk /dev/mmcblk0
Print existing partition table with p

Press d to delete partition

Write 2 to delete second partition

Press n to create new partition

Write p for primary

Partition number set 2

Enter 705 as the first block of second partition and press enter

Hit enter again to use maximum available space of SD card

Press w to write changes

Now you need to reboot pi with
sudo reboot
Here is how all looks together with 512 Mb SD card

After reboot open terminal again and enter
sudo resize2fs /dev/mmcblk0p2

Now your second partition is usable

Be happy ;)

Set up Zabbix maintenance period

Enter maintenance configuration, Enter maintenance profile and click for periods. Add host and groups.
Make sure there is "Maintenance status not in maintenance" rule active in [Conditions]

Sunday, June 1, 2014

Install new fonts on Puppy Linux

Copy all *.ttf files to
/usr/share/fonts/default/TTF/
Then open terminal and launch
fc-cache -vf

Blog Archive