Posts Tagged ‘bash’

cygwin: setup.exe crashes whem upgrading packages

Monday, November 5th, 2007

I´ve run into a very strange problem.

Every time I run setup.exe and try to upgrade bash package

setup.exe crashes with the familiar “setup.exe has generated errors and will be close by windows. you will need to restart the program. An error log is beign created”. The solution I found is for bash package but I guess it also work for other packages as well

After googling a bit I found the this mail thread . But there was no solution posted into the thread so I tried to contact the Mario Frasca (one of the participants in the mail thread) to see if he found any solution to the problem. Well, he did. He sent me a mail telling me that William Crosmun resolved his problem.

It seems that /etc/setup/bash.lst.gz become corrupted

and if you delete it

and retry the upgrade now everything should work.

UPDATE: Please make a backup of the file before deleting it. If deleting the file solve the issue then please fill a bug report at cygwin and include that file. Or post a comment here and I will try to take care of it.

Hope it helps. Remember that if your setup.exe crashes while upgrading a package other than bash you should try to delete otherpackage.lst.gz instead of bash.lst.gz.

bash: clear: command not found

Wednesday, September 26th, 2007

If your are getting “bash: clear: command not found” on you first install of cygwin you have to make sure that you include ncurses packages in your cygwin installation. clear.exe doesn´t come in the standard installation. You must include ncurses to get clear.exe in your system. If you are using bash you can use Ctrl-L and get the same result though.

UPDATE: ncurses is a cygwin package in libs category. You can install it using the the Cygwin Setup utility (just run setup.exe again). See screenshot below

Synchronize bash history among different machines

Wednesday, May 30th, 2007

Today I finally decide to make a script to keep my bash_history synchronized among all the machines I use. It’s a simple script that retrieves all the .bash_history files from all my machines, merges all the files into one, sort it, removes the duplicated lines and write it back to all the machines. The only drawback is that the original ordering of the history files is lost due to the alphabetical sorting step (needed to remove the duplicated lines).

WARNING: Make sure that your history file size limit is big enough to hold all the combined history files. Otherwise you’ll lose some of the entries. You can go to this post for reference on how to change the history file limits

Here’s the script:

 
echo copying local history file
history -a
cp .bash_history full_history
 
HOSTS="machine1.example.com machine2.example.com"
for i in $HOSTS; do
  echo copying history file from $i
  scp $i:~/.bash_history tmp_history.txt
  cat tmp_history.txt >>full_history
  wc -l tmp_history.txt
  wc -l full_history
done
 
 
echo sorting the new history file and removing duplicates
sort full_history|uniq >uniq_history
rm full_history
 
echo replacing history file with the new one
mv uniq_history .bash_history
echo reloading bash history from file
history -c
history -r
 
 
wc -l .bash_history
 
 
for i in $HOSTS; do
  echo backing up .bash_history in $i
  DATE=`date '+%Y%m%d%H%M%S'`
  ssh $i "cp ~/.bash_history ~/.bash_history$DATE"
  echo replacing .bash_history in $i
  scp .bash_history $i:~/.bash_history
done

Enabling bash history and more

Monday, January 8th, 2007

After reading the tip I mentioned in my previous post I made some changes to my ~/.bashrc to enable bash history

alias e32="$HOME/eclipse/eclipse321/eclipse"
alias e33="$HOME/eclipse/eclipse33M4/eclipse"
alias nb="$HOME/netbeans-5.5/bin/netbeans"
 
JAVA_HOME=$HOME/jdk1.6.0
PATH=$JAVA_HOME/bin:$PATH:$HOME/bin:
 
export PATH
HISTFILESIZE=1000000000
HISTSIZE=1000000
HISTCONTROL=ignoredups 
shopt -s histappend
INPUTRC=~/.inputrc

and to my ~/.inputrc

# .inputrc
# "\e[A" and "\e[B" being whatever your terminal uses for up & down.
"\e[A": history-search-backward
"\e[B": history-search-forward

And with the following simple command I can see the commands I use most: cut -f1 -d" " ~/.bash_history | sort | uniq -c | sort -nr | head -n 30

What’s in your bash History? - O’Reilly ONLamp Blog

Friday, January 5th, 2007

Very useful tip to analyze you bash history.