Thursday, December 07, 2006

Copy files from windows to linux

Setting up a cron job to transfer files among linux boxes is easy. But when you mix some windows boxes into the picture, things get complicated. That is because most windows boxes don't have ssh daemon setup.

But one thing you can do is to run pscp on windows to fetch files from Linux. You can download pscp here

To get started you make a .bat file like this on your windows box: c:\path\to\pscp.exe –pw password username@host.of.linux:/path/to/file c:\path\to\destination
Then you use windows scheduler to schedule a task to run this batch file.

Of course to make it more secure (or just for the peace of mind) you want to hide your password, you can use a public/private key pair. For details reference this doc:

Thursday, November 09, 2006

Today when I install a package on my newly installed Ubuntu box, I got this error when run ./configure: C compiler cannot create executables. I installed gcc then but still getting the same error.

By search the Ubuntu forum, I found this command to quickly install a c compiler, maybe other compilers too.

apt-get install build-essential

Just a quick tip for beginners running into the same problem.

Tuesday, October 31, 2006

When doing JasperReports yesterday, I encoutered a weird problem. I have some text fields that holds long strings, so the text has to be wrapped. So I set the text fields to stretch with overflow. It worked fine in iReports 1.2.6. But after deploying it to a web application (Centric CRM), some text fields got the last line cut off, just the last line. And this is not happening on all fields in a page, just some.

I tried different versions of JasperReports and Lowagie iText libraries without any luck. Eventually I figured it out. I have the text fields height set to 18 pixels and my detail band set to 20 pixels so I can get a little padding on top and bottom. Somehow these little padding confused JasperReports. After setting all textfields and band to 20 pixels height, everything worked fine. To archieve the little padding, I set the padding in the Border tab in Properties dialog.

Long story short: When doing JasperReports, if you get the last line cut off when setting Textfield to stretch with overflow, check the text field height and band height. It may help.

Thursday, October 19, 2006

Top is a simple yet powerful command to see what is going on in your Linux system.

The most straight forward way to use top is typing top in your command line. This will give a a quick view of the processes in the system. Those key strokes are useful in this mode:

  1. q, quit
  2. space or enter, refresh the view
  3. M, sort by %MEM column
  4. T, sort by TIME column
  5. P, sort by %CPU column
  6. m, toggle memory usage section display (less useful)
  7. t, toggle task/cpu section display (less useful)
You can also run top in batch mode and pipe results out for post processing. For example:
top -b > /tmp/top.output
This will give you one snapshot. For multiple iterations, you can use -n # option. Also you can limit your output to certain processes by specifying process id. For example:
top -b -n 5 -p 12639, 6932 > /tmp/top.output
This will give you 5 iterations of usage of process 12639 and 6932

One last option in batch mode you may need is -u or -U which is the user id or name. For example:
top -b -n 2 -u alex
top -b -n 2 -u 1012

You can set up a cron job to run top periodically and process the output if your application doesn't have more sophisticated monitoring mechanism built in.