Using Stat & PuTTY's PLink Utility

Introduction:

This Blog has been prepared to assist you in becoming familiar with the Pre & Post Migration steps within Stat specific to using Stat and the
PuTTY Telnet/SSH application in command line mode.

 

Pre & Post Migration Steps

Pre and Post migration steps define activities you perform before and after a migration an archive set occurs. These steps are performed either
manually by the user or automatically by Stat. The steps are meant to promote adherence to development standards and are not mandatory or
enforced.

 

Migration steps can be associated with specific object types and within specific target environments. This means that when you migrate an
archive set that includes an associated object type, or when you migrate an archive set to an associated environment, Stat opens the
Pre Migration Steps window.

 

The window displays a checklist of actions that need to be taken immediately before the archive set is migrated.

 

Below are sample screens of the different types of calls we can make.

 

The “Step Name” field indicates its use, and the “Object Type” field indicates the type of object that this step, or process, is to watch for
and react appropriately.

 

Pre-Migration Steps Setup Screen for Custom Application Processes:

 

 

 

Pre-Migration Steps Setup Screen for PeopleSoft Processes:

 

 

Please Note: Post-Migration Steps are setup in the exact same fashion.

 

 

 

 

Sample Pre & Post Migration Steps Utilizing PuTTY’s PLink:

 

The following is an example of calling a Linux Shell Script to delete a file prior to a new file being migrated to that server.
The call utilizes PuTTY’s PLink functionality to SSH into the remote machine, execute steps as required and return control to the
local calling machine. For additional Command Line Calls or information on using PLink, please see Appendix A at the end of this post.

Return to Top

 

Pre-Migration Step Example:

Step I: Pre Migration Step Record Setup:

Once you hit the Apply button the “Define Command” button is enabled.

Select the “Define Command” button to enter in the scripts, or processes, that we want run when this item gets triggered.

 

Return to Top

Step II:
Pre-Migration Step Command Setup:

 

We enter our command, with parameters to be included, in the lower left hand box.
We can select the “Interpret Command” at anytime to see what the parameters will be interpreted into. (Provided there is a value to get at the time.)

 

Command Breakdown:

The follow two values show how the Stat Stored Parameters are automatically interpreted and inserted into the command call at runtime so the process
can run based on the proper location and permissions that are needed.

 

The following two values, Uninterrupted and Interpreted, shows how the command line parameters are converted from a stored/encrypted value, to the
required value needed to properly execute the job at runtime.

 

Uninterrupted: (Pre-Migration Step Setup):

CMD /C %%MyIPAddress%%\%%BatchDirectory%%\Linux_Scripts\PLinkLinuxDelSQR.bat %%TARGET_OBJECT_NAME%%


Interpreted: : (Runtime Interpretation of the Values):

 

CMD /C 127.0.0.1\P:\BatchFiles\BatchScripts\BAT_Scripts\Linux_Scripts\PLinkLinuxDelSQR.bat MyJavaBld.war


Runtime Processing:

When the Stat Migration starts, and you drag-n-drop the archive code set from one environment to another Stat looks through the objects
that are physically getting moved and checks to see if there are processes that need to be run prior to their migration.

 

When we migrate an object, such as a Java WAR file in our example, Stat will do a look-up in the pre-migration steps command and pull
back the matching job that must get executed prior to the migration.

 

The Pre-Migration Runtime Window will appear at the time of migration. The jobs listed in the below screenshot are controlled by the
items included in the migration package.

 

 

Pre-Migration Steps Execution at Runtime:

The highlighted row above in green indicates that we are migrating an Object Type of "Java WAR" file.
When Stat see's one of these files in a migration action, it knows to call the associated step "RMV_LINUX_FILE_B4_MIGR" prior to 'physically' moving
the objects in this migration package. The call will remove a file that is hosted out on our Linux Server at another location.

However, we are currently running on a Windows Machine in another location... What’s an Administrator to do! (Oh My!)

 


Our PLink Pre-Migration Step to the Rescue!

Our command calls a local script to run PuTTY’s PLink application for us.
This script will do the following:

  1. Load the PuTelnet/SSH application via Command Line Mode.
  2. Login and authenticate us to our Linux Server.
  3. Run a remote script on the Linux Server that we have predefined, passing along any command line parameters.
  4. Watch for Success/Fail.
  5. React accordingly.

 

Return to Top

Calling PLink:

As mentioned above, our PuTTY PLink script as busy task list to accomplish, so let’s get cracking!

Below is a copy of our local call, or parent, script: PLinkLinuxDelSQR.bat

Below is the script to be run on the local machine that will launch PuTTY PLink, connect to my Linux machine, login, authenticate,
and call a shell script on the remote machine to remove the file as needed.


Example: PLink_Lnx_DelFile.bat

Echo Off

REM ===========================================================================

REM PLink_Lnx_DelFile.bat: CMI Connect Remote Linux & Execute Remote Script.

REM ===========================================================================

REM Written By William R. Hart, Solutions Architect.

REM Quest Software, Inc. Copyright 2011

REM ---------------------------------------------------------------------------

REM DESCRIPTION:

REM The following script is a sample of using PuTTy P-Link,

REM or PLink, which is a Command Line interface into the

REM PuTTY tool which can log into remote servers, execute steps

