Call Unix Script from PeopleCode

 

A function to call UNIX and/or shell script from PeopleCode.

/*call unix script from PeopleCode*/
Function CallScript;

   /*According to PeopleBooks, PS_HOME is always prefixed to the file location*/
   &exitCode = Exec("/path/to/script/scriptname ", True);

End-Function;

The Exec command has changed in PT8.4x so the above function will be:

Function CallScript;
 
   /*Use %Exec_Asynchronous if it is not important to wait for a response from the called script*/
   &exitCode = Exec(&PS_HOME | "path/to/script/scriptname", %Exec_Synchronous + %FilePath_Absolute);
   
   If &exitCode <> 0 Then
      MessageBox(0, "", 0, 0, ("Script was not Successful!  Exit code returned by script was " | &exitCode));
   End-If;
   
End-Function;

If you are using the Exec call inside of an Application Engine and you are calling it in a Synchronous mode, make sure you commit your work before you call it, otherwise, you will get a run time error.

CommitWork();
CallScript();

转载于:https://www.cnblogs.com/GoDevil/archive/2008/08/07/1262746.html

你可能感兴趣的:(Call Unix Script from PeopleCode)