zsh.li Pinkhat Memories Me About ?

Dear My
Linux

ARCHIVES_DATE october 2019

Email notifications in your terminal


I lost my domain zsh.li mainly because I didn't check my email pretty often, getting email notifications in the terminal is pretty easy, but it took me a while to figure out how to do it.

This is an old-fashioned method, but I like because nowadays developers are too obsessive with deficient and bloated apps, it can use IMAP but I like POP3 as it deletes the original message from the server which is great for privacy.

I'm using Slackware current which is the testing branch for Slackware 15. Slackware current is using Postfix as the system mail service, surprisingly Postfix is also used for an internet email server but here postfix is restricted to our local installation.

Sadly I haven't been receiving the cron mails in a lot of time and the command mailq showed me lots of mails in queue, so I had to fix the postfix service, I did so generating an alias database. Mailq show me lots of mail alias errors.

Most of time the mail system works out of the box, so you will only need the following:

1. Install fetchmail

2. Paste the following code and replace daya with your local unix user, mail.gmail.com with the mail domain, flor@gmail.com to your email address and parangaricutirimicuaro to your password:


set daemon 600
set syslog
poll mail.gmail.com
  with nodns,
  with protocol POP3
  user "flor@gmail.com" there is daya here,
  with password parangaricutirimicuaro ,
  with ssl, sslcertck;

Add to .bashrc (or .profile):

mail -e && mail -H

And for having an ascii cow displaying the email headers:

mail -e && cowsay "$(mail -H)"

You may need to install the bsdgames for it

Notice: Your emails would be deleted from the email server. You may add the keep parameter after here (daya here)


How to automatically convert the PNG pictures to JPG images.


On the server I have this script running in the background that converts all the PNG files I upload through SFTP to the jpg format in order to improve the website performance.

Requeriments: inotify-tools


#! /bin/bash
inotifywait -m --format '%w%f' -e close_write -r /var/www/ | while read FILE
do
	if ( echo $FILE  | grep -e png$ ); then
#	       sleep 10 
	       convert "$FILE" "${FILE%.png}.jpg"
	      mv "$FILE" /tmp
	       fi
done

How to record and replay a terminal session


Paste the following code in $HOME/.profile or $HOME/.bashrc

, I was inspired for internet forums, however I added the exit function a, it's important mainly for SSH. Also included the time parameter, using the time parameter allows us to replay the script record using the scriptreplay --time=FILE1 FILE2 command.

In the case that you want it to be more hidden or system-wide you can add the code into /etc/profile.


mkdir -p $HOME/.log
test "$(ps -ocommand= -p $PPID) | awk '{print $1}')" == 'script'  || script --timing=$HOME/.logs/$(date +%s).time $HOME/.logs/$(date +%s) -q

if [[ "$(ps -ocommand= -p $PPID) | awk '{print $1}')" == 'script' ]]; then
	exit
else
kill -9 $$
fi