Kategoriearchive: Scripts


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 […]


ISPConfig – add backup size to web backups 8

To view the size of the backups of a domain in the interface, just a few minor changes are needed. The modified files are available for download here. Add one line to interface/web/sites/lib/lang/en_web_backup_list.lng: $wb[‘filesize_txt’] = ‘Filesize’; Extend interface/web/sites/templates/web_backup_list.htm by two lines: <th class=”tbl_col_filename” scope=”col”><tmpl_var name=”filename_txt”></th> <th class=”tbl_col_filename” scope=”col”><tmpl_var name=”filesize_txt”></th> <th […]


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 […]


Add blocklists from blocklist.de to iptables 2

UPDATE: http://blog.schaal-24.de/?p=2683&lang=en I use some blocklists from blocklist.de, to minimize potential attacks. Every list contains one IP per line, so the lists can easily added to the firewall using xt_recent. I use a simple Bash-Script which runs daily via cron to compare my firewall with the lists. Some definitions for […]


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 […]