Category Archives: Tips and Tricks

Locale issue in Linux VPS Box

In case of a new Linux VPS box it is possible that you might encounter an error like this:

perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = (unset),
LC_CTYPE = “UTF-8”,
LANG = “en_US.UTF-8”
are supported and installed on your system.
perl: warning: Falling back to the standard locale (“C”).

To solve this error the following approach worked for me on my Debian box. Execute the following command

sudo vi /etc/ssh/sshd_config

In this file comment the following line. This line basically allows the client OS to pass it’s environment parameters to the remote server which can cause issues.

AcceptEnv LANG LC_*

Save the file and reboot the VPS box. After rebooting this error should not ideally come. If you are still getting this error then it is possible that you don’t have the locale installed. The following command might help you in resolving this problem.

sudo locale-gen
sudo dpkg-reconfigure locales

 

Prioritizing Network Connection in Windows

Windows somehow gives LAN cable connection priority for connecting to internet. This was a mystery which has boggled me for quite some time. Recently I landed in a scenario where on my laptop I had a LAN cable connection as well as a WiFi connection. Now in this situation both Ethernet and WiFi adapter have got internet access via different ISP and the gateway for both are different. Now I wanted my FTP client to download stuffs via my LAN cable and I wanted my Dropbox client to upload files via my WiFi connection. After spending some time on internet I found out that the only solution that guarantees result is to take control over the metrics of the network adapters. If the metrics of WiFi is made lower than the metrics of Ethernet then Windows OS routes all internet traffic via WiFi. After changing the metrics I checked and confirmed that my Browser and Dropbox applications were using WiFi instead of Ethernet. This seems to be working reliably for now. I performed the following steps:

  1. Open command prompt (type cmd.exe in Start Menu in Win 7 or in Run dialog in Win XP).
  2. Type ncpa.cpl (This will open the network connections windows)
  3. Right click on your Wireless Network Connection adapter (WiFi).
  4. Click on “Properties” in the popup. This will open the properties dialog.
  5. In the properties dialog choose “Internet Protocol Version 4 (TCP/IPv4)”.
  6. Click on “Properties” button. This will open the “Internet Protocol Version 4 (TCP/IPv4) Properties”.
  7. Click on the “Advanced” button. This will open the “Advanced TCP/IP Settings”.
  8. In this dialog uncheck the “Automatic Metric” checkbox.
  9. Type ‘1’ without quotes in the “Interface metric” text field.
  10. Click on OK in this dialog and the underlying dialog to save your changes. Click on “Close” in the properties dialog to conclude this task.
  11. Now in the Network Connections window select your “Local Area Connection” (Ethernet Adapter).
  12. Repeat steps 4 through 10 with the only difference that in step 9 type ‘2’ instead of ‘1’.
  13. That’s it you are done.

The idea is that if you provide a lower metrics to your WiFi and a higher metrics to your LAN/Ethernet adapter then Windows OS will always use your WiFi connection for all Internet traffic. This worked well for me.

Using wget to do high speed HTTP transfer within LAN

Today I needed to transfer contents between my Linux servers using a CAT5 LAN connection. The source server served files via HTTP and also had a FTP server running. I ruled out using FTP for transfer as I wanted to do the transfer via command line recursively so the natural candidate was wget. On the target Linux box I executed the following command to get a good transfer speed:
wget -r -nH –cut-dirs=2 –no-parent –reject=”index.html*” http://192.168.111.116/files/dump/
The speed received was something like this:
Downloaded: 2476 files, 27G in 45m 49s (10.0 MB/s)

This completed the job in a a short while with no residual HTML file being generated in target.

Macro Recording Solution

In due course of development I came across a project which required me to extract thousands of file attachments from a MS Access 2010 file. This is a new feature of access and relatively less documented feature for which no third party tools are available to facilitate automated extraction of all the attachments. Manually extracting all the attachments was not an option so I started looking for programmatic ways to do it. Although I did find some ways by which I could use the native scripting of MS Access to extract all the files but I was not sure if it would work reliably. So I started looking for automated macro based solutions and I remembered using Jitbit Macro Recorder a couple of years back. This solution promised some hopes of allowing me to do what I wanted to do without throwing a new programming language in my way. So I went ahead and downloaded a new copy from Jitbit website. I was fairly impressed with the enhanced editor and macro recording facility. it took me very little time to record a reliable macro which could repetitively extract files from the MS Access file. Although the process was slow I was able to extract some files from MS Access without any problem. However the speed of extraction was very slow and I started to lose my patience. This is where Jitbit Macro Recorder again shined and I was able to locate the issue down to a number of unwanted delays which had crept into the recoded script due to my slow recording process. Using the inbuilt editor provided by this solution I finally removed almost 80% of the delays and then I was perceptively pleased at the faster rate of file extraction. After the final tweak the Jitbit Macro Recorder was able to extract files way faster than I could ever do manually. Overall at the end of the whole episode I was surprised that there were more than 3700 files extracted by this wonderful tool! It just worked quite reliably and didn’t crash or slowed down while dong this heavy duty operation which means the developers have done a very good job and have designed this solution for production use. There is no doubt in my mind that this tool is a very promising automation tool in my arsenal and I am going to keep using for quite sometime.