tag:blogger.com,1999:blog-34020393.post8046277406109684527..comments2024-03-27T10:59:38.307-07:00Comments on Jim's PeopleSoft Journal: Exec Processes while Controlling stdin and stdoutJim Marionhttp://www.blogger.com/profile/12995110203807924786noreply@blogger.comBlogger25125tag:blogger.com,1999:blog-34020393.post-75733248492609592102018-01-25T14:47:58.771-08:002018-01-25T14:47:58.771-08:00@Nirmal, if I remember correctly, #Exec_Synchronou...@Nirmal, if I remember correctly, #Exec_Synchronous will cause PeopleCode to pause and wait for execution to complete. When finished, Exec should return the shell scripts exit code. 0 is the standard exit code for success. Using the approach outlined in this blog post gives you significantly more control over the process.Jim Marionhttps://www.blogger.com/profile/12995110203807924786noreply@blogger.comtag:blogger.com,1999:blog-34020393.post-91113538302858371832018-01-25T11:31:43.946-08:002018-01-25T11:31:43.946-08:00I have a Java program which has the main method to...I have a Java program which has the main method to accept a parameter from the command line, and I need to execute this executable through PeopleCode in the field change event, I tried to execute the program through exec function but the exec command is not returning any results after the execution.<br />Exec("java -cp /apps/psofthr/pt8.54/sdevhr/appserv/classes/itextpdf-5.5.8.jar edu.pdf.PDFFlatten /apps/psofthr/test.pdf /apps/psofthr/test1.pdf", %Exec_Synchronous + %FilePath_Absolute)<br />Any suggestion?<br /><br />REgards,<br />Nirmal<br />Anonymoushttps://www.blogger.com/profile/04427364350193960464noreply@blogger.comtag:blogger.com,1999:blog-34020393.post-48364925193333951482018-01-25T11:24:26.205-08:002018-01-25T11:24:26.205-08:00I have a Java program which has the main method to...I have a Java program which has the main method to accept a parameter from the command line, and I need to execute this executable through PeopleCode in the field change event, I tried to execute the program through exec function but the exec command is not returning any results after the execution.<br /><br />Exec("java -cp /apps/psofthr/pt8.54/sdevhr/appserv/classes/itextpdf-5.5.8.jar edu.pdf.PDFFlatten /apps/psofthr/test.pdf /apps/psofthr/test1.pdf", %Exec_Synchronous + %FilePath_Absolute)<br /><br />Any suggestion??<br /><br />Regards,<br />NirmalAnonymoushttps://www.blogger.com/profile/04427364350193960464noreply@blogger.comtag:blogger.com,1999:blog-34020393.post-61273023088412868602016-04-08T16:41:48.287-07:002016-04-08T16:41:48.287-07:00@Rakesh, any error messages or anything? Are you r...@Rakesh, any error messages or anything? Are you reading stdout and stderr?Jim Marionhttps://www.blogger.com/profile/12995110203807924786noreply@blogger.comtag:blogger.com,1999:blog-34020393.post-52808687501454579322016-04-08T02:46:35.337-07:002016-04-08T02:46:35.337-07:00Hi Jim, i am trying to read the output of below un...Hi Jim, i am trying to read the output of below unix command but not able to do so with the example you gave. Am i missing something....<br /><br />Command<br />pr xyz.pdf | grep 'Count'Anonymoushttps://www.blogger.com/profile/07850784158958741735noreply@blogger.comtag:blogger.com,1999:blog-34020393.post-59498319302916752172016-03-30T08:13:08.855-07:002016-03-30T08:13:08.855-07:00@Aniket, those are the only things I can think of....@Aniket, those are the only things I can think of. It might be helpful to use the stdin/stdout redirection described in this blog post to exec your process. You can then use MessageBox to print stdout to the AE log file.Jim Marionhttps://www.blogger.com/profile/12995110203807924786noreply@blogger.comtag:blogger.com,1999:blog-34020393.post-12702322302345941082016-03-28T06:04:11.595-07:002016-03-28T06:04:11.595-07:00@Jim,I did use the UNC path style. However, there ...@Jim,I did use the UNC path style. However, there is no change in the behavior.<br /><br />Thanks & Regards,<br />Aniket SenAnonymoushttps://www.blogger.com/profile/01617319796115567488noreply@blogger.comtag:blogger.com,1999:blog-34020393.post-2165327843551045522016-03-24T09:55:47.215-07:002016-03-24T09:55:47.215-07:00@Aniket, I also mentioned path mappings and I didn...@Aniket, I also mentioned path mappings and I didn't see that in your response. I suggest using the \\servername\sharename\path style instead of the mapped drive letter.Jim Marionhttps://www.blogger.com/profile/12995110203807924786noreply@blogger.comtag:blogger.com,1999:blog-34020393.post-9894889015936459802016-03-23T05:19:58.271-07:002016-03-23T05:19:58.271-07:00Hi Jim,
Thank you for your prompt response. To an...Hi Jim,<br /><br />Thank you for your prompt response. To answer your questions, yes, I am running on Windows server and I have placed the .bat file in PS_Home where all the other .bat files are kept.<br />None the less, even if instead of pointing to the .bat file, I directly write the command as a parameter to the Exec function, even then it works when ran in 2 tier, directly through the App D.<br /><br />My question is that what do I have to do differently for it to work the same way in 3 tier when scheduled through system process requests.<br /><br />What baffles me is that I am looking in as the same super user both in app d and on PIA, also, the fact that when ran through PIA in the .stdout file, the Exec code returns an exit code as 0 and the AE goes to success, yet I do not see the cmd.exe getting invoked and the PTF client getting invoked, as is the case when ran directly through App D.<br /><br />How do I make it work from PIA.IS this even possible with 3 tier?<br /><br />Thanks & Regards,<br />Aniket SenAnonymoushttps://www.blogger.com/profile/01617319796115567488noreply@blogger.comtag:blogger.com,1999:blog-34020393.post-46862442434983997222016-03-22T12:00:43.687-07:002016-03-22T12:00:43.687-07:00@Aniket, I assume you are running on a Windows ser...@Aniket, I assume you are running on a Windows server AND that you copied the batch file to that location on the server AND that the server knows the "E:\" path? The reason I ask about the path is because Windows servers often run with a different registry hive and don't always know about mapped drives. Sometimes you have to use the "UNC" path.Jim Marionhttps://www.blogger.com/profile/12995110203807924786noreply@blogger.comtag:blogger.com,1999:blog-34020393.post-9290377134834770142016-03-22T05:34:00.333-07:002016-03-22T05:34:00.333-07:00i created an AE with only one step with peoplecode...i created an AE with only one step with peoplecode action. <br /><br />the code is as below: <br /><br /><br />&my_command = "E:\PT853\PS_APP_HOME\FSCM92\bat\AERUN.bat"; <br /><br /><br />&command_ftp = Exec(&my_command, %Exec_Synchronous + %FilePath_Absolute); <br /><br />If &command_ftp = 0 Then <br />/* Continue on with program */ <br />MessageBox(0, "", 30000, 0, "Execution of script SUCCESSFUL"); <br />Else <br />MessageBox(0, "", 30000, 0, "Execution of script Has Failed"); <br />Exit (1); <br />End-If; <br /><br />Now, when i run this in 2 tier that is through App D this works as expected. <br />The same AE when i run through PIA system process requests, it does not work. <br /><br />The command in the .bat is to invoke PTF. The command is as follows. <br /><br />cmd.exe /c %PSAE%\PSAE.exe -CT ORACLE -CD FIN92 -CO VP1 -CP VP1 -R 1 -AI PTF_AE_CI <br /><br />Can you please tell me what should i do to get it work in 3 tier? <br />Thank you!! <br /><br />Regards, <br />Aniket SenAnonymoushttps://www.blogger.com/profile/01617319796115567488noreply@blogger.comtag:blogger.com,1999:blog-34020393.post-45462446941641577342016-03-11T22:23:07.051-08:002016-03-11T22:23:07.051-08:00@Aswath, just because a server isn't exposed t...@Aswath, just because a server isn't exposed to the internet, doesn't mean it can't contact the internet. It just means other people can't contact it through the internet. It is quite common to have an app server sitting behind a firewall and requiring proxy server settings to connect to the internet. Beside the Integration Broker proxy server settings, make sure you have your app server proxy configuration settings (specifically the Java related ones) set in you app server configuration.Jim Marionhttps://www.blogger.com/profile/12995110203807924786noreply@blogger.comtag:blogger.com,1999:blog-34020393.post-91208437788239090402016-03-09T03:04:33.007-08:002016-03-09T03:04:33.007-08:00Hi Jim,
Your posts are excellent, i want to ask ...Hi Jim, <br /><br />Your posts are excellent, i want to ask your help to send Push notifications to mobile from peoplesoft.<br /><br />we have a mobile app (android and ios) written in native languages, now i have to send push notifications to mobile server from peoplesoft.<br />They expect me to send a push notification to GCM(google cloud server). i am struggling to do it.<br /><br /><b>what i tried :</b><br />i tried to execute a Java program from peoplecode which(java) will send message to GCM like below, but since App server cant send message to internet this fails<br /><br /><i><br /> &jobject = CreateJavaObject("GCMServer");<br /> rem &jobject.sendMessage("AIzaSyAO2TA3unQAwfjQoLBlILlokTEf1YU6B64", "message content here", "AAAAogECAwQAAQAAAAACvAAAAAAAAAAsAARTaGRyAgBObwgAOAAuADEAMBTOa8S7KrWvaHYvN+m8klkNRMlfNwAAAGIABVNkYXRhVnicHYlBDkBAEARrlzj6CbEbsa4IbiJZd0/wQY/TYyap7lQDj/NFiUPnX2PNwcnMxEVHqFgl9lous8ndLOSeaCMDjTKKgVE026qnn9aT3mzS/gF0GQuA");<br /> <br /> &jobject.sendMessage("AIzaSyAO2TA3unQAwfjQoLBlILlokTEf1YU6B64", "This is message for mob", "cpW8gpq6EN8:APA91bEnVcYg-Qpgk86QXJqh7PHcHDoxOg8Jjyi_EYm23zJ6nS5KXjc4-s4W25kx6ii2Pl4qAeAPyzVqGcDOzgHZ6-IxdZLAkgqjo4cdTi3VbquZAeSj7f_Qs99E0bx3ttugCVeVs_dC");<br /> &jobject = Null;<br /></i><br /><br />Note : the restriction here is they have a 3 tier architecture and only the webserver is exposed to internet.Aswathhttps://www.blogger.com/profile/09929776753401373405noreply@blogger.comtag:blogger.com,1999:blog-34020393.post-80376571412221280822016-01-04T09:55:04.279-08:002016-01-04T09:55:04.279-08:00@Amol, is your app server on Windows and does ever...@Amol, is your app server on Windows and does everything live in the same paths for your app server? When the app server service is running, does it know about the mapped drive? Does the app server service have a named user with drive mappings?Jim Marionhttps://www.blogger.com/profile/12995110203807924786noreply@blogger.comtag:blogger.com,1999:blog-34020393.post-50214544686580834462015-12-31T02:09:11.935-08:002015-12-31T02:09:11.935-08:00Hi Jim,
I have to run a bat file using exec functi...Hi Jim,<br />I have to run a bat file using exec function in App Engine PeopleCode.<br /><br />The bat file has a code of opening the App Designer, comparing the project between source and target environments and export the compare report to a location given in it.<br /><br />I am able to run the bat file using App Designer 2 tier mode, but When I run it through PIA, it does not do anything.<br /><br />Below is the PeopleCode in the AE:-<br /><br />&XmlFile = "C:\windows\system32\cmd.exe /c E:\users\AKR6\Compare\TEST1\Batch\migrate.bat " | DSX_XML_GEN_AET.PROJECTNAME.Value | " " | DSX_XML_GEN_AET.OPRID.Value | " " | DSX_XML_GEN_AET.PASSWORD.Value | " " | DSX_XML_GEN_AET.SOURCE_DESCR.Value | " " | DSX_XML_GEN_AET.SOURCE_OBJECT;<br /><br />&execute = Exec(&XmlFile, %Exec_Synchronous + %FilePath_Absolute);<br /><br />Could you please help in this?Amol Kotkarhttps://www.blogger.com/profile/03889058280736975700noreply@blogger.comtag:blogger.com,1999:blog-34020393.post-18048367342564305702013-06-13T15:11:36.143-07:002013-06-13T15:11:36.143-07:00@Alex, thanks for the update.@Alex, thanks for the update.Jim Marionhttps://www.blogger.com/profile/12995110203807924786noreply@blogger.comtag:blogger.com,1999:blog-34020393.post-77212688274492438392013-06-13T14:00:17.909-07:002013-06-13T14:00:17.909-07:00Hey Jim, forgot to let you know that it works. I b...Hey Jim, forgot to let you know that it works. I basically created a shell script that does the encryption,and I just pass it the value to encrypt.<br />Thanks.Alex Shilmanhttps://www.blogger.com/profile/13008712556039336606noreply@blogger.comtag:blogger.com,1999:blog-34020393.post-22620241742371264432013-05-23T12:40:12.293-07:002013-05-23T12:40:12.293-07:00@Alex, What I pasted, and what you tested was a se...@Alex, What I pasted, and what you tested was a series of commands, not a single command. The ability to use pipes is built into the shell, not exec. The Runtime.exec method interprets it as a single command. You have a couple of options. To get the username/password into gpg, write to the process.getOutputStreamWriter as shown in the second example. The next hurdle is to base64 encode the gpg binary output. There are options for gpg that produce base64, such as --armor. A simple alternative is to create a batch file/shell script that combines both commands using the pipe (|). If you can't or don't want to use a shell script, another alternative is to create a shell and exec commands within that shell. See <a href="http://blog.decaresystems.ie/2008/04/16/runtimeexec-and-the-pipe-operator/" rel="nofollow">this blog post</a> and <a href="http://www.velocityreviews.com/forums/t362758-facing-problem-while-using-pipe-in-runtime-exec.html" rel="nofollow">this forum post</a> for details on creating a shell using System.Runtime.Jim Marionhttps://www.blogger.com/profile/12995110203807924786noreply@blogger.comtag:blogger.com,1999:blog-34020393.post-34332044580778691732013-05-23T12:10:15.863-07:002013-05-23T12:10:15.863-07:00@Alex, that makes sense. Let me test something. I&...@Alex, that makes sense. Let me test something. I'll get back to you.Jim Marionhttps://www.blogger.com/profile/12995110203807924786noreply@blogger.comtag:blogger.com,1999:blog-34020393.post-6394641885641072392013-05-23T12:00:26.627-07:002013-05-23T12:00:26.627-07:00Jim, yes I've tried it on command line in Unix...Jim, yes I've tried it on command line in Unix. And it works. But when I do the same command in getRuntime().exec() it just outputs everything after echo as a string.<br />FYI Im doing this as a function. Where it accepts an input param, and should output encrypted value. <br />Any thoughts? Appreciate your help on this.Alex Shilmanhttps://www.blogger.com/profile/13008712556039336606noreply@blogger.comtag:blogger.com,1999:blog-34020393.post-1350354348139579572013-05-22T16:09:49.433-07:002013-05-22T16:09:49.433-07:00@Alex, I assume you tried a simple command and mad...@Alex, I assume you tried a simple command and made sure that worked for you (no pgp or gpg). Here is the command I used to encrypt a string:<br /><br />echo the_user_id | gpg --symmetric --passphrase-fd 8 | base64<br /><br />I didn't try it in App Engine online (Linux), but as you can see from the command, everything is reading from stdin and writing to stdout. You can tell this by my use of pipes.Jim Marionhttps://www.blogger.com/profile/12995110203807924786noreply@blogger.comtag:blogger.com,1999:blog-34020393.post-43118416484537460962013-05-21T14:05:17.479-07:002013-05-21T14:05:17.479-07:00Hey Jim, this command line doesn't seem to lik...Hey Jim, this command line doesn't seem to like PGP encryption. Your help will be greatly appreciated.<br />I just need to encrypt 2 values: lastname and emplid.<br />Thanks.Alex Shilmanhttps://www.blogger.com/profile/13008712556039336606noreply@blogger.comtag:blogger.com,1999:blog-34020393.post-30113182978292847782013-05-16T21:37:03.082-07:002013-05-16T21:37:03.082-07:00@Alex, I think you should be able to use the outpu...@Alex, I think you should be able to use the output buffer. An alternative would be to use a Java PGP encryption library.Jim Marionhttps://www.blogger.com/profile/12995110203807924786noreply@blogger.comtag:blogger.com,1999:blog-34020393.post-24057637521049266292013-05-16T08:40:07.567-07:002013-05-16T08:40:07.567-07:00Hi Jim, Im trying to use your code to PGP encrypt ...Hi Jim, Im trying to use your code to PGP encrypt two values for SSO.<br />Do I need to create a file, or the output buffer should handle that?<br />Thanks in advanceAlex Shilmanhttps://www.blogger.com/profile/13008712556039336606noreply@blogger.comtag:blogger.com,1999:blog-34020393.post-10467392570364294282010-02-24T10:35:02.356-08:002010-02-24T10:35:02.356-08:00Excellent! This may come in handy.Excellent! This may come in handy.Chili Joehttps://www.blogger.com/profile/06860069249183717066noreply@blogger.com