IBM Support

Unix commands for Sterling B2B Integrator users

Technical Blog Post


Abstract

Unix commands for Sterling B2B Integrator users

Body

Unix commands for Sterling B2B Integrator

The Unix command line has hundreds of commands which are useful for discovering information about your Sterling B2B Integrator (SI) system.  Here are some of my favorites, all of which are available on most Unix and Linux systems.  These examples are intended to be run from the command line prompt of your host system for SI.  Except where noted, they can be run by the user who installed SI.  (A few require “root” or unlimited administrator access.)

Note: These commands may be useful from the command prompt for your perimeter server as well.

 

Documentation:

man: The Unix manual is on-line via the “man” command.  It contains detailed information on how to use any Unix command.  A few examples:

   man telnet – dozens of pages on how to use the “telnet” command

   man tcpdump – information on how to use all of the options for “tcpdump”

Some commands have multiple man pages for different sections.  For example, on Redhat Linux, if you use “man grep” it will return this:

   * grep (1)

      grep (1p)

If you hit Enter, or 1 and then Enter, you will see the basic manual page.  If you type “1p” and then Enter, you will see the documentation for the Posix version of the command.  Some man pages have several sections.  You can see information about the different sections by typing “man man”.

Tip: The ‘man’ command shows a formatted version of the document to make it easier to read.  If you want a plain text file, for example if you want to e-mail a man page to someone, filter the command like this:

   man grep | col –b > grep-man.txt

 

Communications:

telnet:  The telnet command is a basic tool designed for connecting to other systems, including other Unix systems.  It’s disabled on many systems because it does not provide any security for your communication connection.  It should not be used for that, but it is still a useful tool for SI admins and users.

Host not found:  If you have a “host not found” or “Cannot connect to” error, it may be that your network doesn’t allow the connection, or has a problem of some sort, it might be blocked by your firewall, or it might be blocked by your partner’s firewall.

Try this command:

telnet hostname PORT

   where “hostname” is the name of the system and “PORT” is the port to which you need to connect.

For example, this command will attempt a connection to as2.mypartner.com on port 5080:

   telnet as2.mypartner.com 5080

This will work when connecting to the server using any protocol.  If you see the word “connected” in the response, you know the server allows you to connect to that address.  If you see a long delay then your server doesn’t allow you to connect to that server.  If you see “Connection refused” you’ve reached the server “as2.mypartner.com” but can’t connect to the port you’ve selected.

Extra: You can use this to connect to your own system to make sure you can connect to a particular port.  If your SFTP Server Adapter is configured for port 5122, then try this command:

   telnet localhost 5122

It will test the connection to make sure it’s in use for your local system.  The “localhost” server is the name for your own computer.

