Securely specify mysql credentials in automated scripts

Often, you may want to run a script that uses a username and password to access data in a MySQL database. Securely running a script like this manually is easy – simply use the ‘-p’ option for the MySQL client, and it will prompt you for the password. However, this is not an option if you want to automate the script.

There are several ways to provide the password in a way that can be used with automated scripts, but only one that is both flexible and secure. You can specify the password on the command line itself (with ‘mysql -p ‘); however, this allows the password be seen by other users who run commands like ‘ps’. Another option is setting the environment variable “MYSQL_PWD” to the password, but this can also be seen by other users. Continue reading “Securely specify mysql credentials in automated scripts”

Using the Data::Dumper module to debug your Perl scripts

If you’re ever writing a Perl script that contains fairly complicated data structures (multi-dimensional arrays, hashes of arrays, etc), or you’re debugging code that contains complicated objects, it may be helpful to view the current state of those data structures in their entirety.

This is easy to do with Data::Dumper. Although the features the module provides are fairly complex, it’s easy to use it to just print out the contents of something. Do do this, you’ll first need to import the module with ‘use Data::Dumper;’. Then, to dump the data in an array(for example), simply do ‘print Dumper(@array)’. Continue reading “Using the Data::Dumper module to debug your Perl scripts”

Easily installing Perl modules with Yum

Although many Perl modules are available through Red Hat and CentOS’s repositories, the name the modules have in the repository differ from the name of the module itself.

To use yum to install a Perl module using the module name, just place ‘”perl()”‘ around the name of the module (double quotes included) when giving it as an argument to yum. For example, to install the ‘Net::Telnet’ module, you would run ‘yum install “perl(Net::Telnet)”‘.

Alternatively, to construct the correct package name, you would prepend the module’s name with ‘perl-’, and change all of the instances of ‘::’ to ‘-’. For example, the package for the ‘Net::Telnet’ module would be ‘perl-Net-Telnet’.

OpenSSH SOCKS proxy support

Often, when you’re administering or developing on servers remotely, you may need to access resources that are not available to the public. There are several different ways that you can gain access to protected services from a remote location, including a VPN, port forwarding over SSH, and stunnel.

However, one method that is not as well known is OpenSSH’s SOCKS proxy option. Introduced in OpenSSH 3.7, SOCKS support allows you to easily tunnel traffic from any application that has support for a SOCKS4 or SOCKS5 proxy through your SSH connection. To do this, you simply need to add ‘-D <port>’ to your ssh connection string, where <port> is the port you would like your proxy to run on. Then, configure your application to use a proxy at localhost:<port>, and all of the traffic from that application will be tunneled through your SSH connection.

In addition to accessing protected resources, you can also use this for more everyday tasks – such as encrypting traffic sent over a public wireless connection.

Human readable disk usage

Finding out what directories and files are using up the disk space on your server is fairly easy with du, but the output is not always easy to read.

However, it’s not too hard to pretty up the output with some perl and the module Number::Bytes::Human (available from CPAN). To convert normal du output into a more human readable form, which shows file size in the correct units (K, M, or G) and also includes the percentage of the total space each entry is using, use the follwing steps.

Finding out what directories and files are using up the disk space on your server is fairly easy with du, but the output is not always easy to read.

However, it’s not too hard to pretty up the output with some perl and the module Number::Bytes::Human (available from CPAN). To convert normal du output into a more human readable form, which shows file size in the correct units (K, M, or G) and also includes the percentage of the total space each entry is using, use the follwing steps. Continue reading “Human readable disk usage”

TNR Global and Hidden-Tech Present: Developing a Dynamic Web Site for Your Business – Joomla!

Date: January 29, 2008, 5:30 p.m. — 7:30 p.m
Location: Lord Jeffrey Inn, Amherst, MA

Hidden-Tech members are invited to an evening seminar to explore the Joomla! content management system. Learn how you can use open source tools to create an interactive website for your business or organization. The Joomla! web content management system allows non-programmers to create dynamic websites with forums, blogs, newsletters, calendars, polls, ad banners, user registration, directories, and more.

Who can benefit?
If your organization—
a. has a lot of content
b. needs an interactive site
c. wants to update web content easily
— then consider Joomla!

University of Massachusetts – Mind the Gap Women & Technology Summit

Natasha Goncharova, Managing Director of TNR Global, LLC, will be a panel participant at the Technology Trends in Industry session at the University of Massachusetts’s “Mind the Gap” Women & Technology Summit, on September 27, 2007. The event, organized by the Commonwealth Alliance for IT Education (CAITE), provides a venue for women to explore career options in technology fields.