Set value of the variable in “FOR” loop in Window batch script

Window No Comments

Running for loop and setting the variable values within the for loop is different in window batch file comparing to other scripting or programming language.

Following example is trying to get the total value of 1, 2, 3 and 4.

set COUNT=0
for %%F in (1 2 3 4) do (
set /A COUNT=!COUNT! + 1
echo %COUNT%
)

But we will get:

0
0
0
0

This is because batch processor expands the variable only once, thus %COUNT% is expanded to its value, which is the initial value, 0.

To fix this, ENABLEDELAYEDEXPANSION can be turned on to delay the batch processor expanding the variable the end of the looping. Also, using ! instead of % to expand the environment variable value.

setlocal ENABLEDELAYEDEXPANSION
set COUNT=0
for %%F in (1 2 3 4) do (
set /A COUNT=!COUNT! + %%F
echo !COUNT!
)

The result of the above code is:

1
3
6
10

There’s another way to enable the delay expansion is through the registry. Please refer to http://batcheero.blogspot.com/2007/06/how-to-enabledelayedexpansion.html.

Writing files to NTFS drive in Snow Leopard

Mac OS No Comments

Had problem in writing files to my external harddisk with NTFS format through Snow Leopard.

In some forum, expert recommended to use free utility tools like: iNTFS and NTFS mounter

Write files to NTFS drive is actually supported by Snow Leopard but this functionality is not enabled by default. The above utility tools are useful for Leopard, as Leopard does not support write operation. To enable the write operation fro NTFS drive in Snow Leopard:

  1. In Terminal, type diskutil info /Volumes/volume_name, where volume_name is the name of the NTFS volume. From the output, copy the Volume UUID value to the clipboard.
    diskutil info /Volumes/drive_name
  2. Back up /etc/fstab if you have it; it shouldn’t be there in a default install.
    sudo cp /etc/fstab /etc/fstab.ori
  3. Type sudo nano /etc/fstab
    sudo vi /etc/fstab
  4. In the editor, type UUID=, then paste the UUID number you copied from the clipboard. Type a Space, then type none ntfs rw. The final line should look like this:
    UUID=123-456-789 none ntfs rw

    where 123-456-789 is the UUID you copied in the first step.

  5. Repeat the above steps for any other NTFS drives/partitions you have.
  6. Save the file and quit nano (Control-X, Y, Enter), then restart your system.
  7. Restart the computer, the added NTFS drive should be able to be written.

Useful link:

  1. http://www.macosxhints.com/article.php?story=20090913140023382
  2. http://www.insanelymac.com/forum/index.php?showtopic=211212

Lock Hunter

Window No Comments

Finding trouble deleting your Window files because the files are locked? I had been using Unlocker in Window XP.

However, after upgraded to Window 7 (64bits) Unlocker is not working anymore. Alternative application can be used to unlock file: LockHunter. LockHunter, not to mentioned works in both Window 32bits and 64bits, it also provides better features comparing to Unlocker. List of features can be found in: http://lockhunter.com/index.htm

Continue unlocking window file….

EFTPOS Terminal Machines

Uncategorized No Comments

The evolution of the EFTPOS Machine has changed the way both retailers and consumers do business. Before the introduction of electronic payment systems, physical money was the primary method of payment. These systems have made business transactions more efficient, easier and safer for everyone.

The advantages to both business and consumer are many. Transactions are more efficient because there is no physical handling of bank notes and coins. This means fewer errors can occur due to human error because it is all automated. It is more convenient for consumers to carry a single card than bulky notes and this also applies to businesses as they don’t need to store cash.

Transactions with EFTPOS also provide a higher level of safety over cash transactions. Shops can minimize the amount of money in the store and so lose less in case of robbery. For the consumer, losing their cards does not mean losing their money immediately because of the secure PIN.

However there are also some disadvantages. The main disadvantage is that an EFTPOS Terminal may not be available everywhere, although this is becoming increasingly less in this modern age. Businesses will also need to provide extra training on the use of an EFTPOS Machine. Another disadvantage is that financial institutions may impose limits on the daily use of debit and credit cards, which is often a security measure.

Work behind proxy with subversion

Uncategorized No Comments

To checkout (or perform any other svn command) svn content from repository outside the proxy, modify ther servers file:

  • Linux/Mac OS X:

    [html]
    vi ~/.subversion/servers
  • Window 7/Window Server 2008:

    [html]
    cd %USERPROFILE%\AppData\Roaming\Subversion
    start servers