When you want to exit the telnet command, type CTRL+[ then the word, “quit”.

netstat: The netstat command lets you see what ports are available and what  ones are in use.  It can be used for more advanced diagnostics, but I just want to introduce it for it’s most basic functionality for SI users, which is determining what ports are in use and available.

If you’re setting up a server adapter, such as the Connect:Direct Server Adapter, you have to specify a port that is not already in use.  You can keep specifying ports at random, then trying to start your new server adapter, but that can take a very long time.  Instead, try this Unix command:

   netstat –an | grep PORT

For example if you want to know if you can use port 12000 for your server adapter:

   netstat –an | grep 12000

If it returns a blank line, you can use that port for your adapter.  (Remember that you have to make sure your network admin allows your partners to connect to it, too.)

If it returns a line with the word “LISTEN” then that port is already in use.

NOTE: You can use this command after setting up and starting your server adapter to make sure it is active.

 

 

Disk and string commands:

There are many, many commands on a Unix system for searching, locating and manipulating strings of text.  Here are some basic ones for locating information that may help in diagnosing an error.

grep: The grep command is a very powerful tool for finding patterns in a text string.  It uses an implementation of regular expressions to allow the user to find different types of strings.  It can be used to search a file, or to search results from another command.

Here are a few examples:

grep ERROR system.log.*

   Run from the SI/install/logs directory, this command will search for all occurrances of lines with the word “ERROR”, which denotes error messages.

It’s case sensitive.  If you wanted to do a search that is not case sensitive, run the command like this:

   grep –i error system.log.*

You can search for patterns, too.  If you want to search for “ ERROR: ” with a space before “ERROR”, a colon, and a space after the colon, put the search text in quotes:

   grep “ ERROR: “ system.log.*

There are many options for the grep command, such as:

   -I  ignore case

   -l return the file name only
   -o return lines that do NOT match the pattern

If you want to find all of the logs that have “ERROR” in them, here you go:

   grep –l ERROR *

It will return only the file names.  That can be helpful when many logs have errors and you want to determine which ones to search.

You can run the results from a command through “grep” to filter the results.  I did that earlier in this blog when I introduced the “netstat” command.

 

find: The find command can be used to locate files in a directory structure, and also can be combined with other Unix commands to do operations on them.

Some examples:

find . –name test.txt\* –print

   Returns the location for every file name beginning with “test.txt”.

find . –name test.txt\* -exec rm {} ;

   Deletes every file, everywhere in the specified file system, that begins with “test.txt”.

The “-exec” option applies the specified command to every file that matches the search result.  Many different Unix commands can be specified.  In this case I used “rm” but you could search just those file names using “grep”, use a “sed” or “awk” script to manipulate them, or “mv” to move them to a new location.

The string “{} \;” designates the file name that was found

find . –delete test.txt\*

   Deletes every file beginning with the name “test.txt”

find . –mtime 2 –print

   Locates every file that has been modified in the last 2 days.

find . –user UNAME –print

  Finds every file owned by “UNAME”.  For example, if you wanted to find all of the files owned by “si_admin” you could use this command:

   find . –user si_admin –print

ls: The “ls” command is used to list files in Unix.

   To list all of the file names in a directory, the basic command is:

ls –l

As with many Unix commands, there are powerful options that make it even more useful.  When I am diagnosing an error for Sterling B2B Integrator, I often list the files in reverse order by date modified, so the most recently updated files appear last on the list:

ls –ltr

So if I test something, and then run that command, I know which logs were just updated.

vi: The Unix “vi” editor is a powerful tool for searching and editing files from the command line of the Unix environment.  Books have been written about this editor, which is found on every Unix and Linux system.  Here is a link to one that I like a lot (IBM does not necessarily support this endorsement):

   http://www.discoverbooks.com/ProductDetails.asp?ProductCode=1565924266&gclid=CMe507K98dACFc64wAodCwcH_A

You can edit any text file in vi, like this:

vi textfile

You can then edit it or do searches within it.  Here are a very few helpful examples for getting around in vi:

^   The “^” key will move the cursor to the beginning of the current line

$  The “$” key will move you to the end of the line

1G If you type “1G” your cursor will move to the first line of the file

G If you type “G” your cursor will move to the last line of the file

PgUp, PgDn The PgUp and PgDn keys on your keyboard will move up or down one page, just like in most editors

/string If you type “/” and a string, then hit Enter, your cursor will move forward to the next line matching that string.

/  If you then type just “/” and Enter, your last search will be repeated.

?string If you type “?” and then a string, your cursor will move to the previous line matching that string.

:g/string/p If you type “:”, then the letter “g”, then a string, then “/p” you will show every line matching that string in the whole file.  This is a great way to find error messages in the file.

:number If you type “:number” and hit “Enter” you will see line numbers before each line

 

That’s it for today.  I hope there was something in this blog that is useful to you, if you work with or administer a Sterling B2B Integrator instance on a Unix or Linux platform.

If you know of useful commands and techniques, please feel free to comment on this blog entry.  If you want more information about related subjects, please let me know.  I will appreciate any and all questions and comments.

Thanks!

[{"Business Unit":{"code":"BU059","label":"IBM Software w\/o TPS"},"Product":{"code":"SS3JSW","label":"IBM Sterling B2B Integrator"},"Component":"","Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"","Edition":"","Line of Business":{"code":"LOB59","label":"Sustainability Software"}}]

UID

ibm11121319