Sunday, March 18, 2012

Automate removal of sensitive data or password from bash script or file

What if you would like to remove some text or password from a bash script or file which contains your sensitive data?

If you are using xUnix system such as Kubuntu, your can try the sed command, as shown in this page and below.
~$ sed -i 's/GenuinePassword/UglyPassword/g' *;
Hope this helps!

Saturday, March 17, 2012

App Manager "Operation fail" on Nokia N900

If you experience App Manager "Operation fail" on Nokia N900, which is codenamed  Maemo 5 or Fremantle  , you might want to see this post at Maemo Talk forum.

I tried the below command in the Terminal application on Nokia N900, it works after I start the App Manager again.
pkill hildon-application-manager
You might also be interested to know about Nokia N900 USB networking Maemo Wiki page and Nokia N900 hangs during installations thread.

Last updated Nokia N900 firmware/software revision (PR 1.3.1, 21.2011.38.1)


According to Maemo Talk forum, 79400 and 80102 threads, indicates that the last updated Nokia N900 (Marmo 5 or Fremantle) firmware/software revision is PR 1.3.1, which has the 21.2011.38.1 version.

Tuesday, March 13, 2012

Rename files name to its SHA1 value

Trying to rename file name to its SHA1 value? I've tried the below steps.

leonard@leonard-SX58:~/Downloads/TestFolder$ sha1sum Text\ File
dd122581c8cd44d0227f9c305581ffcb4b6f1b46  Text File
leonard@leonard-SX58:~/Downloads/TestFolder$
leonard@leonard-SX58:~/Downloads/TestFolder$ sha1sum Text\ File | awk '{print $1}'
dd122581c8cd44d0227f9c305581ffcb4b6f1b46
leonard@leonard-SX58:~/Downloads/TestFolder$

Based on this page again. I reuse and modified the "Sample Shell Script To Loop Through All Files" script again.
#!/bin/bash
FILES=*
for f in $FILES
do
  echo "Processing $f file..."
  #take action on each file. $f store current file name
  #cat $f
  SHA1_VALUE=$(sha1sum "$f" | awk '{print $1}')
  echo $SHA1_VALUE
  mv "$f" "$SHA1_VALUE"
done
Take note of this thread at Stack Overflow page. I quoted it again.

Always double-quote variable expansions "$foo" and command substitutions "$(foo)" (unless you specifically know you have not to).

Prepend string or text to file name


Trying to prepend a string or text to file name? There're two alternatives which I have tried are listed below.

First method using mmv.
leonard@leonard-SX58:~$ sudo apt-get install mmv
leonard@leonard-SX58:~$ cd ~/Downloads/TestFolder
leonard@leonard-SX58:~/Downloads/TestFolder$ ls -al

total 24
drwxr-xr-x  2 leonard leonard 4096 2012-03-13 15:04 .
drwxr-xr-x 35 leonard leonard 4096 2012-03-13 14:50 ..
-rw-r--r--  1 leonard leonard    2 2012-03-13 15:04 Text File
-rw-r--r--  1 leonard leonard    2 2012-03-13 15:04 Text File 1
-rw-r--r--  1 leonard leonard    2 2012-03-13 15:04 Text File 2
-rw-r--r--  1 leonard leonard    2 2012-03-13 15:04 Text File 3
leonard@leonard-SX58:~/Downloads/TestFolder$ mmv "*" "#1"
leonard@leonard-SX58:~/Downloads/TestFolder$ mmv "*" "PrependText_#1"
leonard@leonard-SX58:~/Downloads/TestFolder$ ls -al
total 24
drwxr-xr-x  2 leonard leonard 4096 2012-03-13 15:11 .
drwxr-xr-x 35 leonard leonard 4096 2012-03-13 14:50 ..
-rw-r--r--  1 leonard leonard    2 2012-03-13 15:04 PrependText_Text File
-rw-r--r--  1 leonard leonard    2 2012-03-13 15:04 PrependText_Text File 1
-rw-r--r--  1 leonard leonard    2 2012-03-13 15:04 PrependText_Text File 2
-rw-r--r--  1 leonard leonard    2 2012-03-13 15:04 PrependText_Text File 3
leonard@leonard-SX58:~/Downloads/TestFolder$

Second method using bash script.
Based on this page, I reuse and modified the "Sample Shell Script To Loop Through All Files" script.

