Tuesday, November 30, 2010

Event Properties Stop Bugcheck String 0x0000000a

SkyHi @ Tuesday, November 30, 2010

SYMPTOMS

On a computer that is running Microsoft Windows Server 2003, you may receive one of the following Stop error messages:
  • Stop 0x00000024 (0x0019033d, 0xb9958014, 0xb9957d10, 0xf70c1299)
  • Stop 0x0000000a (Parameter1, Parameter2, Parameter3, Parameter4)
  • Stop 0x000000c2 (0x00000007, 0x0000121a, 0x00000000, 0xe01d7790)
Note The four parameters in each error message vary.

When this problem occurs, information that describes the error is saved in the System log. The information resembles the following:

Event Type: Warning
Event Source: USER32
Event Category: None
Event ID: 1076
User: User
Computer: Computer
Description:
The reason supplied by user User for the last unexpected shutdown of this computer is:
System Failure: Stop error
Reason Code: 0x805000f
Bug ID:
Bugcheck String: 0x00000024 (0x0019033d, 0xb9958014, 0xb9957d10,
0xf70c1299)
Comment: 0x00000024 (0x0019033d, 0xb9958014, 0xb9957d10, 0xf70c1299)

CAUSE

This problem occurs because the NTFS driver incorrectly locks the resource when the NTFS driver tries to access the resource.

RESOLUTION


Hotfix information

A supported hotfix is available from Microsoft. However, this hotfix is intended to correct only the problem that is described in this article. Apply this hotfix only to systems that are experiencing this specific problem. This hotfix might receive additional testing. Therefore, if you are not severely affected by this problem, we recommend that you wait for the next software update that contains this hotfix.

If the hotfix is available for download, there is a "Hotfix download available" section at the top of this Knowledge Base article. If this section does not appear, contact Microsoft Customer Service and Support to obtain the hotfix.

