Doorgaan naar hoofdcontent

Posts

Passing e-mails to a shell script [1/2] with Postfix E-Mail Server to process attachments

1] Passing e-mails to a shell script opens up a brave new world of possibilities If you have a Postfix mail server setup and running as MTA(Mail Transfer Agent), or even as a LDA (Local Delivery Agent) it is really easy to pipe a mail to your shell script. you open up the aliases file mostly it is in /etc/aliases: mailer-daemon: postmaster postmaster: root nobody: root hostmaster: root usenet: root news: root webmaster: user1 www: user1 ftp: user1 abuse: root   So you see you have a bunch of aliases the first part is the email address you sent to e.g : www@yourdomain.org after the ":" is where the mail gets delivered so in our example the mail will be delivered to user1 if you want to redirect to your script change line 8 of the aliases file into: www : |"/home/user1/myscript.sh/" user1 this will pipe all emails addressed to  "www"  to your script 2] Use Munpack to save the attachments of e-mails One great use of the redirection is to ex
Recente posts

Working with pdf files on the command line

PDFTK great tool for rearranging your pdf file. Howto join multiple pdf's together: e.g. you want to join the files: BRO_001.pdf BRO_002.pdf BRO_003.pdf the command is 'cat' from concatenate pdftk BRO_001.pdf BRO_002.pdf BRO_003.pdf cat output Joined.pdf Or even faster pdftk BRO_00* cat output Joined.pdf the cat command accept page ranges 1-end  (the whole document) 6-4-2  pages 6 4 2 in that order even odd r1-r2  last page and second last page

Create Directory Structure Based on Date of Files

Whenever you have 10k picture to look through in one directory you know it takes forever to load those thumbnails. And to find that perfect picture from Christmas 2000 it takes forever. Wouldn't it be nice to just go to the folder 200012 and see all the pictures you made in december of the year 2000. Well with a few commands you can actually do this real quickly. First of all , if you already have somekind of folder structure you might move or copy everything to one root folder. Here is the "flattening" command for e.g. all jpg files find . -name "*.JPG" -print0 | xargs -0 cp --target-directory ./test/ After you flattenend your directory lets create the date folders: mkdir `ls -l --time-style=+"%Y%m" | awk '{print $6}' | sort | uniq`  So after this step move all the files to there correct folder: For this step I couldn't get it without a script So I made this little bash script which uses rather cool features of bash:   #!

Converting HEIC , HEIF files with Image Magick

Convert alle HEIC files in a directory to PNG file First off all you have to compile imagemagick from source with heic support and some other libs: Here are the instructions for this: cd /usr/src sudo git clone https://github.com/strukturag/libde265.git sudo git clone https://github.com/strukturag/libheif.git cd libde265/ sudo ./autogen.sh sudo ./configure sudo make sudo make install cd /usr/src/libheif/ sudo ./autogen.sh sudo ./configure sudo make sudo make install cd /usr/src/ sudo wget https://www.imagemagick.org/download/ImageMagick.tar.gz sudo tar xf ImageMagick.tar.gz cd ImageMagick-7* sudo ./configure --with-heic=yes sudo make sudo make install sudo ldconfig if you want to convert all files in a directory to png from heic. For some reason mogrify from imagemagick refuses. So I had to do it with convert: for file in *.HEIC; do convert $file $file.PNG; done The only drawback with convert is that it changes the date of the new files to th

Awk Tips & Tricks: print a "," at the end of the line EXCEPT the last one!

Small AWK idiomatic tip. If you want to add a char at the end of each line.EXCEPT the last one. for instance you are generating an array. awk NR>1 {printf(",\n");} {printf($0);} TLDR; The NR stands for number record, the line it is processing usually. the printf statement prints out without the ORS( output record separator) usually newline (\n) char. END;
disable-laptopkb.sh #Bash Script to disable laptop keyboard. id=$(xinput list | awk 'BEGIN {FS="[=\t]+"} /Translated/ {print $3}') xinput float $id

VIM tips & tricks 2: "Adding and Subtracting numbers"

One of the coolest features in Vim is to easily change a number by either an addition or a subtraction of the number on the cursor In normal mode you type <C-a> for adding one or <C-x> for subtracting one it even gets better if you add a number before your <C-a> it will use that number to add to the number on the cursor!