Escolar Documentos
Profissional Documentos
Cultura Documentos
MPEIntroductionandTipsforUnixUsers
Robelle
What'sNew
Support
JustAskUs
PopularApps
Resources
SiteMap
MPEQuickstartforUnixUsers
Basedonthetechnicalsupportcallsthatwearereceiving,itappearsthatmanyHP3000systems
arebeingputinthecareofstaffwithonlyUnixandWindows.Sowehavedecidedtowritea
seriesofintroductionstoMPEfortheseluckysouls:
Part1:CommandCrossReference
Part2:LoginandLogoff
Part3:Files
Part4:FileContent
Part5:Scripts
MPEforUNIXUsers,Part1
CrossReferencefromUnixCommandstoMPECommands
FirstthingyouneedtoknowisthatMPEhasUnixlikefeaturesintegratedintoit(viaPosix),butmostapplications
andsoftwaretoolswerewrittenwiththenonPosixfeatures.
BasicMPEconsistsofasingleshell(thecommandinterpreter)andafilesystemthathasonly3levels(user,
group,account)buthasmanyfileattributesincludingrecordsize/type,maxfilesize,extentsandpasswords
(calledlockwords).
The3rdpartyproductMPEXisanalternateshell,asissh.pub.sys(thePosixshell).
(ThiscrossreferencelistbelowisadaptedfromaninverselistbyNeilArmstrongofRobelle.)
UNIXCommand
EquivalentMPECommand
sh
commandinterpreter,mpexorposixshell
ksh
commandinterpreter,mpexorposixshell
csh
commandinterpreter,mpexorposixshell
.profile(sh)
optionlogoninUDC
ksh$r,csh%!
whiledo,dountil
<file(input)
<file
>file(output)
>file
>>file(append)
>>file(append)
<<hereisdoc
Notsupported
scripts
commandfiles,udc
#atstartofline
comment
http://www.robelle.com/tips/mpeforunix.html
1/13
9/3/2015
MPEIntroductionandTipsforUnixUsers
command&
Notsupported,usejob
cmd1&&cmd2
Notsupported
$r(ksh),%!(csh)
redo
x=vexportNAME
setvar
abortjobkill[9]
abortio
adduser
newuser
at
stream
batch
stream
cancel
deletespoolfile
cd
chdir
chmod,passwd
altacct
chmod,passwd
altgroup
chmodfile
altsecfile
chmod,passwd
altuser
cp
copy
cpio
store
date
showtime
dc
calc
df,bdf
discfree,dstat
du
diskuse,report
echo
echo,rprint
ed
editor,quadorqedit
env
showvar
exit
bye,exit,eoj
fbackup(hpux)
store
fc1(sh)
listredo
fi
endif
ftp
ftp,dscopy
ifthenelse
ifthenelse
history
listredo
hostname
showme
http://www.robelle.com/tips/mpeforunix.html
2/13
9/3/2015
MPEIntroductionandTipsforUnixUsers
login
hello,job
logname
showme
kill[9]
abort
ld
linkedit
lpq
showout
lprm
deletespoolfile
lpstat
showout
ls
listf,listfile
man
help
mesgn
setmsgoff
mkdir
newdir,newacct,newgroup
more
mv
rename
printenv
showvar
ps
showproc,showq
pwd
pwd
rwall
warn
rebooth
=shutdown
rm
purge
rmdir
purgegroup,purgeacct
sed
editor,quad,qedit
setenv
setvar
su
god(3rdpartyvesoft)
symboliclink
fileequation,posixlink
tar
store
touch
build
unset,unsetenv
deletevar
users
showjob
vi
qedit
wall
warn
whence
help
whoami
showme
http://www.robelle.com/tips/mpeforunix.html
3/13
9/3/2015
MPEIntroductionandTipsforUnixUsers
while...do...done
whiledoendwhile
write
tell
MPEforUNIXUsers,Part2
HP3000LoginandLogoff
ByRobertGreen,Robelle
SoyouareanexperiencedUnix/WindowsSysAdminwhohasbeengiventheresponsibilityoflookingafteryour
firm'snetworkofHP3000s.AndyouhaveneverseentheMPEoperatingsystembefore.
Oneofthefirstthingsthatyoumightdoislogontooneofthesystems,usingthelogininstructionsandpasswords
leftyoubythepreviousadministrator.
Supposedyoufindtheoldadmin'sPCandonthedesktopareiconsfor"PROD3000Session"and"TEST3000
session".Ifyoudon'tfindtheseicons,lookforaprogramcalledReflection,orMinisoft,orQCTerm.Theseareall
softwareemulatorsfortheclassicHP2392/70092terminals.Withintheemulator,lookfor"Connect"inthe
menusandlookforalistofservernames.
(Youcanalsoconnecttothe3000withgenericTelnet,butsomecapabilitieswillbelost.)
Let'sclickonthe"Test"connectionfirst!Noneedtoexperimentonwhatisprobablytheproductionsystem.
Youshouldseeawindowthatlookslikeaclassic24x80computerscreen.Thenacolonshouldappearinthe
windowwiththecursorafterit.ThisistheMPEcommandprompt).
:
Youarebeingpromptedforlogin,justliketheloginuserpromptonUnix,exceptthatinthiscaseyouneedtotype
aHellocommand.
:hellomgr.product
Thecommandnameis"HELLO",whichmeansstartaninteractivesession.
TheUsernameis"MGR"usernamesnotlikeUnixusernames.
TheAccountnameis"PRODUCT",towhichtheUserbelongs.
Youwillusuallybepromptedforoneormorepasswords(theaccountcanhaveapasswordandtheusercanalso
haveapassword).Ifyouenterthemcorrectly,youwillseethecolon(:)promptagainyouareloggedon.Unlike
mostversionsofLinuxandUnix,youCANusethebackspacekeyinordertomakecorrections.
EntertheShowjobcommandtoseethatyouarelistedandseewhatotherusersessionsareactive.
:showjob
PreenteringPasswordsSaytheAccountpasswordis"xyz29b".Youcanenteritinresponsetothesystem
prompt,oryoucanembeditintheHellocommand,usingaslashbetweentheaccountnameandthepassword.
:hellomgr.product/xyz29b
Typicallywhenloggingon,mostusersletthesystempromptthemforthepasswordasthisisnotechoedtothe
screen.
UserNamesUserandaccountnamesarelimitedto8alphanumericcharactersandmuststartwithanalpha.
Usernamesandcommandsarenotcasesensitive(i.e.,mgr=MGR=Mgr).Usernamesarenotsystemwideasin
Unix.TheyareonlyuniquetoanAccount.Forexample,MGR.DEMOisacompletelydifferentuserfrom
MGR.PRODUCT.MGRisnotauniqueusername,butMGR.PRODUCTisunique.
Accountscanhavemanyusernames,suchasBOB.PRODUCT,BILL.PRODUCT,SALLY.PRODUCT,butoften
accountsonlyhaveoneUser.
Whyisthat?
Becausecertainsystemfunctions,suchasFileRename,canonlybedonebytheuserwhooriginallybuiltthefile
(theCreatorthisiscalled).IfyouhavemultipleUsersinanAccount,yousometimeshavetroubleperformingall
thefiletasksyouwishtoperform.Forexample,youlogonasBILL.PRODUCTandrebuildaproductionfile(youcan
http://www.robelle.com/tips/mpeforunix.html
4/13
9/3/2015
MPEIntroductionandTipsforUnixUsers
PurgethefilewithoutbeingtheCreator,butwhenyoubuildthenewfileyouarenowthenewCreator).Thena
nightlyproductiontasklogsonthatnightasBOB.PRODUCTandtriestorenamethefile.Itfailsbecauseitisnot
theCreatorandthetaskfailsaswell,causingoperationalproblemsinthemorning!
AnAlternativetoUsers
ThereisanalternativetohavingseveralUsernamesforanAccount:useSessionnamesinstead.
:hellobob,mgr.product
Thesessionnameis"BOB"anditwillshowupontheShowjobcommand,butdoesn'tmeanmuchofanythingelse.
ButallfilesinthePRODUCTaccountwillbecreatedbyuserMGRandcanberenamedbyanysessionnamethat
canloginasMGR.SoeveryonewouldloginasMGR,butwithauniqueSessionname.
Except!Vesofthasa3rdpartySecurity/3000productthatcancreatepasswordsontheSessionname.Thisvery
useful,especiallysincetheVesoftSessionnamescanbeappliedtoanyaccountifyoulike.Ineffect,thiscreates
somethinglikeaUnixusernamethatismostlyindependentoffiledirectories(yes,Accountsarealsofile
structuresinMPE).
FileStorageinAccountsandGroups
Youraccountalsoprovidesfilestorage.MPEfilesarestoredinGroups,whicharelikesubdirectoriesofAccounts.
UnlikeUnix,MPEfilesarenotstoredattheAccountlevel,butonlyatthelowerGrouplevel(andtherearenosub
Groupssorry!)
Forexample,thePRODUCTaccountmighthavefourgroups:
PRODUCTaccount
PUBgroupthisisadefaultgroupthatallaccountshave
DATAgroup
TEMPgroup
JOBSgroup
PROGRAMSgroup
Again,Groupnamesarelimitedto8charactersandarenotcasesensitive.
AndofcoursetherecanbepasswordsoneachGroup,justastherecanbeoneachAccountandUser.Security
accessrestrictionsareattachedtoAccountsandGroups(suchas"onlysomeonewhocanlogintotheAccountcan
readthefilesinthisAccount).
Eachusercanhaveadefaultlogongroup.WhenyoulogonyoucanseethefilesinyourlogongroupusingListfor
Listfile:
:LISTFshowstheMPEfilesinyourcurrentgroup
:LISTFILEshowsMPEandPOSIXfilesinyourcurrentgroup
YoucanspecifyadifferentlogonGroupaftertheAccountintheHellocommand
:hellomgr.product,jobs
Thereisonethingthatisquiteconfusingfornewusers.IntheHellocommand,theGroupcomesafterthe
Account,separatedbyacomma.Butinafilename,theGroupcomesbetweenthefilenameandtheAccount,
separatedbyperiods.Forexample,
MGR.PRODUCT,DATA
User.account,group
SALES2004.DATA.PRODUCT
File.group.account
Tomakethingsabitmorecomplex,thetrailingAccountandGroupnamescanbeleftofffromafilenameandwill
defaulttoyourcurrentloginAccountandGroup.
SALES2004.DATAinyourlogonPRODUCTAccount
SALES2004inyourlogonDATAgroupofthePRODUCTaccount
Theseareallthesamefile.
MappingMPEFilesintoPosixSpace
SinceMPEalsohasPosixfiles,howdoestheMPEfilesystemmapintothePosixstructure?Itisactuallyquite
simple.AllMPEnamesareconvertedtouppercase.
/PRODUCTtheAccountislocatedofftheRootnode
/PRODUCT/PUBthedefault"PUB"Group
/PRODUCT/DATAtheDATAGroup
http://www.robelle.com/tips/mpeforunix.html
5/13
9/3/2015
MPEIntroductionandTipsforUnixUsers
/PRODUCT/DATA/SALES2004afileintheDATAgroup
Effectively,theMPEAccountistreatedasarootdirectoryonPosix,withtheGroupstreatedassubdirectoriesof
theAccount.Veryneatinfact,thesystemallowsPosixfilestobecreatedwithinMPEAccount/Groupspace,but
thosefilescannotbe"seen"byordinaryMPEcommandssuchasListf(onlythenewcommandssuchasListfile).
HelpYourself
Insteadof"man"pagesonUnixorF1inwindowsorotherhelpfiles,MPEhasit'sownHelpfacility,whichcanbe
accessedby:
:help
ThatisenoughforyourfirsttimeonMPE.LogoffnowwiththeByecommand.
:bye
MPEforUNIXUsers,Part3
TheComplexWorldofFiles
ByRobertGreen,Robelle
Inpart2,weexploredthedirectorystructureofMPEabittoexplainaboutloggingon.Inpart3,welookatfilesto
seehowtheyaredifferentfromfilesinUnix.
TheFileSystemisoneareawhereMPEisreallydifferentfromUnix.Andmuchmorecomplicated.Let'sstartby
buildingafile,
:buildabc
Seemsjustlike
touchabc
inUnix,right?Wrongthe
build
commandhaslotsofoptionalparameters,allwithdefaults.
Toseewhatwe"built",weusethe
listf
command(thisislike
lsl
inUnix):
:listfabc,2
ACCOUNT=GREENGROUP=BOB
FILENAMECODELOGICALRECORDSPACE
SIZETYPEOFLIMITR/BSECTORS#XMX
ABC128WFB01023100*
The
listf,2
optionshowsthemostcommonattributesofanMPEfile.Otheroptionsshowaccessdates,creatorname,and
otherattributes.
FILENAMEfilenamesarelimitedto8charactersandcaseisnotsignificantjustasexplainedforuserand
accountnamesinpart2.
CODEafiletypenumberthattellsyouwhattypeofcontentthefileshouldhold.Someofthesehavemnemonic
labels,butunderneathallareintegervalues.Forexample,111isaQEDITworkfile,1030isanNMPROGfile.The
defaultcodeis0(i.e.,nothingspecial).ForalistoffilecodesusedbyHPandthirdpartyvendors,goto
http://www.robelle.com/smugbook/filecode.html
http://www.robelle.com/tips/mpeforunix.html
6/13
9/3/2015
MPEIntroductionandTipsforUnixUsers
Anegativefilecodemakesthefilea"privilegedfile"whichcanonlybeopenedbyaprogramrunninginprivileged
mode(inusermode,programscannotaccessorchangedatathatisnottheirowninprivilegedmode,programs
cangetatdataoutsidetheprogramtheoperatingsystemrunsinaspecialprivilegedmode).Themostwell
knownexampleofprivilegedfilesinMPEisdatabasefilestheycanonlybeaccessedbygoingthroughthe
databaseAPI(orbygoingintoprivilegedmode,accesstowhichisrestrictedbysystemsecurity).
SIZEspecifiestherecordsize.Unixfilesdonothaverecordsafileisjustastreamofbytes.ButMPEfileshavea
recordstructure(exceptforPosixbytestreamfiles,whicharelikeUnixfiles).
TherecordsizeistheamountofdatathatisreadorwrittenbyasinglecalltoMPE'sFREADorFWRITEintrinsic.
AnintrinsicisanMPEsystemroutine,justlikefreadandfwriteinUnix.
Thedefaultrecordsizeis128words(whichis256bytes,becausetheoriginalHP3000wasa16bitmachine).
TYPFBmeans"fixed,binary".Fixedistherecordformat,meaningthateachrecordcontainsexactly128words.
AnotheroptionisVforVariable.Binarymeansthatifafixedrecordisincomplete,itisfilledoutwithbinaryzero.
ThealternativeAforAsciimeansthatincompleterecordsarefilledwithblanks.Also,whenafileisAscii,theSIZE
columnwillshowtherecordsizeinBytes(128Bforexample).
EOFtellsyouhowmanylogicalrecordshavebeenwrittenintothefile(actually,itshowsyouthehighestrecord
numberthathasbeenwritten).Anemptyfilelikethisalwaysshows0fortheEOF.
LIMITtellsyouthemaximumnumberoflogicalrecordsthatcanbewrittenintothefile(forvariablelength
recordsthisnumberisbasedonwritingmaximumlengthrecords,soitisoftennotthereallimit).TheLIMIT
conceptiscompletelyalientoUnix.InMPE,aprogramcanfailbecauseitattemptstoappendarecordtoafile
thathasreacheditsLIMIT,eventhoughthesystemstillhaslotsoffreediskspace.
R/BRecordsPerBlock.IntheoriginalMPEyouspecifiedthenumberoflogicalrecordstobestoredinaphysical
blockofdiskstorage(ablockwastheamountnormallytransferredto/fromdisk).Overtheyears,theinternalsof
MPEhavechangedsomuchthatthisattributedoesnotmeanmuchanymore,althoughitismaintainedfor
compatibility.
SPACE,SECTORSLogicaldiskspaceinMPEismeasuredin"sectors",whichare256byteseach.Asrecordsare
writtenintoanewfile,diskspaceisallocatedinchunkscalled"extents"andthisSECTORvaluegoesup.Againthis
unitofmeasureisjustforhistoricalcompatibility,sincethecurrentversionofMPEactuallymanagesdiskspacein
pages,whicharemuchlarger.Ifyouwouldlikemoreexplanation,pleasesee
http://www.robelle.com/smugbook/pages.html
SPACE,#XMXdiskspaceisallocatedinextents,so#Xisthenumberofextentscurrentlyallocatedtothefile
andMXisthemaximumnumberthatcanbeallocated.Intheolddays,MXwaslimitedto32and#Xwentfrom0
to32,atwhichpointthefilewasfull.Andallextents,exceptthelastone,werethesamesize.
NowthedefaultMPEfilehas*forMX,whichmeansthatthereisnoeffectivelimitonthenumberofextents.
However,youstillmusthaveafixednumberfortheLIMITonlogicalrecords,evenifthatnumberis2billion!
BewarnedthatifyoucreateafilewithafixednumberofextentsandalargeLIMITinlogicalrecords(forexample,
builddef;disc=123456789,32
),youmayverywellgetanerrorsuchas"extentsizetoolarge".
HerearesomeadditionalfileattributesforMPE:
USERLABELSareoptional256byteareasforcontrolinformationthataretackedontothestartofthefilespace.
TypicalexamplesareSelfDescribingfilesandPowerhousesubfiles,wherethedatadictionaryisstoredintheuser
labelsthisleavesallthelogicalrecordswiththesamedataformat.Historicallytheycomefromoldmainframe
systems,evengoingbacktotapebasedsystemswherethetapeshadlabelsonthem!Theyaremostcommonly
usedinCOBOLsystemsthatweremigratedfromtheseoldIBMsystems.ThetypicalfileonMPEhas0userlabels.
CCTLstandsforCarriageControl.AfilewiththeCCTLattributehasanextrabyteatthebeginningofeachlogical
recordwhichtellswhethertodoapageeject,singlespace,doublespace,ormoreobscurefunctionbefore(or
after)printingtherecord.ThesearenotthesameasSpoolfilestheyaremorelikeantiqueportableprintfiles.
Thiscapabilitygoesbacktooldlineprinters,whichhadprogramtapes,whichcouldbecustomizedforspecial
formssuchaspreprintedinvoices.WhatisinterestingisthatmostofMPE'ssimulatedlineprinterfunctionalitystill
worksonDeskjetprintersandterminalscreenemulatorsbecauseMPEconvertstheCCTLcodesintoterminal
codes.
ThedefaultforanMPEfileis
buildabc;nocctl
.FormoreonCCTLfiles:
http://www.robelle.com/tips/mpeforunix.html
7/13
9/3/2015
MPEIntroductionandTipsforUnixUsers
http://www.robelle.com/smugbook/cctl.html
TEMPstandsfortemporaryfiles.OnUnix,temporaryfilesarejustpermanentfilesthatarebuiltinaspecial
directory,suchas
/var/temp
.Unixdoesnotnormallyhaveanautomaticcleanupfortemporaryfilesafterauserlogsoff.MPEtempfilesare
differentbecausetheyareactuallytemporary!Theyarenotrecordedintheregularfiledirectory,butinatemp
directorythatisattachedtotheuserlogon(interactivesessionorbatchjob).Anyprocesscreatedduringthelogon
canaccessthetempfilesofthatsession/jobandwhenthesession/joblogsoff,thetemporaryfilespaceis
returnedtothesystem.
MPEevenhasprocesstemporaryfilesthatareprivatetoaprogramandgoawaywhenthatprocessterminatesor
aborts.ThesearecalledNEWfilesandcanbesavedasTemporaryorPermanentfilesbytheprocess.
CIR,MSGstandsforCircularorMessagefile.MPEhasspecialfileswherethecurrentrecordpointereitherwraps
around(CIR)ormovesinsuchawaythatafreaderasestherecordthatisread(MSG).
KSAM,KSAMXLtheseareindexedsequentialfiles,withKSAMbeingtheoriginal,classicMPEversionandKSAMXL
beingtherewritefortheRISCprocessorsandMPE/XL(nowcalledMPE/iX).
So,youcanseethatoursimplebuildabcisactuallyamuchmorecomplexcommand:
:buildabc;rec=128,1,F,binary;disc=1024;code=0;&
std;ulabel=0;nocctl
Tuneinnextmonthfordetailsonhowtoworkwiththecontentofallthesefiletypes!
MPEforUNIXUsers,Part4
ExaminingtheContentofFiles
ByRobertGreen,Robelle
Inpart3,welookedatfiles.Inpart4,welearnhowtolookatfilecontent.
IfyouareaUnixperson,thefirstthingyoulookforismore,andtheMPEequivalentisPrint:
Printfilename
Printdisplaysthelinesofthefileon$Stdlist,stoppingeveryscreenfulandaskingifyouwantmore.Youcan
answerYorN.InUnix,youusuallypressSpaceforYesor"goon",butinMPEyouusuallypressEnter.
Printisonlyusefulforfilesoftextdata.Forlookingatbinarydata,thebasictoolprovidedbyMPEisFcopy.
ThemainpurposeofFcopyis"filecopy",butitcanalsodisplaybinarydatainHexorOctalformatanddosome
simpledataselection.Fcopyisasubsystem,whilePrintwasanMPEcommand.Youenterthesubsystemwiththe
Fcopycommandandithasitsowncommands.YouexitthesubsystemwiththeExitcommand(somelater
subsystemsusedQuitasUnixstartedtoinfluenceMPE).OthersubsystemsofMPEincludeEditorandSort.
:fcopy
>from=filename;to=;hex;char
>from=filename;to=;octal;char
>exit
:
NoticethatwhenyouenterFcopy,thepromptcharacterchangesfromColontoGreaterThan.Thisistypicala
ColonpromptalwaysindicatesthatanMPEcommandisexpected.
Thefirstcommanddisplayseachrecordoffilenameon$Stdlistasahexadecimaldumpandasacharacterdump
(CharreplacesnonprintingcharacterssuchasCarriageReturnandLinefeedwithPeriodtoavoiddisruptingyour
display).
ThesecondcommandconvertstherecorddatatoOctalinsteadofHex.
Thethirdcommand,Exit,getsyoubacktoMPE.
FcopyintroducesyoutoacoupleofotherMPEisms.
1)YouuseControlYtostopthelistingthisistrueforallMPEsubsystems,butforMPEcommandsusetheBreak
keyifControlYdoesnotwork.
http://www.robelle.com/tips/mpeforunix.html
8/13
9/3/2015
MPEIntroductionandTipsforUnixUsers
2)ThesyntaxoftheFcopycommandsisdifferentfromthatofMPEcommandsunfortunately,thisistrueofmost
allMPEsubsystemstheyallhaveslightlydifferentcommandsyntaxstyles.
Fcopyalsoallowsyoutoselectspecificrecordsnumbers,orrecordsthathaveaspecifictextstringatagiven
location.YouappendtheSubsetoptiontoyourcopytask:
subset=1/10
subset="string",column[,EXCLUDE]
ButFcopycannotselectonbinaryfieldsorlookformultiplestrings.
Forcomplextextsearches,theUnixuserturnstogrep,andMPEhasgrepinthePosixshell.Toentertheshell,
youtype"sh.pub.sys",whichisanimpliedrunonthe"sh"programinthe"pub"groupofthe"sys"account.When
youareinthePosixshell,youmustusePosixfilenames,notMPEfilenames.Sosh.pub.syswouldbe
/SYS/PUB/SH.
Forlookingatfilecontents,thePosixheadandtailcommandsareveryhandy(showthestartofafileortheend
ofit).
AnotherMPEsubsystemthatcanbeusedforexaminingtextfilesisEditor.
:editor
/textfilename
/find"string"
/list*
/exit
NoticethatthepromptcharacterisSlash,whileFcopyusedGreatThan.
Editorhasafairlypowerfulsetofsearchoptions.Inthisexample,Findlooksforthenextlinethatcontainsthe
stringatanylocationwithintheline.Buttofindallthelinesthatmatch,youmustprogramtheFindinaWhile
loop.
MPEalsohasawidevarietyoftexttoolsfromthirdpartiesthatyouwilllikelyonyoursystem,suchasQedit,an
Editorreplacementthatalsoprovidesfullscreenediting(seewww.qedit.com).
:qedit.pub.robelle
/textfilename
/list"string"
/exit
ThecommandsaresimilartoEditor,butthedefaultbehavioristotreatanyoccurrenceofastringasarequestfor
allthelinesthatcontainthatstring.QeditborrowsconceptsfromFcopyandothertools.Forexample,youcan
displaytheselectedlinesinHexadecimalifyouwish:
/list$hex$char1/10
Orignorecaseandonlysearchcertaincolumnsonstringmatches:
/List"enhancement"(Upshift20/50)
Orsearchforupto10stringsonasinglecommand.
/List"problem"or"bug"or"help"
Magnetisourmethodofchoiceforsearchingagroupoffiles,becauseitissofast.Itisapartof"Nuggets(aka
Toolboxes)",apackageofMPEutilitieswrittenbyStanSielerandfriends,andsoldbyLund.Bydefault,Magnet
liststhefileswithafilecodeofzero(regularfiles)or111(Qeditfiles)inyourlogongroupthatcontainatleastone
linewiththetargetstring.UsetheFoptiontospecifyfilesets,theCoptiontoignorecase,Ltolistlinesthat
match,andEtoshowEditorstylelinenumbers.Forexample,tosearchtheSRCgroupofthelogonaccountfor
"fopen",ignoringcase:
:magnet"f@.srcfopencle"
FormoredetailsonMagnet,see
http://www.allegro.com/products/hp3000/toolboxes.html
MPEXisathirdpartytoolfromVesoftthatextendstheMPEcommandshelltoworkonsetsofmanyfiles,rather
thanjustonefile.Itisveryflexibleandallowsselectionssuchas"filesbiggerthan1GBanduntouchedinovera
year".MPEXallowsyoutoselectfilesbasedonsearchingtextwithinthefiles:
%PRINTAP@.SOURCE;SEARCH="CUSTNUM";NUM
MPEXalsoallowssearchingforlinescontainingalternatestrings,ormorethanonestring,oralmostanysearch
logic:
%PRINT@.SOURCE;SEARCH="PROCEDURE"or"FUNCTION";NUM
%PRINT@.SOURCE;SEARCH="PROCEDURE"and"FNAME"
%PRINT@.JOB;SEARCH="!JOB"andNOT"MANAGER.SYS"
http://www.robelle.com/tips/mpeforunix.html
9/13
9/3/2015
MPEIntroductionandTipsforUnixUsers
Therearemanymoreoptions(caseless,lookfordelimiters,lookforadelimiterontheleftonly,etc.).
DatabaseFiles
Whatdoesitmeanwhenyougetthiserror:
:printstore01.db
^
PRIVILEGEDFILEVIOLATION(FSERR45)
ThePRINTcommandfailed.(CIERR9080)
Thismeansisthatyoutriedtoopenadatabasefileinusermode.Theseare"privilegedfiles"thatcanonlybe
openedinPrivMode.Thisrestrictionensurestheintegrityofthedatabasestructurebyforcingallaccessthrough
systemapprovedtoolsorAPIs.
QueryisadatabasetoolfoundoneveryHP.Itcandoselection,butonlyworksondatabases,notdiskfiles.A
simpleQuerytaskwouldbe:
:query
>FINDorderdetail.orderdateGT20040101
>REPORTALL
Queryhasnumerousreportformattingoptions,includingsorting,levelbreaks,itemformatting,etc.However,the
outputisintendedforaprinter,somostoftheformattingoptionshavethatinmind.Itispossibletoredirectthis
outputtoadiskfile,butQuerywaswrittenbeforeanyoneaskedforoutputtoanExcelspreadsheet.
Suprtoolisathirdpartyproduct(seewww.suprtool.com)thatisfoundonmanyHP3000systemsitworkson
bothdatabasesanddiskfiles.LikeFcopyitcancopyorprintrecordsusingChar,hexdump,butitcandomuch,
muchmore.Itcandosophisticatedselectionandsorttherecords.Forexample,toselectalltheOpenorders,sort
them,eliminateduplicates,writethemtoadiskfileforfurtherprocessing,andprintthefieldsofeachselected
entry,use:
:suprtool.pub.robelle
>baseorders.db
>getorderdetail
>iforderdate>"20040101"andorderstatus="O"
>sortordernum
>dupnone
>outputopensel
>list
>xeq
SuprtoolprovidesaDefineandItemcommandtodescribetherecordformatofafilesothatitcanbetreatedlike
adatabase.Ortomoreaccuratelydescribeadatabase(i.e.,definesubfields,datefields,anddecimalplaces).
Theoutputcangototheprinter,ortoadiscfile,ortothedatabase,ortoanExcelspreadsheet,ortoalmostany
otherformatoffile.
MPEforUNIXUsers,Part5
ShellScripts
ByRobertGreen,Robelle
BothMPEandUnixhavescripts,butthereareanumberofdifferences.FromapaperbyKenRobertsonwhenhe
wasatRobelle:
"BeforeMPE/iX,therewasaruntimeenvironmentfortheMPE/VclassofHPcomputerscalledthe
CommandInterpreter(CI).ThisMPE/VCIhadlimitedprogrammingcapability,withIf/Elseconstructs
andnumericvariableslimitedtovaluesbetween0and65535.ThebasicinterfaceoftheMPE/VCI
(CommandInterpreter)wasportedtoMPE/iXmachines,andbeefedupsoitwouldbeusableasarun
timeshell.
TheMPE/iXcommandinterpreterhasagenerouscommandset,pushingtheshellintotherealmofatrue
programmingtool.ItsabilitytoevaluateexpressionsandtoperformI/Oonfilesallowstheendusertoperform
simpledataprocessingfunctions.TheCIcanbeusedtosolvecomplexproblems.Itscode,however,is
interpreted,whichmaycauseaCIsolutiontoexecutetooslowlyforpracticalpurposes.
Commandfilesareacollectionofcommandsinflatfiles,ofeithervariableorfixedlengthrecordstructure,that
resideintheMPEorPOSIXfilespace.Basically,commandfilesarewhatyoucouldcallMPEMacros.Anythingthat
youcandointheCIinteractively,youcandowithcommandfiles,andthensome.Youcanusecommandfilesin
situationsthatcallforrepetitivefunctions,suchasrecompilingsourcecode,specialspoolercommands,etc.
Commandfilesarealsogreatwhenyouwanttohidedetailsfromtheenduser.
http://www.robelle.com/tips/mpeforunix.html
10/13
9/3/2015
MPEIntroductionandTipsforUnixUsers
AcommandfileisexecutedwhenitsnameisistypedintheCI,orinvokedfromacommandfileorprogramming
shell.Justasinprogramexecution,theuser'sHPPATHvariableissearchedtodeterminethelocationofthe
commandfile."
MPEScriptsVersusUnixScripts
Fortheaveragetask,theMPEscriptinglanguageiseasiertoreadandunderstandthanmostUnixscripts.For
example,commandlineparametersinMPEhavenames,justlikeinregularprogramminglanguages.
Ofcourse,thereareseveralscriptlanguagesonUnixandonlyoneonMPE!OnUnixyoucanwriteshellscriptsfor
anyofthemanyshellsprovided(Cshell,Bourneshell,ksh,bash,etc).AlthoughthereisalsonowaPosixshellon
MPE,mostscriptsarewrittenfortheCI.Severalthirdpartytools,suchasQeditandMPEX,emulateHPscripting
andintegrateitwiththeirowncommands.
Acommandfilecanbeassimpleasasinglecommand,suchasaShowjobcommandwiththeoptiontoonlyshow
interactivesessions(andignorebatchjobs):
:qedit
/add
1showjobjob=@s
2//
/keepss
/e
:
YouhavecreatedacommandfilecalledSSwhenyoutype
SS
youwillexecute
showjobjob=@s
OnMPE,theuserneedsread(r)orexecuteaccess(x)toSS.OnUnixyounormallymusthavexaccess,notjustr
access,soyoudoa
chmod+x
onthescript.ThisisnotnecessaryinMPE,although,ifdon'twantuserstobeseethescript,youmayremove
readaccessandenableexecuteaccess.
StructureofaCommandFile(akaCIscript)
AscriptisanASCIIfilewithmaximum511byterecords.UnlikeUnix,therecordsmaycontainanASCIIsequence
numberinthelast8columnsofeachline.Thecommandfileconsistsof3optionalparts:
1.Parameterlinewithamaximumof255arguments
parmsessionnumber
parmfilename,length="80"
2.Optionlines
optionnohelp,nobreak
optionlist
3.Thebody(i.e.,theactualcommands)
showjobjob=!sessionnumber
build!filename;rec=!length,,ascii
InMPEscripts,thereisnoinlinedata,unlikeUnix'hereis'files.
Parameters
Noticeintheexampleabovethatparametersareusedwithanexclamation(!),asopposedtothe$inUnix.The
sameistrueforvariables.Parametersareseparatedbyaspace,commaorsemicolon.Allparametervaluesare
untyped,regardlessofquoting.
InatypicalUnixscript,theparametersarereferencedbypositiononly($1,$2,$3,...).InanMPEscript,the
parametershavenames,asinthefunctionofaregularprogramminglanguage,andcanalsohavedefaultvalues.
InUnixyouuse$@foralloftheparametersasasinglestringinMPEyouuseanANYPARMparameterto
referencetheremainderofthecommandline(itmustbethelastparameter).
HereisascriptfromBeechglentotranslate"subsys"and"err"numbersfromMPEintrinsicsintoerrormessages.
http://www.robelle.com/tips/mpeforunix.html
11/13
9/3/2015
MPEIntroductionandTipsforUnixUsers
Thesubsysanderrornumbersarepassedinasparameters:
parmp_subsys=108,p_error=63
commentdecodessubsysandinfoerrorcodes.
commentByMikeHornsbyfromBeechglenDevelopment.
commentThankstoStanSielerfromAllegro.
comment
setvarsubsyshex(!p_subsys)
setvarerrorhex(!p_error)
commentthehexconversionallowsfornegativenumbers
commentthe#32765ismagicaccordingtoStan!
setvarcmd"wlerrmsg(#32765,!subsys);wlerrmsg(!error,!subsys);exit"
debug!cmd
Asyoucanseeabove,theSetvarcommandassignsavaluetoparameterortoanewvariable.Buttherearealso
systempredefinedvariables.Toseethemalldo
Showvar@;hp
.Togetinformationonvariables,do
helpvariable
andtogethelponaspecificvariable,suchas"hpcmdtrace",do
helphpcmdtrace
(setTRUEforsomedebugginghelp).
InmostMPEcommands,youmustuseanexplicitexclam!toidentifyavariable:
build!filename
However,someMPEcommandsexpectvariables,andthusdonotrequiretheexplicit!.Forexample,Setvar,If,
ElseIf,Calc,While,andforallfunctionarguments,andinside![expressions].
Warning:variablesare"sessionglobal"inMPE.Thismeansthatifachildprocess,orscripts,changesavariable,it
remainschangedwhenthatchildprocessterminates.InUnixyouareusedtotheideathatthechildcando
whateveritlikeswithitscopyofthevariablesandnotworryaboutanyexternalconsequences.
Ofcoursehavingglobalvariablesalsomeansthatitismucheasiertopassbackresultsfromascript!Andthisis
quitecommoninMPEscripts.
Options
Optionsallowyoutolistthecommandsastheyareexecute(optionlist),disabletheBreakkey(optionnobreak),
enablerecursion(optionrecursion),anddisablehelpaboutthescript(optionnohelp).
TheBodyoftheScript
Hereisascriptbodythatshowsactiveprocessinformation(fromBeechglen):
WHILEHPCONNSECS>0
IFFINFO("SQMSG",0)
PURGESQMSG,TEMP
ENDIF
BUILDSQMSG;REC=79,,F,ASCII;TEMP;MSG
FILESQMSG=SQMSG,OLDTEMP
SHOWQ;ACTIVE>*SQMSG
SETVARPINLIST""
WHILEFINFO("SQMSG",19)<>0
INPUTSQLINE<SQMSG
IFPOS("#",SQLINE)<>0THEN
SETVARPINRTRIM(STR(SQLINE,47,5))
SETVARPINLIST"!PINLIST"+","+"!PIN"
ENDIF
ENDWHILE
IFFINFO("SPMSG",0)
PURGESPMSG,TEMP
ENDIF
BUILDSPMSG;REC=79,,F,ASCII;TEMP;MSG
FILESPMSG=SPMSG,OLDTEMP
SETVARPROC"SHOWPROCPIN="+"!PINLIST"+";SYSTEM>*SPMSG"
!PROC
WHILEFINFO("SPMSG",19)<>0
INPUTSPLINE<SPMSG
IFPOS(":",SPLINE)<>0THEN
ECHO!SPLINE
ENDIF
ENDWHILE
PAUSE30
http://www.robelle.com/tips/mpeforunix.html
12/13
9/3/2015
MPEIntroductionandTipsforUnixUsers
ENDWHILE
Thisexampleshowsmanyofthecommandscommonlyusedinscripts:If,While,Pause,Setvar,InputandRun.
OthercommandsyouwillseeareEcho,Deletevar,Showvar,Errclear
HandlingErrors
InmostUnixscripts,ifastepfails,youcheckforanerrorwithanIfconditionalandthentakesomeaction,oneof
whichisendingthescript.WithoutanIf,thescriptcontinueson,ignoringtheerror.
InMPE,thedefaultactionwhenastepfailsistoabortthescriptandpassbackanerror.Tooverridethis
default,youinsertaContinuecommandbeforethestepthatmayfail.YouthenaddIflogicafterthesteptoprint
anerrormessageandperhapsReturn(back1level)orEscape(allthewaybacktotheCI).
continue
buildnewdata
ifcierror<>100then
print"unabletobuildnewdatafile"
print!hpcierrmsg
return
else
commentduplicatefile,okay
endif
YoucansetHPAUTOCONTtoTRUEtocontinueautomaticallyincaseoferrors,butthiscanbedangerous.The
defaultbehavioratleastletsyouknowifanunexpectedproblemoccurs.
UserDefinedCommands(UDC)
UDCsarelikeCommandFilescripts,exceptthatseveralarecombinedinasingle"catalog"file.Theyareanolder
featureofMPE,soyoumayseetheminolderapplicationsevenwhenscriptsseemlikeabettersolution.The
primaryreasonthattheyarestillusefulisthattheysupportOptionLogon,whichinvokesthecommandwhena
userlogsontothesystem.
MoreInformation
TimEricson'scollectionofUDC'sandCommandfileshasrecentlybeenresurrectedandrepublishedinthepublic
domainat:
http://www.3k.com/index_cmd.html
TheBeechglenwebsitehasanumberofusefulscripts,somementionedabove:
http://www.beechglen.com/mpe/downloads.html
http://www.robelle.com/tips/mpeforunix.html
13/13