2/1/10

Grep replacement for binary files / Script

Example 10-7. A grep replacement for binary files

    #!/bin/bash
    # bin-grep.sh: Locates matching strings in a binary file.
   
    # A "grep" replacement for binary files.
    # Similar effect to "grep -a"
   
    E_BADARGS=65
    E_NOFILE=66
   
  if [ $# -ne 2 ]
  then
     echo "Usage: `basename $0` string filename"
     exit $E_BADARGS
   fi
  
   if [ ! -f "$2" ]
   then
     echo "File \"$2\" does not exist."
     exit $E_NOFILE
   fi 
  
  
   for word in $( strings "$2" | grep "$1" )
   # The "strings" command lists strings in binary files.
   # Output then piped to "grep", which tests for desired string.
   do
     echo $word
   done
 
 # As S.C. points out, the above for-loop could be replaced with the simpler
 #    strings "$2" | grep "$1" | tr -s "$IFS" '[\n*]'
 
 # Try something like  "./bin-grep.sh mem /bin/ls"  to exercise this script.
   exit 0

 

<http://www.faqs.org/docs/abs/HTML/loops.html#FILEINFO>



Add ISCSI FileSystem

iSCSI Configuration

  1. iSCSI startup using the init script or manual start-up. You need to edit and configure iSCSI via /etc/iscsi/iscsid.conf file
  2. Discover targets.
  3. Automate target logins for future system reboots.
  4. You also need to obtain iSCSI username, password and storage server IP address target host)

Step  1: Configure iSCSI

Open /etc/iscsi/iscsid.conf with vi text editor:
# vi /etc/iscsi/iscsid.conf
Setup username and password:
node.session.auth.username = My_ISCSI_USR_NAME
node.session.auth.password = MyPassword
discovery.sendtargets.auth.username = My_ISCSI_USR_NAME
discovery.sendtargets.auth.password = MyPassword
Where,
• node.session.* is used to set a CHAP username and password for initiator authentication by the target(s).
• discovery.sendtargets.* is used to set a discovery session CHAP username and password for the initiator authentication by the target(s)
You may also need to tweak and set other options. Refer to man page for more information. Now start the iscsi service:
# /etc/init.d/iscsi start



Step 2: Discover targets


Now use iscsiadm command, which is a command-line tool allowing discovery and login to iSCSI targets, as well as access and management of the open-iscsi database. If your storage server IP address is 192.168.1.5, enter:
# iscsiadm -m discovery -t sendtargets -p 192.168.129.1
# /etc/init.d/iscsi restart
Now there should be a block device under /dev directory. To obtain new device name, type:
# fdisk -l
or
# tail -f /var/log/messages
/dev/sdb is my new block device.


Step 3: Format and Mount iSCSI Volume


You can now partition and create a filesystem on the target using usual fdisk and mkfs.ext3 commands:
# fdisk /dev/sdb
# mkfs.ext3 /dev/sdb1
Tip: If your volume is large size like 1TB, run mkfs.ext3 in background using nohup:
# nohup mkfs.ext3 /dev/sdb1 &

Mount new partition:
# mkdir /mnt/iscsi
# mount /dev/sdb1 /mnt/iscsi



Step 4: Mount iSCSI drive automatically at boot time


First make sure iscsi service turned on at boot time:

# chkconfig iscsi on
Open /etc/fstab file and append config directive:
/dev/sdb1 /mnt/iscsi ext3 _netdev 0 0

Save and close the file.

Advanced Bash Scripting link - Notes

Changes all filenames in working directory to lowercase.

   1 #! /bin/bash
   2 #
   3 # Changes every filename in working directory to all lowercase.
   4 #
   5 # Inspired by a script of John Dubois,
   6 # which was translated into into Bash by Chet Ramey,
   7 # and considerably simplified by Mendel Cooper, author of this document.
   8
   9
  10 for filename in *                # Traverse all files in directory.
  11 do
  12    fname=`basename $filename`
  13    n=`echo $fname | tr A-Z a-z`  # Change name to lowercase.
  14    if [ "$fname" != "$n" ]       # Rename only files not already lowercase.
  15    then
  16      mv $fname $n
  17    fi
  18 done 
  19
  20 exit 0
  21
  22
  23 # Code below this line will not execute because of "exit".
  24 #--------------------------------------------------------#
  25 # To run it, delete script above line.
  26
  27 # The above script will not work on filenames containing blanks or newlines.
  28
  29 # Stephane Chazelas therefore suggests the following alternative:
  30
  31
  32 for filename in *    # Not necessary to use basename,
  33                      # since "*" won't return any file containing "/".
  34 do n=`echo "$filename/" | tr '[:upper:]' '[:lower:]'`
  35 #                             POSIX char set notation.
  36 #                    Slash added so that trailing newlines are not
  37 #                    removed by command substitution.
  38    # Variable substitution:
  39    n=${n%/}          # Removes trailing slash, added above, from filename.
  40    [[ $filename == $n ]] || mv "$filename" "$n"
  41                      # Checks if filename already lowercase.
  42 done
  43
  44 exit 0

