Monday, January 22, 2018

Using plink.exe and SSH to run a remote CL command on IBM i

If you want to connect to an IBMi system via SSH and plink.exe, run CL system commands and possibly get message responses from the call, the process can get interesting because of the system command and program call syntax causing issues. As it turns out it's not all that hard to format a command line with parameters for running via plink. 

ere’s what you can do if you can’t write a CL command wrapper and want to use plink.exe to run IBMi programs or commands:

Original - Problem - This one passes the numeric parameters as numeric values, but we want them to be character. The command interpreter thinks they are numeric parameters
plink -ssh "user@" -pw pass1 /bin/system 'CALL PGM(LIB/PLINKTESTC) PARM("999   " "222   ")'

Fixed with special characters (,), / and ’ all escaped with a backslash \ and with double quotes around the entire command.
plink -ssh "user@" -pw pass1 /bin/system “CALL PGM\(LIB\/PLINKTESTC\) PARM\(\’999\’  \’222\\)”

An easier option might be to build a CL command wrapper

Sample CL command wrapper which handles all padding and conversion of data to proper typesplink -ssh "user@" -pw pass1 /bin/system 'RJSDEVHS/PLINKTEST PARM1(999) PARM2(222)'

Providing Feedback from plink.exe
You can feedback CL message responses via SNDPGMMSG if you plan to send back any CL responses from plink.exe to be consumed by the caller.

Sample IBMi Code

 PGM        PARM(&PARM1 &PARM2)                         
 DCL        VAR(&PARM1) TYPE(*CHAR) LEN(10)             
 DCL        VAR(&PARM2) TYPE(*CHAR) LEN(10)             
              |> &PARM1)                                
              |> &PARM2)                                

PLINKTEST - CL Command Wrapper
CMD        PROMPT('plink test')                        

Sunday, January 21, 2018

Visual Studio 2017 15.5.4 IDE crashes when typing in C# Source Member

I was working with a C# source member yesterday and my Visual Studio IDE started crashing randomly. I updated from 15.3 to 15.5.4 to see if the problem would go away but it didn't. I saw a few posts when googling that talked about disabling the C# edit and continue option to get rid of this issue. Since I have only ever used edit and continue in VB I thought it was worth a try. 

Sure enough since I disabled edit and continue my C# editor hasn't crashed since.

Here's a MS link for disabling edit and continue

Git for Visual Studio Developers–Get your .gitignore right and save yourself needless merges

When using Visual Studio with Git, you probably want to ignore baggage files that may result in repository merge issues on a regular basis. 

Check out the following link for an explanation on how to add the appropriate files to your .gitignore file list.

The following link takes you to the raw .gitignore example file

Using Alternate Windows FIle Manager

If you're like me you're always looking for tools to make your day more productive. Back in the early days of PCs I used a tool called Norton Commander for file navigation and quick file editing. On Linux and IBMi I now use Midnite Commander. 

Listed below is a list of good FREE alternatives for Windows file management. 

Windows File Explorer Apps

Explorer ++

Free Commander

Norton Commander Look-Alikes

Midnight Commander

Far Manager

Feel free to send me your favorites.

Thursday, January 18, 2018

Capturing IBMi Spool File Print Documents via Windows LPD Service

Some IBM i or Mainframe users may have a need to push spool files from the IBM i/AS400, Mainframe or other systems to a Windows server so the binary or text output can be captured and processed electronically. It's pretty easy to use Windows LPD server to help the process along. 

Steps to Set up Windows Print Services and Print Queue for Capturing Print from Other Systems

Install Windows LPD Server on Windows (By Installing Print Services in Windows 2008, 2012, 2016 or Windows 7, 8 10)

Create a new output directory called: c:\localprint and another subdirectory called c:\localprint\spool

Add a Generic Text Windows Printer and name it MAINFRAME, IBMI or whatever is desired. Make sure it is shared with the same name. MAINFRAME, IBMI, Etc.
During printer creation create a new port for the printer that outputs to c:\localprint\report.txt