Note If additional issues occur or if any troubleshooting is required, you might have to create a separate service request. The usual support costs will apply to additional support questions and issues that do not qualify for this specific hotfix. For a complete list of Microsoft Customer Service and Support telephone numbers or to create a separate service request, visit the following Microsoft Web site:
http://support.microsoft.com/contactus/?ws=support
(http://support.microsoft.com/contactus/?ws=support)
Note The "Hotfix download available" form displays the languages for which the hotfix is available. If you do not see your language, it is because a hotfix is not available for that language.

Prerequisites

To apply this hotfix, you must have Windows Server 2003 Service Pack 1 or Windows Server 2003 Service Pack 2 installed.

For more information, click the following article number to view the article in the Microsoft Knowledge Base:

889100 

(http://support.microsoft.com/kb/889100/
)


How to obtain the latest service pack for Windows Server 2003

Restart requirement

You must restart the computer after you apply this hotfix.

Hotfix replacement information

This hotfix does not replace any other hotfixes.

File information


The English version of this hotfix has the file attributes (or later file attributes) that are listed in the following table. The dates and times for these files are listed in Coordinated Universal Time (UTC). When you view the file information, it is converted to local time. To find the difference between UTC and local time, use the Time Zone tab in the Date and Time item in Control Panel.

REFERENCES
http://support.microsoft.com/kb/937455

Monday, November 29, 2010

regular expression with grep

SkyHi @ Monday, November 29, 2010
 

Searching Files Using UNIX grep

The grep program is a standard UNIX utility that searches through a set of files for an arbitrary text pattern, specified through a regular expression. Also check the man pages as well for egrep and fgrep. The MPE equivalents are MPEX and Magnet, both third-party products. By default, grep is case-sensitive (use -i to ignore case). By default, grep ignores the context of a string (use -w to match words only). By default, grep shows the lines that match (use -v to show those that don't match).
Text version.

% grep BOB tmpfile{search 'tmpfile' for 'BOB' anywhere in a line}
% grep -i -w blkptr * {search files in CWD for word blkptr, any case}
% grep run[- ]time *.txt{find 'run time' or 'run-time' in all txt files}
% who | grep root {pipe who to grep, look for root}

Understanding Regular Expressions

Regular Expressions are a feature of UNIX. They describe a pattern to match, a sequence of characters, not words, within a line of text. Here is a quick summary of the special characters used in the grep tool and their meaning:
Text version.

^ (Caret)=match expression at the start of a line, as in ^A.
$ (Question)=match expression at the end of a line, as in A$.
\ (Back Slash)=turn off the special meaning of the next character, as in \^.
[ ] (Brackets)=match any one of the enclosed characters, as in [aeiou]. Use Hyphen "-" for a range, as in [0-9].
[^ ]=match any one character except those enclosed in [ ], as in [^0-9].
. (Period)=match a single character of any value, except end of line.
* (Asterisk)=match zero or more of the preceding character or expression.
\{x,y\}=match x to y occurrences of the preceding.
\{x\}=match exactly x occurrences of the preceding.
\{x,\}=match x or more occurrences of the preceding.

As an MPE user, you may find regular expressions difficult to use at first. Please persevere, because they are used in many UNIX tools, from more to perl. Unfortunately, some tools use simple regular expressions and others use extended regular expressions and some extended features have been merged into simple tools, so that it looks as if every tool has its own syntax. Not only that, regular expressions use the same characters as shell wildcarding, but they are not used in exactly the same way. What do you expect of an operating system built by graduate students?
Since you usually type regular expressions within shell commands, it is good practice to enclose the regular expression in single quotes (') to stop the shell from expanding it before passing the argument to your search tool. Here are some examples using grep:
Text version.

grep smug files{search files for lines with 'smug'}
grep '^smug' files{'smug' at the start of a line}
grep 'smug$' files{'smug' at the end of a line}
grep '^smug$' files{lines containing only 'smug'}
grep '\^s' files{lines starting with '^s', "\" escapes the ^}
grep '[Ss]mug' files{search for 'Smug' or 'smug'}
grep 'B[oO][bB]' files{search for BOB, Bob, BOb or BoB }
grep '^$' files{search for blank lines}
grep '[0-9][0-9]' file{search for pairs of numeric digits}

Back Slash "\" is used to escape the next symbol, for example, turn off the special meaning that it has. To look for a Caret "^" at the start of a line, the expression is ^\^. Period "." matches any single character. So b.b will match "bob", "bib", "b-b", etc. Asterisk "*" does not mean the same thing in regular expressions as in wildcarding; it is a modifier that applies to the preceding single character, or expression such as [0-9]. An asterisk matches zero or more of what precedes it. Thus [A-Z]* matches any number of upper-case letters, including none, while [A-Z][A-Z]* matches one or more upper-case letters.
The vi editor uses \< \> to match characters at the beginning and/or end of a word boundary. A word boundary is either the edge of the line or any character except a letter, digit or underscore "_". To look for if, but skip stiff, the expression is \. For the same logic in grep, invoke it with the -w option. And remember that regular expressions are case-sensitive. If you don't care about the case, the expression to match "if" would be [Ii][Ff], where the characters in square brackets define a character set from which the pattern must match one character. Alternatively, you could also invoke grep with the -i option to ignore case.
Here are a few more examples of grep to show you what can be done:
Text version.
 
grep '^From: ' /usr/mail/$USER{list your mail}
grep '[a-zA-Z]'{any line with at least one letter}
grep '[^a-zA-Z0-9]{anything not a letter or number}
grep '[0-9]\{3\}-[0-9]\{4\}'{999-9999, like phone numbers}
grep '^.$'{lines with exactly one character}
grep '"smug"'{'smug' within double quotes}
grep '"*smug"*'{'smug', with or without quotes}
grep '^\.'{any line that starts with a Period "."}
grep '^\.[a-z][a-z]'{line start with "." and 2 lc letters}


REFERENCES
http://www.robelle.com/smugbook/regexpr.html

sort unique duplicated column awk cut uniq

SkyHi @ Monday, November 29, 2010
Step 1:
#end with bb or cc
grep "bb$" virtusertable

Step 2:
#print column1 and colum2 and sort by column2 and keep the first unique line
awk '{print $1,$2}' virtusertable | sort -k2 -u > sortcolum2u.txt

Step 3:
#That will delete lines containing crap[0-3].
grep -Ev 'crap0|crap1|crap2|crap3'

Step 4:
#keep first column
awk '{print $1}' virtusertable 

Step 5:
#print column1 and column2, sort by column2(domain)
awk -F@ '{print $1,$2}' virtusertableColumn1.txt|sort -k2 > virtusertableFsortdomain.txt

Step 6:
##replace space with @
:%s/\s/@/g



REFERENCES
http://www.linuxquestions.org/questions/linux-general-1/sed-or-grep-delete-lines-containing-matching-text-446640/

http://efreedom.com/Question/1-1915636/Way-Uniq-Column
http://stackoverflow.com/questions/2978361/uniq-in-awk-removing-duplicate-values-in-a-column-using-awk
http://www.softpanorama.org/Tools/sort.shtml



Counting unique values in a column with a shell script
$ cut -f2 file.txt | sort | uniq | wc -l


#Finding unique records from file
01224624005
01224626366
01224627408
01224626366
01224627408
##return duplicated lines 01224626366 01224627408
uniq -d sorted_sme.txt > dup_sme.txt
##return unique lines  01224624005
uniq -u sorted_sme.txt > unq_sme.txt

REFERENCES
http://www.computing.net/answers/unix/finding-unique-records-from-file/4591.html

Processing the delimited files using cut

cut command print selected parts of lines from each FILE (or variable) i.e. it remove sections from each line of files:

For example /etc/passwd file is separated using character : delimiters.

To print list of all users, type the following command at shell prompt:
$ cut -d: -f1 /etc/passwd
Output:

root
you
me
vivek
httpd

Where,

* -d : Specifies to use character : as delimiter
* -f1 : Print first field, if you want print second field use -f2 and so on...

Now consider variable service. Let us print out mail word using cut command:
$ service="http mail ssh"
$ echo $service | cut -d' ' -f2

mail

Note that a blank space is used as delimiter.
Processing the delimited files using awk

You can also use awk command for same purpose:
$ awk -F':' '{ print $1 }' /etc/passwd
Output:

root
you
me
vivek
httpd

Where,

* -F: - Use : as fs (delimiter) for the input field separator
* print $1 - Print first field, if you want print second field use $2 and so on


REFERENCES
http://www.cyberciti.biz/tips/processing-the-delimited-files-using-cut-and-awk.html

Friday, November 26, 2010

Setting up the firewall in Mac OS X 10.5 (Leopard)

SkyHi @ Friday, November 26, 2010
After receiving a port scan this morning (thanks for the new year present):

I’ve came to realize that I need to setup the firewall on my Mac asap before someone decided to take a tour of my iMac. Until recently, I’ve always use my PC laptop to surf the Internet, so I always forgot to setup the firewall on my Mac…but after the incident it looks like I have to act quick before things got out of hand. If you are new to Leopard and you have no idea how to setup the firewall, here is a simple step by step guide:
Step 1: Click on the System Preferences icon on your dock:

Step 2: Click on Security:

Step 3: Click on Firewall:

Step 4: By default, the firewall will allow all incoming connections…which is not very helpful at all:

We need to change that by clicking on the 3rd option:

Step 5: Now click on the “+” button at the bottom left hand corner to choose which your application(s) you want to allow or block access by the firewall:

Select the application(s) you want and click on the Add button.
Step 6: After you have added your application(s), click on the Advanced button:

As you can see, the Stealth Mode is not turned on by default:

Turn on the Stealth Mode and click on the OK button:
Step 7: The applications you have added are allowed (incoming connections) by default, if you want to block some of your application(s), just click on that application and change to “Block incoming connections“:

- – - -
I hope this article will help you to setup your firewall
REFERENCES

BAD HEADER, Improper use of control character (char 0D hex)

SkyHi @ Friday, November 26, 2010
I looked at the headers of a message from pligg by chance and saw this in there.


X-Amavis-Alert: BAD HEADER, Improper use of control character (char 0D hex):

From: webmaster@nothing.no.no\r\n


So my Amavis virus filtering didn't like the \r\n - which I don't believe is needed. I tested it with just the \n and no problems. It still passes but the more stringent mail systems may bounce it.


diff linkadmin.php.original linkadmin.php

117c117

< $headers = 'From: ' . PLIGG_PassEmail_From . "\r\n";

---

> $headers = 'From: ' . PLIGG_PassEmail_From . "\n";


editlink.php, login.php, recommend.php also have this. In recommend.php on line 91 it looks like it was fixed. It was commented out and has a line below with just the \n and no \r.


I looked at the svn from last night - 407 I think?


I solved the issue by turning almost all \r\n into \n in the php

module called "compose2.php". I hope I will not have to do the same

with the whole code...

REFERENCES
http://forums.pligg.com/questions-comments/2801-emails-have-control-character-them.html
http://osdir.com/ml/mail.ilohamail.devel/2007-03/msg00000.html

Remote Desktop Into Mac OS X Leopard From Windows

SkyHi @ Friday, November 26, 2010

Using remote desktop, you can access one computer from another computer through the internet or a local area network. Here, I’ll outline how to remote desktop into Mac OS X 10.5 (Leopard) from Windows, which is something I had to do today.

On the Mac, go to System Preferences > Sharing and check “Remote Login,” if it is unchecked. You may get a message saying that your current power settings will not allow remote login when the Mac is sleeping. Just hit OK for that and Take note of the example ssh command given in the information area.

Then check “Screen Sharing,” if it is unchecked. Click the “Computer Settings” button on the right. A prompt should appear. Check “VNC Viewers may control screen with password” and type in a memorable password. Then hit OK and uncheck “Screen Sharing.” This is a security precaution. You will turn this on later when you ssh in.

On your PC, you will need to install PuTTY and TightVNC. You can get PuTTY here: http://www.chiark.greenend.org.uk/~sgtatham/putty/ and TightVNC from here: http://www.tightvnc.com/download.html.

On your PC, open up PuTTY, and in the “Host Name” field, type in the host name of the computer. This is the text after the @ symbol in the provided ssh command example noted earlier, e.g. my.host.name.edu. Select SSH as the connection type.

Then, on the left category menu, click on Tunnels, which is under Connection > SSH. For the “Source Port” box, type 5901, and for the “Destination” box, type localhost:5900. Then hit the Add button. And then hit the Open button in the bottom-right.

A black window will appear and a prompt may appear, asking you whether you trust the host. Click yes. Then, in the black window, you will be asked for your login name – enter your Mac login name. Then it will prompt for your password – enter that too.

Then, enable Screen Sharing by entering the following commands into PuTTY:
cd /Library/Preferences
echo -n enabled > com.apple.ScreenSharing.launchd
Next, open up TightVNC Viewer on your PC. It will prompt you for a VNC Server. Enter localhost:1. (This is possible because you are tunneling Port 5901 through SSH.) Hit "Connect." You should then be prompted for a password. Enter the VNC password that you set earlier.

That's it! A window should appear on your PC with the exact same display as your Mac and you should be able to control the mouse and do most things remotely.
Unfortunately, this method can yield severe lag between the two computers, especially if your Mac's internet connection has a slow upload speed.

One performance tweak you can do on the Mac is enter into a Terminal:
defaults write com.apple.ScreenSharing controlObserveQuality 3
This changes the quality of the remote display to setting 3 which is 8-bit color. The other settings are:
1 = black and white
2 = grey scale
3 = 8 bit color
4 = 16 bit color
5 = full color

Just replace the "3" in the command with the number of the desired setting.
You should probably also change your mac desktop wallpaper to a solid color and/or reduce the resolution so the screen image is more easily compressed.

Finally, before you close the connection, you should disable Screen Sharing. In your PuTTY window, which you must keep active while you are on VNC, enter the following commands:
cd /Library/Preferences
rm com.apple.ScreenSharing.launchd
Edit: Apparently, removal of this file and disabling of Screen Sharing only takes place after you restart the computer. i.e. after you remove this file, you can still vnc into the system. However, I don't know whether you can still vnc into it from a computer different from the one from which you originally vnc'd. You can restart the system immediately (closing all open files without saving changes) with:
sudo shutdown -r now
And that's it! You should now be able to remote desktop into Mac OS X Leopard securely from a Windows machine. Happy remote desktop-ing! Also, please leave a comment below if this was helpful or if you have any questions.

Note: If you have Cygwin installed like I do, then you can just open up a Cygwin shell window and enter:
ssh username@hostname -L 5901:localhost:5900
to ssh in with port forwarding.

Note 2: If you want to be able to access your Mac anytime, go to Energy Saver, which is also in System Preferences, and move the slider for Time Before Sleep to Never. You can also schedule automatic turn on/off of the Mac to save energy, e.g. have it off while you're asleep.

References:
http://lifehacker.com/319528/remote-control-leopard-with-tightvnc
http://www.macosxhints.com/article.php?story=20080318190503111
http://www.alternapop.com/2007/12/01/leopard-screen-sharing-image-quality/
http://www.whenbrainsfly.com/2009/01/remote-desktop-into-mac-os-x-leopard-from-windows/

rsync error: "IO error encountered -- skipping file deletion"

SkyHi @ Friday, November 26, 2010
IO error encountered -- skipping file deletion


Figured it out....



In hardy there is a hidden folder in /home/user/ called .gvfs...No idea what it is, but just exclude it from your rsync backup.

REFERENCES
http://ubuntuforums.org/showthread.php?t=290617