Midrange News for the IBM i Community

Posted by: gio cot
Problem with rmtcmd
has no ratings.
Published: 18 May 2012
Revised: 23 Jan 2013 - 4138 days ago
Last viewed on: 22 May 2024 (9160 views) 

Using IBM i? Need to create Excel, CSV, HTML, JSON, PDF, SPOOL reports? Learn more about the fastest and least expensive tool for the job: SQL iQuery.

Problem with rmtcmd Published by: gio cot on 18 May 2012 view comments(4)

Hi all

i find this example to retrive windows user name but i have two problems:

1- The rmtcmd ask user and password iSeries
2- Came displayed the dos window

is it possible to avoid these problems  ??

DCL &JOB *CHAR 10                                                                         
DCL &PCCMD *CHAR 100                                                                      
DCL &PCUSER *CHAR 10                                                                      
DCL &CURLIB *CHAR 10                                                                      
/* Get current job name and current library */                                            
/* then delete any existing temporary data area with the same name */                     
RTVJOBA JOB(&JOB) CURLIB(&CURLIB)                                                         
DLTDTAARA  DTAARA(&CURLIB/&JOB)                                                           
   MONMSG CPF0000                                                                         
/* Build Windows command to execute. Using START causes %USERNAME% to be resolved.      */
/* /B prevents extra windows from opening.                                              */
CHGVAR VAR(&PCCMD) VALUE('START /B RMTCMD CRTDTAARA +                                    
                          DTAARA(' || &CURLIB |< '/' || &JOB |< ') +                     
                          TYPE(*CHAR) LEN(10) VALUE(%USERNAME%) /Z')                     
   MONMSG IWS4010                                                                        
STRPCCMD  PCCMD(&PCCMD) PAUSE(*NO)                /* Send command to attached PC */      
RTVDTAARA  DTAARA(&CURLIB/&JOB) RTNVAR(&PCUSER)   /* Retrieve the data area */           
DLTDTAARA  DTAARA(&CURLIB/&JOB)                   /* Clean up */                         
SNDPGMMSG  MSG('PC user name is: ' || &PCUSER) MSGTYPE(*COMP)                            

Return to midrangenews.com home page.
Sort Ascend | Descend


(Sign in to Post a Comment)
Posted by: bobcozzi
Site Admin ****
Comment on: Problem with rmtcmd
Posted: 12 years 4 days 16 hours 10 minutes ago
Edited: Fri, 18 May, 2012 at 08:09:08 (4388 days ago)

You need to prefix the CRTDTAARA command with a quote because you have embedded blanks in the string itself. You don't need the trailing/closing quote, however, just the opening quote.

Posted by: giocot
Premium member *
Comment on: Problem with rmtcmd
Posted: 12 years 3 days 15 hours 55 minutes ago

Hi Bob thanks for you reply, but my problems was:

1- avoid asking iSeries user and password

2- avoid open dos window (less important)


i tryed with example below but don't work; i'm not able to understand in whic mode i have to pass the

system-user-password parameters .

If you can help in this i would be gratefull


  STRPCCMD PCCMD('start  RMTCMD "crtdtaara mylib/mydtaara *char 10 
/system:myiSeries   /user:myUser /password:mypass ')                   

Posted by: bobcozzi
Site Admin ****
Comment on: Problem with rmtcmd
Posted: 12 years 3 days 10 hours 4 minutes ago
Edited: Sat, 19 May, 2012 at 14:13:31 (4387 days ago)

Well, you're only allowed 123 total characters in your command string and what you specified in this example is beyond that limit. So you can't do what you want with STRPCCMD.

But I had no problem running this:

STRPCCMD PCCMD('start  RMTCMD                                           


Posted by: giocot
Premium member *
Comment on: Problem with rmtcmd
Posted: 12 years 3 days 8 hours 17 minutes ago

Hi Bob thanks again for you reply, but be patient: my question was : how can avoid asking iSeries user and password ? regarding the limit of 123 cahracters if think is not the problem as when you run the strpccmd and you exced this limit you receive the error from iSeries, and when i run " STRPCCMD PCCMD('start  RMTCMD "crtdtaara mylib/mydtaara *char 10 /system:myiSeries   /user:myUser /password:mypass ')" i don't received this error. Anyway if i can't do it with STRPCCMD which other way i can use ?

Thanks in advance