Archivo

Entradas Etiquetadas ‘bash’

BASH 4.0

martes, 24 de febrero de 2009 Sin comentarios

BASH 4.0

http://www.mail-archive.com/cygwin@cygwin.com/msg94439.html

ftp://ftp.cwru.edu/pub/bash/bash-4.0.tar.gz
ftp://ftp.gnu.org/pub/gnu/bash/bash-4.0.tar.gz

#!/usr/bin/bash
bash4=$(`echo $SHELL` --version | grep "version 4" | awk '{if (NR!=2) {print $4}}')
if [ -z $bash4 ]
	then
		wget ftp://ftp.gnu.org/pub/gnu/bash/bash-4.0.tar.gz
	else
		echo you have bash 4
fi
Categories: develop, unix/linux Tags:

Using Windows ? Don’t Kill Yourself

lunes, 27 de octubre de 2008 Sin comentarios

Using Windows ? Don’t Kill Yourself

Supose you are Linux user and you have a Windows system.

Alternatives: Cygwin, Mingw or Colinux

You need some (or all) of this interpreters:
Perl, PHP, Python and Ruby

Modify the %PATH%

Example you have a bin dir, on C:\ to include the executables on the %PATH% do this:

1
set PATH=%PATH%;C:\bin\

On Windows Vista, you can use your mouse:

computer > properties > Advances system settings > (continue) > Advanced > Enviroment Variables > System Variables > Path (edit)

Example run Kompozer on cmd.exe but no modify %PATH%

1
2
: kompozer.bat save on %WINDIR%
@"C:\Program Files\Kompozer\kompozer.exe"

Doble click on your scripts to run:

1
2
3
4
5
6
7
8
: Perl Scripts
 assoc .pl=Perl.File
 ftype Perl.File=C:\strawberry\perl\bin\perl.exe "%1" %*
 set PATHEXT=%PATHEXT%;.pl
: Python Scripts
 assoc .py=Python.File
 ftype Python.File=C:\Python26\python.exe "%1" %*
 set PATHEXT=%PATHEXT%;.py

Note:
On Windows Vista you need run cmd.exe as Administrator don’t work as normal user

Apache, PHP and MySQL ?
XAMPP and Server2Go

Notes:
XAMPP: simple, quick and easy install.
Server2Go: is great to make CD demo of a Web Application.

Using Perl or Python as CGI on Windows ?

Using Python 2.6

1
#!\python26\python.exe

Using Strawberry Perl:

1
#!\strawberry\perl\bin\perl.exe

Now your script works on http://localhost/cgi-bin/script.cgi

Categories: develop, unix/linux, windows Tags: , , , , ,

Resize Multiple Images

lunes, 20 de octubre de 2008 2 comentarios

Resize Multiple Images

En mi caso tengo que cambir el tamaño de mas de 1,000 fotografias asi que si utilizo gimp y las escalo cada una no es una buena solución.

Necesitas ImageMagick y Bash.

Subfolders:

script.sh:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/bin/bash
# fotos
IFS=$'\t\n'; # Algunas fotos puede que tengan espacios
for i in `ls`; do
    for j in `ls $i `; do # fotos/098-001/ fotos/098-002/ fotos/097-001/ etc...
    if [ "$j" = "Thumbs.db"  ]; then  # garbage file on win32
        echo "Nothing to do..."
    elif [ "$j" = "script.sh" ]; then # this script file :D
        echo "Nothing to do..."
    else
        echo "Working ..." # do the job
        #convert "$i/$j" -resize 500 "$i/new_$j"
        #mv "$i/new_$j" "$i/$j"
        mogrify -resize 500 "$i/$j"
    fi
    done
done

Ahora todas las imagenes tienen width: 500.

Ahora supongamos que se tienen multiples sub directorios, puedes utilizar este script:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#!/bin/bash
IFS=$'\t\n'
EXTS=( jpg gif png JPG GIF PNG )
for EXT in ${EXTS[@]};
do
	for f in `find . -name "*.$EXT" -type f`;
	do
		dir=`dirname $f`
		ff=`basename $f`
		echo "Working ..."
		#convert "$f" -resize 500 "$dir/new_$ff"
		#mv "$dir/new_$ff" "$f"
                mogrify  -resize 500 "$f"
	done
done

[thanks for the advice CyX]

Categories: develop, unix/linux Tags: , ,

rubygems-update issue on Ubuntu

martes, 30 de septiembre de 2008 4 comentarios

rubygems-update issue on Ubuntu

If you have this problem on your computer:

sudo gem update --system
Updating RubyGems
Bulk updating Gem source index for: http://gems.rubyforge.org/
Updating rubygems-update
ERROR:  While executing gem ... (Gem::GemNotFoundException)
    could not find rubygems-update locally or in a repository

The problem is RubyGems you need to install manually or use this script solution:

#!/bin/bash
#(download the latest on http://rubyforge.org/frs/?group_id=126)
wget http://rubyforge.org/frs/download.php/43984/rubygems-update-1.3.0.gem
sudo gem install rubygems-update-1.3.0.gem
sudo update_rubygems
# now this work:
sudo gem update --system
echo "done."

I found this solution on this web:

http://rubyglasses.blogspot.com/2008/08/updating-gem-to-120-on-ubuntu.html

Categories: develop, unix/linux Tags: , ,

Toshiba Fan On Ubuntu

domingo, 28 de septiembre de 2008 6 comentarios

Toshiba Fan On Ubuntu

You need to install toshset include on toshutils (do you have lm-sensors ?)

sudo apt-get install toshutils

This script make the fan run high, low or normal

#!/bin/bash
case $1 in
	h) sudo toshset -fan 4 # high
	;;
	n) sudo toshset -fan 5 # normal
	;;
	l) sudo toshset -fan 6 # low
	;;
esac

If you live in warn places, “~$ script.sh h” could be help you a little don’t use all time this option, to normalize your fan run “~$script.sh n”.

There are other tools on toshset “man toshset”.

Switch to our mobile site