Bring Back My Qshell Output
July 18, 2007 Hey, Ted
I just ran a CL program that has an embedded QShell script. It produced some output to my display and gave me a message that told me to press Enter. I did, and the Qshell output display went away. Now I want to bring that display back and look at the output again. Can I do that? –Len Yes, and it’s easy. So the readers can see what you’re talking about, let’s look at an example. Here’s a CL program that includes a QShell script. pgm dcl &Script *char 1024 dcl &QshStatus *dec 10 value(0) dcl &MsgDta *char 256 dcl &MsgID *char 7 /* force QShell to send escape msg QSH0005 if it fails */ addenvvar envvar(QIBM_QSH_CMD_ESCAPE_MSG) + value('Y') replace(*yes) chgvar &Script + (+ 'for CurFile in *; + do + [[ $CurFile == ''*'' ]] && break ; + [[ -d $CurFile ]] && continue ; + echo Processing $CurFile; + echo Doing one thing to $CurFile; + echo Doing another thing to $CurFile; + echo Doing yet another thing to $CurFile; + echo I''m finished with $CurFile; + done; + exit 0') qsh cmd(&Script) monmsg qsh0005 exec(do) rcvmsg msgtype(*LAST) rmv(*NO) msgdta(&MsgDta) + msgid(&MsgID) if (&MsgID = 'QSH0005') chgvar &QshStatus %bin(&MsgDta 1 4) enddo If I run this script, QShell processes every file in my current directory. In this case, I’ve loaded the loop with echo commands. In a real job, all but the first and last echo commands would be replaced by commands that did some real work, of course. My QShell terminal session looks something like this: Processing temp2r3569101.wri Doing one thing to temp2r3569101.wri Doing another thing to temp2r3569101.wri Doing yet another thing to temp2r3569101.wri I'm finished with temp2r3569101.wri Processing temp2save.txt Doing one thing to temp2save.txt Doing another thing to temp2save.txt Doing yet another thing to temp2save.txt I'm finished with temp2save.txt Press ENTER to end terminal session. To bring the terminal session back, run the following command from a CL command line: qsh cmd('echo x') Voilà! –Ted
|