BASH script for resize images using morgify
#!/bin/bash
FILES=/home/rafal/Pictures/Mockba/*
for f in $FILES
do
echo “resize $f “
cp $f $f”.bak”
mogrify -resize 50% $f
done
Debugging authentication problems
— to debug POP3 —
# telnet x.x.x.x 110
user USERNAME
pass PASSWORD
stat
quit
— to debug IMAP —
# telnet x.x.x.x 143
a login USERNAME PASSWORD
a examine inbox
a logout
— to debug POP3 over SSL —
# openssl s_client -connect x.x.x.x:995
(then use same commands as POP3 example)
— to debug IMAP over SSL —
# openssl s_client -connect x.x.x.x:993
(then use same commands as IMAP example)
Centos 5: amavis filed start
[root@hostname ~]# /etc/init.d/amavisd start
Starting Mail Virus Scanner (amavisd): fetch_modules: error loading required module Compress/Zlib.pm:
dualvar is only available with the XS version of Scalar::Util at /usr/lib/perl5/site_perl/5.8.8/Compress/Zlib.pm line 8
BEGIN failed—compilation aborted at /usr/lib/perl5/site_perl/5.8.8/Compress/Zlib.pm line 8.
Compilation failed in require at /usr/sbin/amavisd line 197.
ERROR: MISSING REQUIRED BASIC MODULES:
Compress::Zlib
BEGIN failed—compilation aborted at /usr/sbin/amavisd line 237
SOLUTION:
perl -MCPAN -e "CPAN::Shell->force(qw(install Scalar::Util));"
Make ISO images on Linux
Create iso file from cd drive:
dd if=/dev/cdrom of=/home/user/cd.iso
Create iso file from cd drive:
dd if=/dev/dvd of=/home/user/dvd.iso
Create iso file from scsi cd drive:
dd if=/dev/scd0 of=/home/user/cd.iso
Mount iso file and unmount :
mount -o loop -t iso9660 /home/user/cd.iso /mnt/dir_for_mount
umount -lf /mnt/dir_for_mount
PostgreSQL How dump all databases
#!/bin/bash
logfile=”/home/user/db_backups/pgsql.log”
backup_dir=”/home/user/db_backups”
touch $logfile
databases=`psql -h localhost -U postgres -q -c “\l” | sed -n 4,/\eof/p | grep -v rows\) | grep -v template0 | grep -v template1 | awk {‘print $1’}`
echo “Starting backup of databases ” » $logfile
for i in $databases; do
dateinfo=`date ‘+%Y-%m-%d %H:%M:%S’`
timeslot=`date ‘+%Y%m%d%H%M’`
/usr/bin/vacuumdb -z -h localhost -U postgres $i >/dev/null 2>&1
/usr/bin/pg_dump -U postgres —inserts $i -h 127.0.0.1 -f $backup_dir/$i-database-$timeslot.backup
echo “Backup and Vacuum complete on $dateinfo for database: $i ” » $logfile
done
In /root You should have .pgpass file with chmod 600
cat /root/.pgpass
*:*:*:postgres:password_for_postgres_user
MySQL How dump all database & gzip
mysqldump -u root -pMyPassword —all-databases | gzip > /path/to/file/mysql.sql.gz
MySQL How change root password
UPDATE mysql.user SET Password=PASSWORD(‘myNewPassword’) WHERE User=’root’;
FLUSH PRIVILEGES;
Send mail from terminal with attachment
echo “This is the message body” | mutt -a file_attach.zip -s “subject of message” recipient@domain.com
Embedded developing resources
1. http://www.barrgroup.com/Embedded-Systems/How-To/Embedded-Java
2.http://www.youtube.com/watch?v=mdHCWPZ-kbQ&feature=BFa&list=PL62BE418C34C3B2BD
3.http://www.javaworld.com/javaworld/jw-09-1996/jw-09-ripps.html