REM as required, and return results as requested.

REM

REM A simple explanation would be that you are running

REM PuTTY, using profiles previously setup, and calling into

REM a remote server with the profile params and executing processes

REM as needed.

REM

REM In this case: YOU'RE doing ALL of THIS in a SINGLE COMMAND LINE CALL!

REM (-You Rock!)

REM ---------------------------------------------------------------------------

REM INSTRUCTIONS/DESCRIPTION:

REM 1. Takes the Command Line FileName To Be Deleted.

REM 1.5

REM 2. Load PuTTY's PLINK Command Line Interface Utility.

REM 3. Log into Remote Linux Environment.

REM 4. Execute Remote Shell Script: delfile.sh

REM 5. Capture Output and Return.

REM ---------------------------------------------------------------------------

REM CALL PLINK: CLP: (Cmd Line Params)

REM CmdLine: N:\Program Files\Putty\PLink -v (Verbose)

REM -ssh (Run via SSH)

REM -batch (Batch Mode)

REM -pw (Encrypted KEY or PWD)

REM uid@195.555.555.555 (Target Server)

REM sh DelFile.sh (Run This Script)

REM ---------------------------------------------------------------------------

REM Test Call:

REM N:\Putty\PLink -v -ssh -batch -pw pwd uid@195.555.555.555 sh DelFile.sh %1

REM ---------------------------------------------------------------------------

REM Stat Post Migration Call:

REM TEST:

REM CMD /C N:\Putty\PLink -v -ssh -batch -pw pwd uid@195.555.555.555 sh %1

REM PROD:

REM CMD /C N:\Putty\PLink -v -ssh -batch -pw pwd uid@195.555.555.555 sh %1

REM ===========================================================================

REM --- SAMPLE ONLY ---

REM ***** NOT RESPONSIBLE FOR USE, MISUSE OR RESULTS OF USE *****

REM *** IF YOU DONT FULLY UNDERSTAND IT, PLEASE DO NOT USE IT ***

REM --- SAMPLE ONLY ---

REM ===========================================================================

REM:

REM --------------------------------------------------------

REM Confirm we have a Valid Command Line Params.

REM --------------------------------------------------------

IF "%1"=="" GOTO CmdLnPrmsNotFnd

ECHO "Processing the Following Commands: " %0

ECHO "Command Line Param #1 = " %1

 

START C:\Program Files\Putty\PLink -v -ssh -batch -pw pwd uid@195.555.555.555 sh DelFile.sh

 

REM --------------------------------------------------------

REM SCRIPT SUCCESS: Tell User - Exit Clean.

REM --------------------------------------------------------

Echo "Script Process " %1 " Completed Activities For " %2

ECHO "Please Check Above For Errors Before Closing!"

Pause

Exit

 

REM --------------------------------------------------------

REM SCRIPT FAIL: No Command Line Params - Tell User - Exit.

REM --------------------------------------------------------

:CmdLnPrmsNotFnd

Echo "FAIL: INVALID Cmd Line Params Passed."

ECHO "Please Check Values and Try Again. Exiting..."

Pause

Exit

 

REM -------------------------------------

REM < End of Script >

REM -------------------------------------

 

 

When the script completes, we interpret the results and close the window. If there are other objects in our migration that also need to do
particular functions or processes, they too will be called following the pre-established firing order we configured.

 

Return to Top

Summary:

Stat’s Pre & Post Migration steps make the everyday, monotonous and repetitive, tasks easier to remember and easier to automate.
There are always things we would like to do ‘If we had the time’. Let Stat give you that time back by handling these types of tasks for you!

 

In summary, the value of using Stat’s Pre & Post Migration Steps to streamline the migration process.

  1. Pre-Migration Steps offer preprocessing activities such as:
  1. Compiling Applications and Objects (Such as *.EXE, *.JAR, *.WAR, *.SLN)
  2. Zip/Unzip File and Folders
  3. Export/Import Data Tables and Database Definitions
  4. Backup File and Folders
  5. Run Pre-Migration Processes That Are Currently Executed on a Manual Basis
  • Post-Migrations Steps offer post-processing activities such as
    1. Running Migrated Scripts/Executables.
    2. Export/Import Data Tables and Database Definitions
    3. Zip/Unzip Files and Folders
    4. Deploy Migrated Structures and Applications (Such as *.EXE, *.JAR, *.WAR, *.SLN)
    5. Execute Compilers and Deployment Routines.
  • The PuTTY PLink utility is a great, free, way to integrate with Stat to remotely execute shell scripts, or other processes that
    need to be run in your UNIX environments.

 

The resulting combination gives Developers, System Administrators, and Migrators the ability to pursue even more capabilities to further
enhance and improve other area of their system, and free them up to take advantage of other opportunities within the organization.

 

Return to Top

 

 

Appendix A: PuTTY’s PLink Tool


For a direct link to the PuTTY PLink command line options please see the following reference: Chapter 7 Help on PLink

 

PuTTY homepage is located here: PuTTY_Home_Page

 

 

Thank you for taking the time to read this Blog and I hope that you found it useful.

 

 

Respectfully Submitted,

 


William R. Hart

Solutions Architect
Quest Software, Inc.

 

 

 

 

 

 

 

 

 

Anonymous