Midrange News for the IBM i Community


Posted by: gio cot
Analist
Problem with rmtcmd
has no ratings.
Published: 18 May 2012
Revised: 23 Jan 2013 - 4111 days ago
Last viewed on: 26 Apr 2024 (9121 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  ??


PGM                                                                                       
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')                     
STRPCO                                                                                   
   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)                            
ENDPGM                                                                                   

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

COMMENTS

(Sign in to Post a Comment)
Posted by: bobcozzi
Site Admin ****
Chicagoland
Comment on: Problem with rmtcmd
Posted: 11 years 11 months 8 days 21 hours 39 minutes ago
Edited: Fri, 18 May, 2012 at 08:09:08 (4361 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.

RMTCMD "CRTDTAARA DTAARA(COZTOOLS/TEST1) TYPE(*CHAR) LEN(12) VALUE(%USERNAME%)
Posted by: giocot
Premium member *
Comment on: Problem with rmtcmd
Posted: 11 years 11 months 7 days 21 hours 24 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 ****
Chicagoland
Comment on: Problem with rmtcmd
Posted: 11 years 11 months 7 days 15 hours 33 minutes ago
Edited: Sat, 19 May, 2012 at 14:13:31 (4360 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                                           
       "CRTDTAARA QGPL/COZZI *CHAR LEN(10) VALUE(%USERNAME%)')  PAUSE(*NO)

 

Posted by: giocot
Premium member *
Comment on: Problem with rmtcmd
Posted: 11 years 11 months 7 days 13 hours 46 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