////////////////////////////////////////////////////

du: DOS to UNIX text file conversion.

   1 #!/bin/bash
   2 # du.sh: DOS to UNIX text file converter.
   3
   4 E_WRONGARGS=65
   5
   6 if [ -z "$1" ]
   7 then
   8   echo "Usage: `basename $0` filename-to-convert"
   9   exit $E_WRONGARGS
  10 fi
  11
  12 NEWFILENAME=$1.unx
  13
  14 CR='\015'  # Carriage return.
  15 # Lines in a DOS text file end in a CR-LF.
  16
  17 tr -d $CR < $1 > $NEWFILENAME
  18 # Delete CR and write to new file.
  19
  20 echo "Original DOS text file is \"$1\"."
  21 echo "Converted UNIX text file is \"$NEWFILENAME\"."
  22
  23 exit 0

http://www.faqs.org/docs/abs/HTML/index.html

P.S. The unalias command removes a previously set alias.

MSI / MS Installer error code 2230

Internal error 2203. c:\windows\installer\xxxxx.ipi, -2147024629
Document ID: CTX104619 / Created On: Sep 7, 2004 / Updated On: Sep 29, 2004
Average Rating: 1 (8 ratings)
View products this document applies to link to products this document applies to

Symptoms

When trying to install/uninstall a citrix hotfix, installing/uninstalling the server software or when adding or removing some components of the server software one may receive the following error:

Internal error 2203. c:\windows\installer\xxxxx.ipi, -2147024629



Resolution

Ensure the path of the administrator’s user variables in the system properties of the temp and tmp variables are as follows:

TEMP:%USERPROFILE%\Local Settings\Temp

TMP:%USERPROFILE%\Local Settings\Temp

This document applies to:

* MetaFrame Presentation Server 3.0 for Microsoft Windows 2000
* MetaFrame Presentation Server 3.0 for Microsoft Windows 2003
* MetaFrame XP 1.0 for Microsoft Windows 2000
* MetaFrame XP 1.0 for Microsoft Windows 2003

http://support.citrix.com/article/CTX104619 

Microsoft Word 2000 HTML Mess Cleaner

It is well-known that Microsoft Word is a lot less than perfect when it comes to generating HTML-code. The "Save as web page"-function in Microsoft Word generates files that are about ten times as large as they should be. This is because the code is filled with a lot of page formatting tags in order to be able to present the document in Microsoft Office-programs (Word+Powerpoint). This "code bloat" is useless in a web context and potentially harmful to presentation in any other browser than Internet Explorer.

The problem not only arises when using the "Save as web page"-option. You get the same mess when copying text from Word to a Wysiwyg-editor (i.e. Frontpage) or in many cases to a Content Management System.

The solution: Remove the clutter from the HTML code automatically:
http://www.algotech.dk/word-html-cleaner-input.htm

More Free MS Word HTML cleaners:

AD Attribs

