HOWTO: Determine what process is listening on a port (AIX Unix specific)

I needed an easy way to determine which process was listening on a port. For AIX, you need to get the socket id from “netstat -Ana” and use the rmsock “rmsock socket_id tcpcb” to get the PID and command. It would be easy to expand this out to list command line and owner for each PID.

--------------------------------------------------------------------------------------
| Process              | PID             | Protocol | Listening On                   |
--------------------------------------------------------------------------------------
| WEBAPL               |         4915396 |      UDP |                127.0.0.1.32807 |
| WEBAPL               |         4915396 |      UDP |                127.0.0.1.32808 |
| WEBAPL               |        12058770 |      UDP |                127.0.0.1.51714 |
| WEBAPL               |        12058770 |      UDP |                127.0.0.1.51715 |
| backupserver         |        19791994 |      TCP |              192.168.1.4.50021 |
--------------------------------------------------------------------------------------
#!/bin/ksh93

OS_NAME=$( uname -s )

if [[ $OS_NAME == "AIX" ]] ; then
    echo "--------------------------------------------------------------------------------------"
    printf "| %-20s | %-15s | Protocol | %-30s |\n" "Process" "PID" "Listening On";
    echo "--------------------------------------------------------------------------------------"

    netstat -Ana | awk '
    /[0-9\*].[0-9].+LISTEN/ {
        SOCKET=$1;
        IPPORT=$5;
        "rmsock " SOCKET " tcpcb" | getline SOCKOUT;
        split(SOCKOUT, sockarray, " ");
        gsub(/[\.\(\)]/, "", sockarray[10]);
        LISTENERS[ sprintf("| %-20s | %15d | %8s | %30s |", sockarray[10], sockarray[9], "TCP", IPPORT) ] = 1;
    }
    /udp.*.[0-9]/ {
        SOCKET=$1;
        IPPORT=$5;
        "rmsock " SOCKET " inpcb" | getline SOCKOUT;
        split(SOCKOUT, sockarray, " ");
        gsub(/[\.\(\)]/, "", sockarray[10]);
        LISTENERS[ sprintf("| %-20s | %15d | %8s | %30s |", sockarray[10], sockarray[9], "UDP", IPPORT) ] = 1;
    }
    END {
        for (var in LISTENERS)
            print var

    }' | sort | uniq

    echo "--------------------------------------------------------------------------------------"
else
    echo "ERROR: Requires AIX"
    exit 1
fi
Share Button

How to: How to copy an Oracle tablespace across platforms – quick and dirty ;-)

On the source machine:
Set the tablespace(s) into read only mode

Alter tablespace <tablespace> read only

Export the tablespace meta data using export

expdp system/<password> DUMPFILE=expdat.dmp DIRECTORY = dpump_dir TRANSPORT_TABLESPACES = <list of tablespaces separated by commas> TRANSPORT_FULL_CHECK=Y

If the dumpdir is not set up, you will get an ‘invalid’ directory error:

CREATE DIRECTORY dmpdir as ‘/somedir’;
GRANT read,write on DIRECTORY to system;

Export the data converting on the fly:
Determine the platform name for the destination machine:

SELECT PLATFORM_ID, PLATFORM_NAME, ENDIAN_FORMAT FROM V$TRANSPORTABLE_PLATFORM
rman TARGET /
RMAN> CONVERT TABLESPACE </list><list of tablespaces separated by commas> to PLATFORM ‘<platform name from previous step>’  FORMAT=’/somedir/%U’;
Share Button

How to create an iTunes/iPod compatible audiobook (MPEG4 m4b) on Linux using MP4Box and mp4v2 v1.9.1 – it can be done!

I’ve been wracking my brains over this for the past few weeks and it finally struck me how to create an m4b audiobook with chapters that is compatible with your iPod, iTunes, VLC, etc.  It was very simple once I figured it out:

Step 1:

encode the mp3 files to “aac” (mpeg4) using your favorite converter (I use ffmpeg):

ffmpeg -i "track1.mp3" -y -vn -acodec libfaac -ab 128k -ar 44100 -threads 3 -f mp4 track1.aac

Step 2:

Create a chapters file so that MP4Box can understand it:

* Common syntax : CHAPTERX=h:m:s[:ms or .ms] on one line and CHAPTERXNAME=name on the other – the order is not important but chapter lines MUST be declared sequencially (same X value expected for 2 consecutive lines).

track1.chapters:

