|
||||||||
|
|
![]() |
|
|
|
|
||
|
Exchange Data the Easy Way with Windows File Shares by Michael Sansoterra There's nothing worse than doing something and later discovering there's a much simpler way. To my amazement and dismay, I recently learned that NetServer provides an elegant way for the iSeries to read and write files on a Windows file share. If you're like me, you knew NetServer allowed IFS folders to be published as shares for use on a Windows network. But did you know NetServer also works in the opposite fashion, allowing the iSeries to access data on a Windows share from a Windows PC or server? Users of Integrated xSeries Server will find this tip a yawner, because they already know about this capability. But for those you who don't, here's how it works. Windows share data is made available to iSeries commands and programs via a special file system on the IFS called QNTC. QNTC is located under the IFS root (/). When configured properly, Windows share data is accessed using the following format: /QNTC/ComputerName/ShareName/Path ComputerName is the name of a Windows PC or a server hosting a share, ShareName is the name of the share being accessed, and Path is a file or folder name located on the share. Here are the steps required to configure NetServer for Windows file share access:
You should see the entries from your share appear on the screen. If you add a file to your share on the PC side, press F5 on the iSeries WRKLNK screen and the new file should appear. The WRKLNK screen should look similar to the following:
Work with Object Links
Directory . . . . : /qntc/silver01/manuals
Type options, press Enter.
2=Edit 3=Copy 4=Remove 5=Display 7=Rename 8=Display attributes
11=Change current directory ...
Opt Object link Type Attribute Text
V4R5_SQLRef.pdf DSTMF
V4R5_VARPG_Parts_R > DSTMF
V4R5_VARPG_Program > DSTMF
V4R5_VARPG_Ref.pdf DSTMF
V5R1 Tips and Tool > DSTMF
V5R1_CLProgramming > DSTMF
V5R1_DB2TextExtend > DSTMF
V5R1_ILERPG_Ref.pd > DSTMF
V5R1_SQLHostLangPr > DSTMF
More...
Parameters or command
===>
F3=Exit F4=Prompt F5=Refresh F9=Retrieve F12=Cancel
F17=Position to F22=Display entire field F23=More options
The implications of accessing Windows file share data via the IFS are many: QSHell scripts and redirected output, Java programs and all CODE/400 source, etc., can be stored on a Windows share and simultaneously accessed by the iSeries. Windows shares can be backed up using iSeries hardware. Report processing output can be mapped directly to a user's home drive. An RPG program can directly read a text file on a Windows share using the OPEN and READ APIs. Here's a command I use to copy a source member directly to a file share on my laptop (computer name is SILVER_01 and share name is source):
CPYTOSTMF FROMMBR('/qsys.lib/mike.lib/qrpglesrc.file/program.mbr')
TOSTMF('/qntc/silver_01/source/program.rpgle.txt')
STMFOPT(*REPLACE)
STMFCODPAG(437)
Make sure to replace your computer name and share name information. Of course, you'll have to possess write authority to your share in order for this command to create a text file on the share. If you don't have write authority, you'll receive a CPFA09C "not authorized to object" error. Also note, in the above example, that code page 437 (often used by English Windows versions) is specified for the translation from EBCDIC to ASCII (STMFCODPAG parameter). The *PCASCII special value can be used but often does not translate special characters correctly. The User Log-In Caveat One drawback to this scenario is that the iSeries user name and password has to match a Windows user name and password. This is a problem for many shops because there is no consistency between iSeries and Windows credentials. Further, adopted authority does not affect data access on the IFS. Fortunately, Shannon O'Donnell's excellent SWAPUSRPRF program (see "Swapping AS/400 User Profiles") does the trick by temporarily swapping the current user's profile with a different profile: one that's capable of accessing the file shares on the network. After downloading and compiling this utility, create a common profile/password combination on both the iSeries and your Windows PC or server. This profile should have limited authority on the iSeries and have authority to one or more shares on the Windows network. Next, simply modify the sample CL program Shannon supplied:
PGM PARM(&USERID &PASSWORD)
DCL VAR(&ORGUSER) TYPE(*CHAR) LEN(10)
DCL VAR(&USERID) TYPE(*CHAR) LEN(10)
DCL VAR(&PASSWORD) TYPE(*CHAR) LEN(10)
/* GET THE CURRENT USER PROFILE */
RTVJOBA USER(&ORGUSER)
/* SWAP JOB'S CURRENT USER PROFILE TO SUPPLIED PROFILE */
CALL PGM(SWAPUSRPRF) PARM(&USERID &PASSWORD)
/* PERFORM TASK ON PROTECTED QNTC PORTION OF THE IFS */
WRKLNK '/qntc/silver_01/source/*'
/* SWAP BACK TO THE ORIGINAL USER PROFILE */
CALL PGM(SWAPUSRPRF) PARM(&ORGUSER '*NOPWDCHK')
ENDPGM
When you call this CL, pass the name and password of the Windows share profile you created. This will allow the share to be temporarily accessed by the profile. When the program completes, the job continues to run under the original profile, at which time the Windows shares will be unavailable to users who don't have a user name and password that matches their Windows system. Windows XP Sharing Also, the NetServer documentation indicates that Windows XP sharing is supported in V5R2. I'm assuming this means that the new Windows XP "simple file sharing" may not be recognized by an older version of NetServer. Learn to Share The benefit of using the QNTC file system is that it offers real-time file-sharing capabilities with Windows-based systems. This makes it unnecessary to use file transfer mechanisms like FTP because the file transfer work can be done transparently by NetServer! For more information on configuring NetServer, go to the iSeries NetServer Web site. Michael Sansoterra is a programmer/analyst for SilverLake Resources, an IT services firm based in Grand Rapids, Michigan. E-mail: msansoterra@silver-lake.com
Editors: Howard Arner, Joe Hertvik, Ted Holt, David Morris,
Managing Editor: Shannon Pastore
Publisher and Advertising Director: Jenny Thomas
Advertising Sales Representative: Kim Reed
Contact the Editors: To contact anyone on the IT Jungle Team
Go to our contacts page and send us a message. |
|
| Copyright © 1996-2008 Guild Companies, Inc. All Rights Reserved. |