After printer creation go in to printer Advanced properties and check/enable the Keep Printed
Documents setting and uncheck/disable the Enable Advanced Printing Features settings.

This will insure the .SHD and .SPL files created by the printing process are kept after printing to disk file c:\localprint\report.txt. 

Note: c:\localprint\report.txt will never be processed. For any custom processing we will process the saved spool files (.SPL) from Windows print creation. We will ignore the .SHD files which appear to hold printer settings. Periodically the c:\localprint and c:\localprint\spool directories should be cleared of files that have been processed by a custom process.

Use regedit to go into Windows Registry and edit the following key: 

Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\PrintPrinters\MAINFRAME (or whatever your printer name is). Set the SpoolDirectory parm in the registry key to c:\localprint\spool

Re-start Windows Print Spooler service or reboot server.

Sending Over an iSeries Text Based Spool File with Line and Page Breaks via LPR/LPR

Example command to send over spool file from iSeries to Windows server

Create remote outq to send spool files over automatically from the IBM I

Sunday, January 14, 2018

IBM i Access from .Net with JT400

If you have been using Microsoft .Net for Windows development in C# or VB and would like to access IBM i - AS/400 data, programs, IFS files, data areas and more easily from a .Net desktop application, web application or web service, check out this nuget package. 

I converted the jt400.jar from the IBMi Java Toolbox to .Net using an open source project called IKVM. You can do the same or just install the nuget package. 

I've been using this successfully in applications since 2005.

PyDev Python IDE for Eclipse

PyDev is a Python IDE for Eclipse, which may be used in PythonJython and IronPython development.

I discovered this Eclipse based IDE environment for Python development when I was looking for Python IDE and debugging tools. 

Check it out if you plan to do any Python development.

Windows Modern UI for .NET WinForms Applications

If you develop any .Net WinForms applications and you like using open source components, check out the MetroFramework. 

These controls provide rough equivalents to the built-in Windows form controls and they come at no cost.

Using Midnite Commander on IBM i via SSH and Putty

If you used Norton Commander back in the day you probably remember this DOS utility with a side-by-side directory list.

It saved my life back in the early days of PCs.

I discovered Midnite Commander a few years ago which functions as a functional equivalent to Norton Commander in Linux.

There is also an AIX version so now that I have SSH working I thought I would give it a try.

It appears to work just fine. Very cool.

This will be useful addition when doing IBMi command line work via putty.

If you're using SSH and Putty to access the IBMi remotely check it out.

Listed below is a loose list of instructions for getting MC to work on your IBMi.

Create Local IBM i Copy of Perzl RPMs (replaced by OPS product)

Use the above URL and instructions to create a local IBMi copy of Perzl *.deps tree for use with the script.
Thw script will help you download and install AIX binary builds and dependencies to your IBMi PASE environment from the Perzl AIX site.

Installing Midnite Comander from a PASE Command Line

Once the Perzl RPM items have been resolve run the following steps from a PASE or SSH putty terminal.

Note: make sure the updated and files have been installed and has been run prior to trying the next steps.

Start the PASE command line or log in via SSH and Putty 

call qp2term    --enter the PASE command line

cd /QopenSys/download  --Change to location

List to see if Midnite Commander is available
./ aix61 list mc-

Download Midnite Commander via wget
./ aix61 wget mc-

Install Midnite Commander
./ aix61 rpm mc-

Create symbolic link for all users to use MC without path
ln -sf /QOpenSys/opt/freeware/bin/mc /QOpenSys/usr/bin/mc

Now you can simply log in to putty or other SSH terminal session and type:
mc or mc -c to use Midnite Commander. 

Run Midnite Commander

Black and white mode



Color Mode
/QOpenSys/opt/freeware/bin/mc -c


mc -c

Now start enjoying Minite Commander.

You'll find it very easy to navigate the IFS, browse or edit text files right from the IBMi system,

Midnite Commander User Interface

Update for January 2022

Now it's as simple as using yum to install Midnite Commander from a PASE command line if you have the IBM Open Source Package Management installed on your IBM i system.

yum install mc