CHAPTER1=00:00:00.000
CHAPTER1NAME=Chapter 001
CHAPTER2=00:30:00.139
CHAPTER2NAME=Chapter 002
CHAPTER3=01:00:00.728
CHAPTER3NAME=Chapter 003
CHAPTER4=01:30:01.269
CHAPTER4NAME=Chapter 004
CHAPTER5=02:00:01.858
CHAPTER5NAME=Chapter 005
CHAPTER6=02:30:02.375
CHAPTER6NAME=Chapter 006
CHAPTER7=03:00:02.964
CHAPTER7NAME=Chapter 007
CHAPTER8=03:30:03.553
CHAPTER8NAME=Chapter 008
CHAPTER9=04:00:04.094
CHAPTER9NAME=Chapter 009
CHAPTER10=04:30:04.683
CHAPTER10NAME=Chapter 010
CHAPTER11=05:00:05.224
CHAPTER11NAME=Chapter 011
CHAPTER12=05:30:05.765
CHAPTER12NAME=Chapter 012
CHAPTER13=05:46:14.106
CHAPTER13NAME=Chapter 013
CHAPTER14=06:16:14.143
CHAPTER14NAME=Chapter 014
CHAPTER15=06:46:14.732
CHAPTER15NAME=Chapter 015
CHAPTER16=07:16:15.249
CHAPTER16NAME=Chapter 016
CHAPTER17=07:46:15.790
CHAPTER17NAME=Chapter 017
CHAPTER18=08:16:16.331
CHAPTER18NAME=Chapter 018
CHAPTER19=08:46:16.920
CHAPTER19NAME=Chapter 019
CHAPTER20=09:16:17.460
CHAPTER20NAME=Chapter 020
CHAPTER21=09:46:18.050
CHAPTER21NAME=Chapter 021
CHAPTER22=10:16:18.639
CHAPTER22NAME=Chapter 022

Step 3:

Add the chapters to the audio file (creates Nero format chapter markers):

MP4Box -add track1.aac -chap track1.chapters test.mp4

Step 4:

Convert the Nero chapter markers to Quicktime chapter markers using mp4chaps from the mp4v2 project (you will want v1.9.1 or higher):

mp4chaps --convert --chapter-qt test.mp4
converting chapters in file "test.mp4" from Nero to QuickTime

Step 5:

Rename the file from .mp4 to .m4b extension so iTunes will see it as an audiobook:

mv test.mp4 test.m4b

Proof that it works:

and VLC showing the chapters:

Of course, we aren’t putting in any tags such as “author” or “genre” in this example. Use your favorite tags editor to do so.

Share Button

How to install Sybase’s ODBC driver on Ubuntu Linux for ASE/IQ/Replication Server/SQL Anywhere/etc

ASE 15.0.3 full install on Linux 32bit.
First we need to install unixODBC:

% sudo aptitude install unixodbc unixodbc-bin unixodbc-dev libstdc++5

Because of a bug within the Sybase ODBC install, we need to change /opt/sybase/DataAccess/ODBC/samples/drivertemplate.txt.

/opt/sybase/DataAccess/ODBC/samples/drivertemplate.txt:

[Adaptive Server Enterprise]
Description = Sybase ODBC Driver
Driver = /opt/sybase/ODBC-12_5/lib/libsybdrvodb.so
FileUsage = -1

Change to:

[Adaptive Server Enterprise]
Description = Sybase ODBC Driver
Driver = /opt/sybase/DataAccess/ODBC/lib/libsybdrvodb.so
FileUsage = -1

This template file is used to install the ODBC driver with unixODBC:

odbcinst -i -d -f /opt/sybase/DataAccess/ODBC/samples/drivertemplate.txt

Currently Sybase’s ODBC driver does not have a GUI component for unixODBC. I’m waiting on the bug #. Once I have it, I’ll update this post.

Now we are ready to define an ODBC dsn. We will need to create a template file to do so:

dbadev1.dsn

[dbadev1]
Description=Sybase ODBC Data Source
UserID=sa
Password=password
Driver=Adaptive Server Enterprise
Server=dba-dev1
Port=5000
Database=sybase_dba
UseCursor=1

To add it to unixODBC we need to run:

odbcinst -i -s -f dbadev1.dsn

If you wanted a system wide dsn:

sudo odbcinst -i -s -l -f dbadev1.dsn
Updated to include libstdc++5 for the newer releases of Ubuntu
Share Button

Ryan Putnam: How to upgrade Sybase ASE 12.5 to 15

Ryan Putnam: How to upgrade Sybase ASE 12.5 to ASE 15
Ryan Putnam: How to upgrade Sybase ASE 12.5 to ASE 15

Hi,
I have attached a sample ASE 15 upgrade document which I had created for version 12.5 and have made changes for our version 15 upgrades.  I don’t know if it will help anyone, but I seem to recall a few people asking for some documentation.  Hopefully it can be used as a template?  Anyways, you are welcome to look at it, clone it, get ideas, or whatever.

Enjoy,
Thanks,
Ryan

Share Button