285 pts.
 CL program to transfer a job to QINTER
hi guys, this is a long one. i use to telnet a client in a virtual dsiplay, using the command telnet rmtsys(clientsys) rmtvrtdsp(operacao). The problem is that if someone is using this display, and you try to access it, you will be kicked out without knowing why. So, i need some help to write a CL to automaticaly transfer the job to qinter when the virtual display is occupied. i hope the text is clear. Tanx in advance

Software/Hardware used:
iseries v5r4
ASKED: September 12, 2011  4:47 PM
UPDATED: March 31, 2012  4:47 PM
  Help
 Approved Answer - Chosen by Aringarosa (Question Asker)

Try this:

pgm

   dcl   &MsgId       *char     7
   dcl   &RmtSys      *char   256     value( 'CCCAMCV' )
   dcl   &RmtVrtDsp   *char    10     value( 'OPERACAO' )

   telnet      rmtsys( &RmtSys ) rmtvrtdsp( &RmtVrtDsp )

   dountil   ( &MsgId *eq ' ' )
      rcvmsg   pgmq( *EXT ) msgtype( *DIAG ) msgid( &MsgId )
      if ( &MsgId *eq 'CPF8902' )  do
         telnet rmtsys( &RmtSys )
         leave
      enddo
   enddo

   return

endpgm

Change the value for &RmtSys when you want a different system. Change the value of &RmtVrtDsp when you want a different device.

You should be able to compare messages in your joblog to the parms for RCVMSG to learn some of what's happening. Run TELNET from a command line a couple times and look at the message details for all messages it sends.

However, the code is not complete. It doesn't account for what may happen if you run it multiple times in the same job, especially if other TELNET commands have been run; and it doesn't do a good job of managing the messages in the *EXT message queue.

Part of the problem is that the information it uses comes from the job's *EXT message queue. Messages can get placed there by anything running in the job.

Another part is that you need to look at *DIAG (diagnostic) messages. Those are received in first-in/last-out sequence. The first *DIAG messages in the *EXT message queue may have been placed there hours (or days!) before, depending on how long the job has run.

Much more sophistication is possible, but everything has to start from somewhere.

Tom

ANSWERED:  Sep 13, 2011  8:13 PM (GMT)  by Aringarosa

 
Other Answers:

Why not try telnet rmtsys(clientsys) without the remote display it will use the *DFT parameter and if remote system is setup to use Virtual devices it will create a QPADEVXXXX device in the QINTER Subsystem

Last Wiki Answer Submitted:  September 13, 2011  1:57 pm  by  Rickmcd   1,480 pts.
Latest Answer Wiki Contributors:  Rickmcd   1,480 pts.
To see other answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _


 

hi rickmcv,

because we in the client we use a software where some devices are not created. that’s why we do telnet to a rmtvrtdsp. what i need is something like this:

telnet rmtsys(cccamcv) rmtvrtdsp(operacao)

if rmtvrtdsp(operacao) is on signon display status, then do

telnet rmtsys(cccamcv).

tanx

 285 pts.

 

In that case would need to create the CL to do first telnet command and monitor for msg
CPF8902 using right after command
MONMSG MSGID(CPF8902) EXEC(Telnet 2nd command))

 1,480 pts.

 

I’ve tried this MONMSG MSGID(CPF8902) EXEC(Telnet 2nd command)). but it still doesn’t work. i’ve even tried with rclcfgsts it doesn’t work anyway.

 285 pts.

 

The only thing to do is after running the CL make sure it was compiled with Log CL Commands and after running from Command line look at joblog to see what errors received.

 1,480 pts.

 

the error recieved is…cpf8902…this is killing me

 285 pts.

 

Off the top of my head cl should be
PGM
telnet
MONMSG MSGID(CPF2204) EXEC(TELNET RMTSYS(RMTSYS) +
RMTVRTDSP(VIRTDSP2))
endpgm
then if not working check log again.

 1,480 pts.

 

I’ve tried this MONMSG MSGID(CPF8902)…

Since CPF8902 is sent as a *DIAG message, you can’t use MONMSG. You can only monitor for *ESCAPE, *STATUS and *NOTIFY messages.

For anything else, you need to receive the messages from the appropriate queue. Use the RCVMSG command or the Receive Program Message (QMHRCVPM) API to receive those messages.

Tom

 108,055 pts.

 

Hi Tom, thank you for your help. Tell me something, isn’t the field dountil ( &MsgId *eq ‘ ‘ ) incomplete?

 285 pts.

 

isn’t the field dountil ( &MsgId *eq ‘ ‘ ) incomplete?

No, it’s just a little shortened. It tests for the condition where &MsgId equals a blank. The RCVMSG command will return a blank value in the MSGID() parameter when there are no more messages to receive and the WAIT() time is expired. The default WAIT() time is zero. You could put seven blans between the quotes since &MsgId is a 7-byte character variable, but the *EQ condition will happen if it’s one blank or seven blanks.

I just coded a DOUNTIL for the automatic looping structure. If it runs out of messages, it will drop out of the loop.

Tom

 108,055 pts.

 

Thanks very much Tom. I’ve learned a lot from you.
I still have one problem, when i end telnet, i get a full black screen and that job goes up to 60% cpu usage. It never ends telnet. Any clue why it happens.

Tanx

 285 pts.

 

I still have one problem, when i end telnet,…

Does the same problem show up if you start a new job before calling the program? There is no intelligence in the example code. If, for example, you run the program in a job that has tens of thousands of messages already in the *EXT message queue, it could take a significant amount of time for the program to look through them all.

Which “telnet” are you referring to? There are two “telnets” in the job — you start with the first telnet session, then you call a program that starts a second telnet session to another system. Which one are you ending? How are you ending it? Which system sees “60% cpu usage”?

Tom

 108,055 pts.

 

i’m sorry Tom. My mistake, problem solved.

 285 pts.