AD attributes List
General Tab
Display Name
Attribute Name
Example Value
First Name
givenName
John
Initials
initials
JS
Last Name
sn
Smith
Display Name
displayName
John Smith
Description
description
Sales Manager
Office
physicalDeliveryOfficeName
London Office
Telephone Number
telephoneNumber
0123 456 789
Telephone Number (Other)
otherTelephone
0123 4457 89
Email
mail
JSmith@domain.com
Web Page
wWWHomePage
Web Page (Other)
url
Password
password
JohnsPass321
Destination OU
destinationOU
"OU=Sales,DC=Domain,DC=Com"
Common Name
CN
John Smith or %lastname%
%firstname%
Modify User if already exists
Modify
True or False
Delete User
Delete
True or False
Address Tab
Display Name
Attribute Name
Example Value
Street
streetAddress
10 Downing St;London
(Use a semi-colon for carriage
return)
PO Box
postOfficeBox
Po Box 1
City
l (Lowercase L)
London
State/Province
st
New York
Zip/Postal Code
postalCode
614415
Country
c
GB, DE, US etc
Group Tab
Display Name
Attribute Name
Example Value
Group
memberOf
"CN=ManagersGroup,DC=Domain,DC=Com"
Account Tab
Display Name
Attribute Name
Example Value
User Logon Name
userPrincipalName
JSmith@domain.com
User Logon Name (Pre W2K)
sAMAccountName
JSmith (This attribute is
essential and must be in the import file)
User must change password at next
logon
mustChangePassword
True or False
User cannot change password
userCannotChangePassword
True or False
Account is Disabled
accountDisabled
True or False
Use DES encryption
useDES
True or False
Do not require kerberos
preauthentication
notRequireKerberos
True or False
Password never expires
passwordNeverExpires
True or False
Account is trusted for delegation
trustedForDelegation
True or False
Store password using reversable
encryption
passwordReversable
True or False
Smart card is required for
interactive logon
smartCardRequired
True or False
Account is sensitive and cannot
be delegated
sensitiveForDelegation
True or False
Account Expires (use same date
format as server)
expires
01/01/2007
Profile Tab
Display Name
Attribute Name
Example Value
Profile Path
profilePath
Login Script
scriptPath
logon.bat
Home Folder (local or UNC, see
notes above)
homeFolder
Create Home Folder and Set
Permissions
createHomeDirectory
True
Telephones Tab
Display Name
Attribute Name
Example Value
Home
homePhone
660 123 122
Home (Other)
otherHomePhone
0661 123 122
Pager
pager
1234
Pager (Other)
otherPager
123
Mobile
mobile
120 456 789
Mobile (Other)
otherMobile
121 456 789
Fax
facsimileTelephoneNumber
122 456 789
Fax (Other)
otherFacsimile
TelephoneNumber
0123 456 789
IP Phone
ipPhone
01IP
IP Phone (Other)
otherIpPhone
432493809
Notes
info
General information (Use a
semi-colon for carriage return)
Organization Tab
Display Name
Attribute Name
Example Value
Title
title
Manager
Department
department
Sales
Company
company
Big Corp
Manager
manager
"CN=SJobs,OU=Managers,DC=Domain,DC=Com"
Employee ID
employeeID
Employee Type
employeeType
Employee Number
employeeNumber
Car License
carLicense
Division
division
Middle Name
middleName
Room Number
roomNumber
Assistant
assistant
jpegPhoto
jpegPhoto
E:\photos\%username%.jpg
(25KB or less, 200x200 pixels or
less)
Exchange Tab
Display Name
Attribute Name
Example Value
Create Mailbox for User
mailboxEnabled
True or False, Required when
creating a mailbox.
Alias
mailNickname
Jsmith *Required
Simple Display Name
displayNamePrintable
Jsmith *Required
Email addresses
proxyAddresses
SMTP:JSmith@doamin.com
multiple
addresses?
Forward to
altRecipient
CN=User2,OU=Managers,DC=Domain,DC=Com
Deliver & Forward
deliverAndRedirect
True
Use MAPI Rich Text
mAPIRecipient
True or False
Hide From Address Lists
msExchHideFromAddressLists
True or False
Exchange Store
ExchangeStore
Mail-Enable User
mailEnabled*
True or False
*Do not use with mailboxEnabled
above.
External Address
targetAddress
Required when mail-enabling a
user.
Exchange
Attributes
Display Name
Attribute Name
Example Value
extensionAttribute1
extensionAttribute1
extensionAttribute2
extensionAttribute2
extensionAttribute3
extensionAttribute3
extensionAttribute4
extensionAttribute4
extensionAttribute5
extensionAttribute5
extensionAttribute6
extensionAttribute6
extensionAttribute7
extensionAttribute7
extensionAttribute8
extensionAttribute8
extensionAttribute9
extensionAttribute9
extensionAttribute10
extensionAttribute10
extensionAttribute11
extensionAttribute11
extensionAttribute12
extensionAttribute12
extensionAttribute13
extensionAttribute13
extensionAttribute14
extensionAttribute14
extensionAttribute15
extensionAttribute15
Terminal
Services Tab
Display Name
Attribute Name
Example Value
Profile Path
TSProfilePath
Home Folder
TSHomeFolder
Create Home Folder
TSCreateHomeDirectory
True or False
Deny Logon
TSDenyLogon
True or False
Dial-In Tab
Display Name
Attribute Name
Example Value
Allow Dial-In Access
msNPAllowDialin
True or False
© 2009 Dovestones Software. All rights reserved.

View the current operations master role holders

Once an operations master role has been transferred, it should be verified that the transfer has occurred successfully throughout the domain. The change must be replicated to all relevant domain members in order to truly take effect.
To view the current operations master role holders, use Ntdsutil.exe with the roles option. This option displays a list of all current role holders.
Administrative Credentials
To perform this procedure, you must be logged on as a User or an Administrator.
To view the current operations master role holder
    1. Click Start, click Run, type ntdsutil, and then press ENTER.
    2. At the ntdsutil: prompt, type roles and press ENTER.
    3. At the fsmo maintenance: prompt, type connections and press ENTER.
    4. At the server connections: prompt, type connect to server servername (where servername is the name of the domain controller that belongs to the domain containing the operations masters).
    5. After receiving confirmation of the connection, type quit and press ENTER to exit this menu.
    6. At the fsmo maintenance: prompt, type select operation target and press ENTER.
    7. At the select operations target: prompt, type list roles for connected server and press ENTER.
The system responds with a list of the current roles and the Lightweight Directory Access Protocol (LDAP) name of the domain controllers currently assigned to host each role.
    8. Type quit and press ENTER to exit each prompt in Ntdsutil.exe. Type quit and press ENTER at the ntdsutil: prompt to close the window.

Quick HTTP to HTTPS - Apache2

There are several methods for redirecting your Apache-based website visitors who might type your servers URL using the plain (non-secure) HT...