By uncommenting the following line and add your detail

[html]
http-proxy-host = your.proxy.com
http-proxy-port = 8000
http-proxy-username = defaultusername
http-proxy-password = defaultpassword

Role Management Tool

Window No Comments

I was trying to install Microsoft® Visual C#® 2010 Express in Window Server 2008 R2 Standard (64-bit). In my installation i exclude the installation of Microsoft® SQL Server 2008 (64-bit). Half way during installation, I encounter this error: “You must use role management tool to install or configure Microsoft .net Framework 3.5″.

In order to continue the installation I need to enable the usage of Role Management Tool as requested:
Step 1. Start -> Administrative Tools -> Server Manager

Step 2. On the left hand side, click on Features

Step 3. On the right hand side, click on Add Features link
screenshot

Step 4. Click on .NET Framework 3.5.1 Features checkbox and Add Features Wizard will be shown
screenshot-1

Step 5. Click on Add Required Role Service button
screenshot-2

Step 6. The .NET Framework 3.5.1 Features checkbox should be checked. Click on Next button.
screenshot-3

screenshot-4

screenshot-5

Step 7. Once the Install button is enabled, click on the button to finish up the installation
screenshot-6

screenshot-7

Hope this help!

Installing new font in Mac OS X and Window

Mac OS, Open Office, Window No Comments

Font can be downloaded from http://www.1001freefonts.com/medieval-fonts.php (NOTE: Commercial use need to have license)

Mac OS X:

  • Download the font for Mac OS X
  • Double click on the downloaded font (.ttf extension), “Font Book” will be opened and click on “Install Font”

Window:

  • Download the font for Window
  • Go to “Control Panel” and click on “Fonts”. Click on “Install New Font” from the “File” menu
  • Browse to the downloaded font file from step 1

To test if the font is working: Open any word processor e.g. OpenOffice.org and you will see the new font in the Style list

Install Apache2, Php5 and MySql on Ubuntu 9.10

MySql, PHP, Ubuntu/Linux No Comments

Step 1. List of libraries needed for Apache2, Php5 and MySql for Ubuntu:

[html]
apt-get update
apt-get install  apache2 libapache2-mod-php5 mysql-server libapache2-mod-auth-mysql php5-mysql php5

Step 2. Turn on php module to work with Apache:

[html]
a2enmod php5

Step 3. If you have .phtml or .pl file, remember to add to the follwing line to apache configuration file (/etc/apache2/apache2.conf):

[html]
AddType application/x-httpd-php .php .phtml

Step 4. Restart apache:

[html]
/etc/init.d/apache2 restart

Useful Link:

  • http://ubuntuforums.org/showthread.php?t=277819
  • http://ubuntuforums.org/showthread.php?t=479194&page=2

Increase file upload for php in Apache

PHP, Ubuntu/Linux No Comments

When working with moodle, I always encounter file upload size problem (normally 2M). To increase file upload size, edit /etc/php5/apache2/php.ini file (in Ubuntu 9.10) for PHP 5 and Apache 2 by changing the upload maximum filesize to the size you want:

[html]
upload_max_filesize=30M

Save the file and restart apache:

[html]
sudo /etc/init.d/apache2 restart

iFolder Client on Ubuntu 9.10

Ubuntu/Linux No Comments

Installing ifolder client in Ubuntu 9.10:

  • Step 1. Add source list to aptitude by:
    [html]
    sudo add-apt-repository ppa:marceloshima/ppa

    or manually add the following lines to /etc/apt/sources.list:

    [html]
    deb http://ppa.launchpad.net/marceloshima/ppa/ubuntu karmic main
    deb-src http://ppa.launchpad.net/marceloshima/ppa/ubuntu karmic main
  • Step 2. Update aptitude to get the latest list of software:
  • [html]
    sudo apt-get update
  • Step 3. Install ifolder3
    [html]
    sudo apt-get install ifolder3
  • Step 4. Modify /usr/bin/ifolder file by chaging:
    [html]
    cd /usr

    to

    [html]
    cd /usr/bin
  • Step 5. Run ifolder (it won’t be run automatically for ubuntu) by typing:
    [html]
    ifolder
  • Step 6. Fill in your ifolder server information and you are ready to go!

Useful links:

  • https://edge.launchpad.net/~marceloshima/+archive/ppa
  • http://www.x2b4.com/howto/how-to-install-ifolder-on-ubuntu-server/

« Previous Entries