© 2023 PodTECH IO
All rights reserved.

Get in Touch

UNIX

RedHat vs Ubuntu – Useful Package Commands

RedHat vs Ubuntu – Useful Package Commands Task Red Hat/Fedora Ubuntu Refresh list of available packages Yum refreshes each time it’s used apt-get update Install a package from a repository yum install package_name apt-get install package_name Install a package file yum install package.rpm rpm -i package.rpm dpkg –install package.deb Remove a package rpm -e package_name […]

Perl UNIX

Add a timestamp to every STDOUT line

Add a timestamp to every STDOUT line I found this useful for debugging and just handy to have in the toolbox. Alias within your profile! Use: ./anyscript_you_choose | ./addtime [perl] #!/bin/perl -w # filename: ./addtime my($old)=select(STDOUT); $|=1; select(STDIN); $|=1; select ($old); while(<>) { my($sec,$min,$hour,$mday,$mon,$year,$wday,$ydat,$isdst)= localtime (time); printf “%02d:%02d:%4d %02d:%02d:%02d %s”,$mday,$mon+1,$year+1900,$hour,$min,$sec,$_; } [/perl]

Perl UNIX

Perl – Get the md5 hash for a file

Perl – Get the md5 hash for a file Get the MD5 hash for a file on the command line, using Digest::MD5 usage: ./md5sum.pl [filename] [-f] -f do not display filename [perl] use warnings; use strict; use Digest::MD5; sub md5sum { my $file = shift; my $digest = “”; eval{ open(FILE, $file) or die “Can’t […]

Perl

Get HTTP Code Response – Perl

Get HTTP Code Response – Perl Pass the script many hosts and obtain the HTTP response codes for the pages. [bash] ./http_check.pl … [/bash] [perl] use LWP::UserAgent; print get_url($url); sub get_url ($) { my $url = shift; my $ua = LWP::UserAgent->new; my $req = HTTP::Request->new(GET => $url); my $res = $ua->request($req); return $res->code; } ##Some […]

SQL

Select the next available value in a table

Select the next available value in a table Let’s say I have a table like this: ID Value ———————- 100 val1 101 val2 104 val3 105 val4 107 val5 [sql] SELECT Min(r1.uid) + 1 AS next_available_uid FROM unixuid AS r1 LEFT OUTER JOIN unixuid AS r2 ON r2.uid = r1.uid + 1 WHERE r1.uid > […]

Datacentre

Datacentre – classifications

Datacentre – classifications Tier Level Requirements 1 Single non-redundant distribution path serving the IT equipment Non-redundant capacity components Basic site infrastructure guaranteeing 99.671% availability 2 Fulfils all Tier 1 requirements Redundant site infrastructure capacity components guaranteeing 99.741% availability 3 Fulfils all Tier 1 & Tier 2 requirements Multiple independent distribution paths serving the IT equipment […]