Highlighted
Trusted Contributor.. Trusted Contributor..
Trusted Contributor..
365 views

system() calls work in VUGen (9.52) but not from within Controller

I have a script that makes 3 calls to the O/S using the system() function. The calls and the design around the calls work flawlessly from within VUGen. However, when run from the Controller, the transaction failure rate jumps from 0% to 50% plus. I am getting complete transaction failures with no errors, so I am unable to look at snapshots.

I have tried putting error trapping around everything I can think of, but I cannot capture the error. It looks like the system() calls are being essentially ignored.

I have used this type of design on a regular basis since LR 6.0. Though not ideal, it has ALWAYS worked. I even tested with VUGen on the Controller machine, then using the same machine as a Controller and a Generator. No errors in VUGen. 50% errors in Controller.

Why is it not working now?
Randy at Deere
0 Likes
2 Replies
Highlighted
Absent Member.. Absent Member..
Absent Member..

Re: system() calls work in VUGen (9.52) but not from within Controller

Can you attach a snippet of code with a system() call that is failing?
0 Likes
Highlighted
Trusted Contributor.. Trusted Contributor..
Trusted Contributor..

Re: system() calls work in VUGen (9.52) but not from within Controller

As long as you don't laugh at my kludge...

One of the actions with the system() calls is below.
=============================================

long pTemplate, pFile;
int iCounter=0,irc;
char logfile[1024],command[1024],sourcefile[1024],erasefile[1024],subtrans[1024];
char * templatefile = "whatever";
char * stuff = "notimportant";
char * pIDpointer = "what";
char * pPINpointer = "1234567890123";
char * CorrId = "junk";
char * PIN = "1234567890123";

for(iCounter=0;iCounter<9;iCounter++)
{
lr_vuser_status_message("UserID: %s - Iteration: %02s",
lr_eval_string("{VUser}"),
lr_eval_string("{vu_iter}"));

lr_start_transaction("02_Queue_RMS_Message_RetrieveDTC");

/*Queue Message (RMS)*/
sprintf(sourcefile, "C:\\SARRMS\\Temp\\ret%s%s.bin",lr_eval_string("{VUser}"),lr_eval_string("{FileStamp}"));

lr_output_message("The file being copied is %s",sourcefile);

sprintf(command, "C:\\SARRMS\\Scripts\\RetrieveDTC\\CopyFile\\copyfile.bat %s %s",lr_eval_string("{RetrieveTemp}"),sourcefile);

irc = system(command);

if (irc != 0) {
lr_output_message("copy script return code %d",irc);

lr_error_message( "File copy returned error #d at iteration #%s", irc,lr_eval_string( "{vu_iter}" ) );

// lr_end_transaction("02_Queue_RMS_Message_RetrieveDTC",LR_FAIL);

}

lr_output_message("Return code %d",irc);

PIN = lr_eval_string("{PIN}");

if ((pFile = fopen(sourcefile, "rb+" )) == NULL) {
lr_output_message ("Unable to open %s", sourcefile);

return -1;
}

fseek(pFile,36,0);
pPINpointer = PIN;

while ((*pPINpointer != NULL) && fputc(*(pPINpointer++), pFile) != -1); // Use -1 for EOF

fclose(pFile);

CorrId = lr_eval_string("{CorrId}");

if ((pFile = fopen(sourcefile, "rb+" )) == NULL) {
lr_output_message ("Unable to open %s", sourcefile);

return -1;
}
fseek(pFile,66,0);
pIDpointer = CorrId;

while ((*pIDpointer != NULL) && fputc(*(pIDpointer++), pFile) != -1); // Use -1 for EOF

fclose(pFile);

lr_output_message("The file being queued is %s",sourcefile);

sprintf(command, "C:\\SARRMS\\Scripts\\RetrieveDTC\\qput %s",sourcefile);

irc = system(command);

if (irc != 0) {
lr_output_message("qput return code %d",irc);
lr_error_message( "qput returned error #d at iteration #%s", irc,lr_eval_string( "{vu_iter}" ) );

// lr_end_transaction("02_Queue_RMS_Message_RetrieveDTC",LR_FAIL);

}

sprintf(erasefile, "erase /f /q %s",sourcefile);

irc = system(erasefile);

if (irc != 0) {
lr_output_message("erase script return code %d",irc);
lr_error_message( "Erase script returned error #d at iteration #%s", irc,lr_eval_string( "{vu_iter}" ) );

// lr_end_transaction("02_Queue_RMS_Message_RetrieveDTC",LR_FAIL);

}

lr_end_transaction("02_Queue_RMS_Message_RetrieveDTC",LR_AUTO);
UC03_Get_Request_Status();
}
Randy at Deere
0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.