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.
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
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%)
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 ')
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)
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