port check with perl

If you are on a machine without telnet you can use this perl script to check connectivity.


# nettest.pl

use IO::Socket;
use Errno;
$| = 1;

$host = shift;
$port = shift;
$type = shift || “tcp”;
die “No Host parameter!” if !$host;
die “No Port parameter!” if !$port;

my $rc = new IO::Socket::INET
PeerAddr => $host,
PeerPort => $port,
Proto => $type,
Timeout => 5 or die “\nCan’t bind : $@\n”;

print “\nSuccessfully bound to $host on port $port\n”;

Posted in Uncategorized | Comments Off on port check with perl

Cleaning up Docker Images

Here is great way to clean up docker images that are not being used.

curl -s https://raw.githubusercontent.com/ZZROTDesign/docker-clean/v2.0.4/docker-clean | \
sudo tee /usr/local/bin/docker-clean > /dev/null && \
sudo chmod +x /usr/local/bin/docker-clean

Posted in Uncategorized | Tagged | Leave a comment

Onscreen Keyboard

When using Remote desktop to change your password, you have to press ctrl-alt-delete.

Usually you can use ctrl-End on your remote machine — but sometimes that doesn’t work.

Using the windows onscreen keyboard will do the trick.

Run -> enter osk.exe in the cmd box.

This will pop up the onscreen keyboard. If you press Ctrl – Alt – you’ll see the keys on the onscreen keyboard light up – -then just click the DELETE button on the onscreen keyboard and it will pop up the task manager screen where you click change password.

Posted in Uncategorized | Leave a comment

crontab to check for updates on Redhat or Centos

This is the entry we use to check for updates everynight. If updates are available it will download them and send email so you can just jump on machine and do yum update -y

6 5 * * * /usr/bin/yum -q check-update > /etc/motd 2>&1 || /usr/bin/yum upgrade -y –downloadonly | mailx -s “yum updates on `uname -n`” kmeek@meekconsulting.com

Posted in Uncategorized | Leave a comment

perl toggle operator for extracting one table from mysql dump file

We did it with a nifty one liner perl command that uses the TOGGLE operator.

zcat fast.dmp.12082014_13_03.sql.gz |perl -ne 'if (/CREATE TABLE `budget`/../UNLOCK/ ) {print $_; }' > budget.1208.sql

This looks for lines in the dump between lines that match the green and yellow highlighted words ( which happen to be the separators we want )

We wanted to be able to rename our table so we could load it in the current schema as the live table so we added a substitution before printing like this:

zcat fast.dmp.12082014_13_03.sql.gz |perl -ne 'if (/CREATE TABLE `budget`/../UNLOCK/ ) {$_=~s/budget/budget_1210/; print $_; }' > budget.1208.sql

Good thing to have in your toolkit..

Posted in Uncategorized | Leave a comment

Keep submit buttons from submitting twice

Jquery One function works nicely for limiting a bind event to only one time.

Just be sure to re-bind it ONE time when the server sends back an error when validating the form inputs.

$objResponse->script(" $('#submit_edit_prod_personalization_form').button().one('click',function() { xajax_update_prod_personalization(xajax.getFormValues('edit_prod_personalization_form')); });");

Posted in Uncategorized | Leave a comment

Quick way to find IP address

Here is a quick way to find the external IP address of a system.  It can be used scripts etc

wget http://ipinfo.io/ip -qO –

Posted in Uncategorized | Leave a comment

Find out what CAs a webserver will accept

Here is a handy command to find out what CAs are accepted by a website.  When your website is configured to require client PKI certificates with the SSLVerifyClient require directive, it will only accept client certificates issued by CAs that you trust as defined in your SSLCACertificateFile  directive.

We usually set our up like this:

SSLCACertificateFile /etc/httpd/ssl/ca-bundle.crt

If you want to verify what is in that file for a remote host without going to the server you can run this command from any client.  It will simulate a web client and the server tells it what CAs are trusted and it will print them out.  Pretty neat!

openssl s_client -showcerts -connect beta.usecobra.com:443 –prexit


Posted in Uncategorized | Leave a comment

Setting up NTP to keep server time in sync

Install ntp packages

yum install ntp

Redhat 5 need ntpdate separately

yum install nptdate

Set ntp to start on boot:

chkconfig –level 345 ntp on

chkconfig –level 345 ntpdate on

For redhat 7:

systemctl enable ntpd.service

Verify with this:

chkconfig –list | grep ntp

Should show on for boot levels 3,4,5

chkconfig –list | grep ntp
ntpd            0:off   1:off   2:off   3:on    4:on    5:on    6:off
ntpdate         0:off   1:off   2:off   3:on    4:on    5:on    6:off

Edit the config file if you want to use local server

You can change the servers it uses to sync with to be local domain controllers if you don’t have access to the public NTP servers.

The default settings use round robin pools and send you to random servers in the time server pool.

To change edit the Config File /etc/ntp.conf

Change the server lines:

server 0.rhel.pool.ntp.org iburst
server 1.rhel.pool.ntp.org iburst
server 2.rhel.pool.ntp.org iburst
server 3.rhel.pool.ntp.org iburst

Start the service:

systemctl start  ntpd.service


service ntpd start

Check it is working:

If it is done right you should be able to see the peers actively being used:

ntpq -p

remote           refid      st t when poll reach   delay   offset  jitter


+tcgalxdc02.colu        3 u    –   64  377    0.909   18.481  11.071

*tcghqdc04.colum  2 u    7   64  377   25.665   43.190  15.213

If the delay / offset / jitter are zero — it means it is not getting to the server   check the firewall is allowing port 123 traffic for ntp through.

Posted in Uncategorized | Leave a comment

Quick HTTP server

If you need to pull files from a linux box.  This handy python command will turn on a temporary HTTP server listening on port 8000


cd to directory you want to pull files from and type:

python -m SimpleHTTPServer 8000


Lasts only until you kill the process with Crtl-C

Make sure you have firewall open to allow access to port 8000



Posted in Uncategorized | Leave a comment