Remove control characters (^M) by search and replace in vi

If you edit a text file in a UNIX or Linux environment that has it’s origin in the DOS or Windows world, you will see that every line ends with the control character ^M. The reason is that the UNIX or Linux world only use one control character to mark an end of line and in the DOS or Windows world this is done by two control characters.

The control characters will be automatically converted if you use ASCII mode when transferring the file by FTP between the UNIX or Linux world and the DOS or Windows world.

However, if you end up with a text file in the UNIX or Linux environment that for some reason didn’t get its end of line control characters converted, you will see that every line ends with a ^M. Those ^Ms can easily be stripped away by using the search-and-replace function in the vi editor. This requires that you have a basic knowledge on how to edit files in vi.

To search and replace the ^M you use the search and replace command %s. The format for this command is:

(press ESC key once)
:%s/TEXT/REPLACE/g

where all occurences of the TEXT will be replaced by the word REPLACE. Now we want to replace a control character, so instead of TEXT we should enter ^M. If we just type the ^ character and then the M character on our keyboard, the search and replace function will not match the ^M seen in our text file. This is because they are control characters, i.e. control-M (press and hold the CTRL-key while pressing M). If we try to just press CTRL-M after the :%s/ you will get an error message.

This is because the CTRL-M is the same as pressing the Enter key. To tell vi not to interpret the CTRL-M you need to escape it. This is done by pressing and holding CTRL in the same time as the V-character once before pressing CTRL-M. In the example below, pressing and holding CTRL while pressing the V-character is shown as a ^V and pressing and holding the the CTRL while pressing the M-character is shown as a ^M.

So to search and replace all ^M in the entire file in vi you should do:

(press ESC key once)
:%s/^V^M//g

Calibrate Vivotek PT7137 from URL

The Vivotek PT7137 is a pan-tilt network camera from Vivotek.

After panning and tilting for some time, especially after hitting the boundaries a couple of times, the camera is in need of calibration. You can see this if you have some predefined postition and selecting it doesn’t bring the camera centered to the selected position.

Calibrating the camera can easily be performed by logging in as the administrative account (root) and selecting the Maintenance in the menu. The Calibrate button will immediately calibrate the camera.

However, in some cases you would like to calibrate the camera directly by entering a URL or by using a script.

Read more

Siemens Gigaset WLAN camera vulnerability

The Siemens Gigaset WLAN camera is vulnerable for unauthorized users to gain access through telnet and ftp by logging in as the user root. The user can log in without any password. When logged in, it is possible to view the cameras configuration file where the administrator password is stored in clear text.

The vulnerability is verified to exist in firmware version 1.27 but might be present in other versions too. At present time there are no updates available from Siemens later than version 1.27.

It is therefore a recommendation to maintain the Siemens Gigaset WLAN camera only on a private network or behind a firewall and to use an administrator password that is not used anywhere else.

See also the Siemens web page for Gigaset WLAN camera.

How to install both Windows XP and Easy Peasy (Ubuntu) on ASUS EEE Pc 900

Windows XP on ASUS EeePC

What you need

  • Two USB memory sticks. 2-4 GB is good for Windows and 2 GB for Easy Peasy. Sticks above 8 GB have been problematic for me.
  • A Windows XP installation CD with SP2. If you don’t have at least SP2 included, the install will blue screen. To update your Windows XP with SP2, follow this guide. If you upgrade your Windows XP installation with SP2 in a directory on the hard disk according to the Read more

Rebuild the journal in a ext3 journaled filesystem

The symptom of a broken ext3 journal is that the system will boot normaly but after a while the filesystem will be remounted read only and according to the log there are problems reading a block in the journal.

Boot on a rescue cd or boot but make sure the filesystem is in read only mode.

In this example i use /dev/md0 (the software raid device), becuase when I had this problem it was an ext3 journaled filesystem residing on a software raid that was causing trouble.

Issue the following commands

# fsck /dev/md0
# tune2fs -O ^have_journaled /dev/md0
# mount -n -o remount,rw /dev/md0
# tune2fs -j /dev/md0
# mount -n -o remount,ro /dev/md0
# fsck /dev/md0
# reboot

The first tune2fs removes the current journal on the filesystem (-O ^have_journaled). The second tune2fs (-j) recreates it. In between the filesystem must be mounted read only in order for the new journal to be written.

How to make a Windows XP install CD with SP2 or SP3

If you have a Windows XP installation CD that do not have Service Pack 2 (SP2) or Service Pack 3 (SP3) on it, you will sometimes get in trouble when trying to install it on a computer with newer hardware. If you get a blue screen of death during the installation, it might be a sign that you need to include the SP2 or SP3. Newer Windows XP installations CDs comes with a SP already included. To check if that is the case with your Windows XP installation CD, insert

Read more