Archive for September, 2009

Sep 16 2009

How to control or throttle SCP file transfer speed

Published by michael under Unix/Linux

I wanted to control how fast SCP copy data between two Linux servers. On a Linux system this can easily be achieved using the “SCP -l” switch. In my case I had to make sure to not exceed 0.5 Mbit/s

Since the “-l” parameter uses Kbit/s the correct value in my case is 500

scp -l 500 big-file.tar someuser@someserver.com:backups/.

2 responses so far

Sep 09 2009

How I fixed the problem and got my Logitech mouse working OS X 10.6 Snow Leopard

Published by michael under OS X / Apple OS

Logitech has yet to release updated keyboard and mice drivers for OS X 10.6 / Snow Leopard. I’m quite fond of my Logitech MX 510 mouse and wanted this problem fixed as soon as possible.

I used the instruction from the link below which tells you to download the “Logitech Control Center”, locate the “Logitech Control Center.mkpg” file inside the “Logitech Control Center Installer.app” and execute it. This will by-pass the OS X version check inside the Logitech installer.

I however wanted to use the installer for my mouse MX 510 which uses the “LCC Installer 2.app”. I followed the same instructions, located the “Logitech Control Center.mkpg” and executed it which successfully got the driver installed.

I found the solution to this problem here:
http://www.tuaw.com/2009/09/01/snow-leopard-get-your-logitech-mouse-and-keyboard-working-again/

No responses yet

Sep 06 2009

Want to use Spring 3.0 milestone release from Maven?

Published by michael under Java, Maven, Spring

I wanted to add the Spring 3.0 M4 milestone early access release to a Maven project to test out some of the new features. However Spring  milestone releases are not readily available in the standard public Maven repositories, so what do you do?

For the full explanation check out the link to “Spring/Maven Repositories” link in the bottom. For a quick 1-2-3 step solution add this to the <repositories> section in your Maven pom.xml file so that Maven can find Spring’s early access milestone releases:

<repository>
  <id>spring-milestone</id>
  <name>Spring Portfolio Milestone Repository</name>
  <url>http://s3.amazonaws.com/maven.springframework.org/milestone</url>
</repository>
You can then add Spring 3.0 M4 as a dependency in your pom.xml file:
<dependency>
  <groupId>org.springframework</groupId>
  <artifactId>spring-core</artifactId>
  <packaging>jar</packaging>
  <version>3.0.0.M4</version>
</dependency>
If you’re looking for other Spring artifacts you can browse them using this Spring Maven artifact URL

This Spring article has additional details on this topic e.g  how to access snapshot releases:

Spring/Maven Repositories

No responses yet

Sep 05 2009

How to automatically provide an answer to Unix commands

Published by michael under Unix/Linux

How do you automatically provide an answer to a Unix command for example

cp: overwrite `destination/./b.txt'?

Many Unix/Linux commands that operate on files may stop and ask for confirmation for each file before completing an action. Of course for many Unix/Linux commands there are parameters that allows you to specify the desired behavior, but there are other commands that doesn’t have that capability. Advanced Unix users just look up the “yes” command on how to solve this. Here’s a contrived example where a directory called “destination” contains two files “a.txt” and “b.txt”. We will now copy two files “b.txt” and “c.txt” from a directory called “source”

|-- destination
|   |-- a.txt
|   `-- b.txt
`-- source
 |-- b.txt
 `-- c.txt

We’ll copy the files using the “cp” command

cp source/*.txt destination/.

When we do this we’ll get the following response on the command line where the OS is asking us what it want us to do since one file being copied already exist in the destination directory i.e. “b.txt”

cp: overwrite `destination/./b.txt'?

Unfortunately on Linux the cp command doesn’t have an option to automatically answer this question with a ‘y’ or ‘n’ answer. There’s more than one solution to this problem depending on what you want to do, and one solution is to use the Unix “yes” command. This command will output a string repeatedly until killed. If we want to avoid overwriting any of the files in the destination directory we could use the “yes” command to answer all questions with a no “n”. Below you can see how the “yes” command is used to automatically provide the answer “n” to the “cp” command. Use “man yes” for more information about the “yes” command.

yes n | cp source/*.txt destination/.

This successfully copies all files with the exception of the “b.txt” file which is what we wanted. The “yes” command automatically provided the answer “n” to the “cp” command question whether or not we wanted to overwrite the destination file.

In the case that you mess up when you use the “yes” command for example by typing this:

yes bingo

The “yes” command will output the word “bingo” repeatedly to the screen. You can stop it by typing Control-C or in a different shell type “pgrep yes” which will display the “yes” commands PID (process ID) which you can use to kill the “yes” command by typing “kill <PID>”

pgrep yes

In my case it returned 24940 so I killed it with:

kill 24940

No responses yet