Monday, October 10, 2011

Fixing arrow keys problem in vi editor

It is really frustrating when suddenly Vi Editor behaves strangely. While typing arrow keys, the output is A, B, C, D etc. Inserting in usual way doesn't work and backspace doesn't deletes characters in insert mode. Well after searching for a while on internet I found this cool solution:

In home directory, open file .vimrc (create one if not present) and write

"set nocompatible"

save and close the file. On command line enter the command
"source .vimrc"

voila!! life is back to normal!


Saturday, February 5, 2011

MySQL

Some command for MySQL

Command to shutdown mysql
C:\> mysqladmin -u -p shutdown

Check if mysql is running
command


Other commands

Thursday, January 27, 2011

Running Cygwin command from java

Lets take simple ls command to be run inside java code
Following are the steps

File workDir = new File("C:/cygwin/bin");
String cmd = "bash --login -i -c \" ls \"";
Runtime rt = Runtime.getRuntime();
Process pr = rt.exec(workDir+"/"+cmd, null, workDir);
int i = pr.waitFor();


if (i == 0){
BufferedReader input1 = new BufferedReader(new InputStreamReader(pr.getInputStream()));

String line=null;
while((line=input1.readLine()) != null) {
System.out.println(line);
}
}else{
BufferedReader stdErr = new BufferedReader(new InputStreamReader(pr.getErrorStream()));
// read the output from the command
String s = null;
while ((s = stdErr.readLine()) != null) {
System.out.println(s);
}
}