Linux: Number of days before password expires

While creating a script to send an email alert when a linux accounts password is about to expire, we needed to determine the number of days remaining before expiry. A quick search of Google surprisingly returned only methods that access /etc/shadow, which is not possible for standard users. However, we did manage to come up with a solution.

Kornshell function declarations

Over the years I have seen and maintained many kornshell scripts written by DBAs, and there are a number of programming styles that provoke strong reactions on who is doing it the "right" way. In this article, I will explain the different ways in which functions can be defined in Kornshell and explain why I personally prefer one method over another.

Scripting: Is the DB DataGuarded?

Whilst developing some administrative functions within PL/SQL I needed to know whether the database that the code was being run in was part of an Oracle DataGuard setup, which you would think would be a trivial exercise. My first thought was that we could determine this via v$database. If the DATABASE_ROLE column in v$database contains STANDBY then we know... Continue Reading →

Continue SCP’ing file(s) after log out

The unix command scp is very useful for transferring files between two hosts over a secure connection, but sometimes you need to kick off an scp command that will take several hours to complete and you want to disconnect and go home. Using "screen" One approach is to use the screen command (available only on linux AFAIK) to start the initial transfer, then... Continue Reading →

Starting a Batch (DOS) file minimized

In my article How to backup your Evernote notes regularly I supplied a windows batch file that could be used with the Windows Scheduler to automatically backup your Evernote Notes. In use, however, it soon becomes annoying that the scheduler launches a DOS window to run the script right in the middle of the screen. This article documents the technique for running a batch file minimized to the taskbar.

AJAX Tabs in Bootstrap 2.1

I'm using Twitter Bootstrap in a new project and want to have the content of tabs dynamically loaded via AJAX. Although in previous projects I have used jQueryUI to achieve this I wanted to keep the look of all the user interface elements consistent throughout the design. As a result, I whipped up a simple piece of jQuery to do this.

Database version dependent SQL scripts

I've been working with Oracle databases since version 7.1 and over time I've built up quite a collection of scripts - some of which were improved as later versions of the database provided additional information in the data dictionary (in some cases columns were renamed completely). However because I never know when I might be working on a system running an earlier version of Oracle I sometimes keep multiple versions of scripts, usually with a suffix of v7, v8, etc. However, wouldn't it be nice if you didn't have to specify the version suffix - if somehow the correct script was run automatically? Here's how I do it...

Kornshell function to keep revisions of a file

Sometimes while developing scripts you want to keep backups of certain files, but are worried that over time the old versions will fill the filesystem and need housekeeping. The following function will allow you to keep only <n> versions of a file (the default is 5 backups) with older ones getting removed automatically.  # Usage:... Continue Reading →

Blog at WordPress.com.

Up ↑