Linux

Hammer script to get output from Job by id

This is a simple script I use to export the details from a Job run in Red Hat Satellite 6.2 using hammer from the console. #!/bin/bash # Redhat Satellite Job query by id using hammer if [ $1 -eq $1 ] 2>/dev/null; then # get hosts run by ID JOBHOSTS=$(hammer job-invocation info –id $1 | […]

Read More
Linux

Generate IP-address ranges using simple bash script

This is just a simple script to generate IP-addresses in a IP-range and write the result output to a file. The script does also remove addresses you would like to exclude from the final output. #!/bin/bash OUTFILE=”mk-iprange.txt” IPRANGE=”192.168.0 192.168.1″ EXCLUDE=”192.168.0.1 192.168.0.2 192.168.1.1″ # Remove old OUTFILE rm -f $OUTFILE # Loop addresses, write to OUTFILE […]

Read More
Scripting

Replace specific HTML tags using sed and regular expression

In this post I would like to replace all <embed> HTML tags in a HTML file with a <strong> tag. # sed -e ‘s/<embed[^>]*>/<strong>/g’ filename.html > newfile.html And if you would like to remove the <embed> tag altogether # sed -e ‘s/<embed[^>]*>//g’ filename.html > newfile.html To remove all HTML tags in a file # sed […]

Read More
Linux

IP address change notifier script

This is a simple bash script that is run by crontab every 5 minutes on a linux box. It e-mails me the new address when a change of IP address is detected. The script (ipchangemail.sh) #!/bin/bash # Check if IP-address has changed. If a change has occured, mail me the new address # Add the […]

Read More
Linux

Apache web connections pr hour

This is a bash oneliner to show Apache web connections pr hour. It lists up the IPs that has accessed your webserver and the amount og accesses. # cat /var/log/apache2/access_log_pario.no | grep “21/Jan/2008:..” | awk {‘ print $4″:”$1 ‘} | sed ‘s/\[//g’ | awk -F : {‘ print $1″:”$2″\t\t”$5 ‘} | sort | uniq -c […]

Read More