Kategoriearchive: Scripts

Hetzner – copy IPv6 Reverse-DNS

You can continue to use the old IPv4 subnet with a new server at Hetzner. With IPv6, it does not work unfortunately. Although I do not understand why I can keep all IPv4 (subnet and / or single), but not the IPv6 addresses. It’s annoying when you have to change […]

Report Spam comments from WordPress to blocklist.de

The script wp-spamreport.php (as a download here in my git) reports at any time the spam comments of the last 48 hours to blocklist.de. It does not matter when a comment was marked as spam (manually or automatically by example Antispam Bee), but only that the comments are posted in […]

update ownership for files

To transfer the ownership of files in a directory recursively from a user / group to another, you can use this simple one-liner: find . -user old_user -group old_group -print0 | xargs -0 chown -v -h new_user:new_group I have found it here. There also the individual parameters are explained in […]

temporarily suspend mail delivery to a specific domain

With postfix and cron delivery of new mail messages may be certain times quite easily prevented. It can for example be prevent from that emails are delivered via push to inopportune times to a user. Add a hash-table in /etc/postfix/main.cf to smtpd_recipient_restrictions: check_recipient_access hash:/etc/postfix/hold In the file /etc/postfix/hold all domains […]

bash – remove last char(s) from string 1

The last character of a string is very easy to remove in bash. out=”remove last char!” echo “${out%?}” returns remove last char To remove the last two characters: out=”remove last char!” echo “${out%%??}” returns remove last cha or use out=”remove last char!” echo ${out:0:$((${#out})) – 2} to also get remove […]

php $_POST with special characters

I just wondered why $private_key=$_POST[‘pkey’]; doesn´t work, when I use a variable with AJAX, which also contains a +. The solution is surprisingly simple: PHP changes fields containing the characters space, dot and others to ensure compatibility with the (obsolete) register_globals. There are many workarounds. I use this function: function […]

Bash – using variables outside a while loop 2

The bash runs every loop (while or for) in a subshell. The values for a variable defined inside such a loop / subshell are not available outside. #!/bin/bash t=0 while read line; do   t=$(( t + 1 )) done < /etc/passwd echo $t Returns 0 for $t but inside the […]