#!/bin/bash
FILES=/path/to/*
for f in $FILES
do
  echo "Processing $f file..."
  #take action on each file. $f store current file name
  #cat $f
  mv "$f" "PrependText_$f"
done

Running the script above will also gives the same effect as the first method.

Sunday, March 4, 2012

"There is no disk in the drive. Please insert a disk into drive \Device\Harddisk1\DR1."


If you are experiencing "There is no disk in the drive. Please insert a disk into drive \Device\Harddisk1\DR1." error when starting a program, e.g. chrome.exe or Dropbox.exe, you might want to try the workaround below.

"There is no disk in the drive. Please insert a disk into drive \Device\Harddisk1\DR1." error.
There's a post in TechSpot, which helps us to cleanup and remove old USB storage drivers on Windows. You can get the nice DriveCleanup tool from Uwe Sieber's page to complete this task.

Please remember to run the DriveCleanup tool with Administrator privileges.
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.
C:\Windows\system32>dir C:\Users\Leonard\Downloads\drivecleanup\
 Volume in drive C has no label.
 Volume Serial Number is XXXX-XXXX
 Directory of C:\Users\Leonard\Downloads\drivecleanup
01/03/2012  19:28    <DIR>          .
01/03/2012  19:28    <DIR>          ..
20/09/2011  18:40             1,618 DriveCleanup.txt
01/03/2012  19:28    <DIR>          Win32
01/03/2012  19:28    <DIR>          x64
               1 File(s)          1,618 bytes
               4 Dir(s)   1,652,068,352 bytes free
C:\Windows\system32>C:\Users\Leonard\Downloads\drivecleanup\Win32\DriveCleanup.exe
DriveCleanup V0.8.1 (Win32)
Uninstalls non present USB hubs, USB storage devices and their storage volumes, Disks, CDROMs, Floppies, WPD devices and deletes their registry items
Freeware by Uwe Sieber - www.uwe-sieber.de
removing USB device 'USB\VID_0421&PID_02F4\353781044919304'
 OK
removing USB device 'USB\VID_04E8&PID_6860&MI_01\6&1961B21&0&0001'
 OK
removing USB device 'USB\VID_0FCE&PID_D044\3578300132302620'
 OK
...

... 
... 
Regkey delete HKLM\System\MountedDevices\\DosDevices\F:
 OK
Regkey delete HKLM\System\MountedDevices\\DosDevices\H:
 OK
Regkey delete HKLM\System\MountedDevices\\DosDevices\I:
 OK
Regkey delete HKLM\System\MountedDevices\\DosDevices\J:
 OK
Regkey delete HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\MountPoints2\H
 OK
Regkey delete HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\MountPoints2\J
 OK
Removed 36 USB devices
Removed 2 USB hubs
Removed 40 Disk devices
Removed 7 CDROM devices
Removed 0 Floppy devices
Removed 47 Storage volumes
Removed 35 WPD devices
Removed 56 Keys from registry

C:\Windows\system32>
Phew! I do have a lot of old USB storage drive in my home Windows 7 computer. O.O

Update (19 March 2012, 19:45): It seems that this issue is not resolved completely by cleaning up old USB drivers.

I tried to scan my computer to find anything suspicious. I started a full scan of my compueter using both Microsoft Safety Scanner and F-Secure Online Scanner, which both are free to use. I didn't find anything suspicious on my computer.

Afterward, I need to recall when the symptoms actually start to occur. I recalled that I did a major cleanup on my computer by removing rarely used programs. This step points me to check my %PATH% environment variable. I saw that my %PATH% environment variable has many broken paths included.


C:\Program Files\PC Connectivity Solution\;
C:\Program Files\Common Files\Microsoft Shared\Windows Live;
C:\Perl\site\bin;
C:\Perl\bin;
C:\Symbian\Tools\ADT_1.4\Carbide.c++\x86Build\Symbian_Tools\Command_Line_Tools;
%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;
%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;
C:\Program Files\TortoiseSVN\bin;
C:\Qt\4.6.3\bin;
C:\strawberry\c\bin;
C:\strawberry\perl\site\bin;
C:\strawberry\perl\bin;
C:\Program Files\Common Files\Symbian\tools;
C:\Program Files\CSL Arm Toolchain\bin;
D:\AndDev\android-sdk-windows\tools;
C:\Program Files\Windows Live\Shared;
C:\MinGW\bin;
C:\QtSDK\Desktop\Qt\4.7.1\mingw\bin;
C:\Program Files\Calibre2\;

By checking and removing the broken paths, as shown above, I did manage to cleanup the %PATH% variable. Thereafter, this issue is resolved completely.

Hope this helps!



Cannot connect to wireless network on Kubuntu?

I cannot connect to wireless on Kubuntu. I'm running Kubuntu on Asus X59SL series laptop. I did checked that I turned on wireless using wireless hardware key and enable wireless networking in the tray area. But, I still cannot connect to wireless network. After asking in #kubuntu channel in Freenode IRC, I got the solution below. I cannot recall who replied me on IRC, but I wanna say thank you!

To enable wireless on your Kubuntu, you can use the command below.

leonard@Leonard-X59SL:~$ rfkill list
0: phy0: Wireless LAN
Soft blocked: yes
Hard blocked: no
1: hci0: Bluetooth
Soft blocked: yes
Hard blocked: no
leonard@Leonard-X59SL:~$ sudo rfkill unblock all
[sudo] password for leonard:
leonard@Leonard-X59SL:~$ rfkill list
0: phy0: Wireless LAN
Soft blocked: no
Hard blocked: no
1: hci0: Bluetooth
Soft blocked: no
Hard blocked: no
leonard@Leonard-X59SL:~$
Remember that you need to unblock both soft and hard block for your wireless interface on Kubuntu platform to enable wireless networking.