|
This probably belongs on C400-L, but real quick... spawn() starts a batch job that you can communicate with via pipes or sockets. Since it's a batch job, it cannot run interactive commands like DSPUSRPRF. And since it requires all of the overhead of creating a new job, it's not an efficient way to run commands. spawn() would be appropriate for running a QShell command or script since in the unix-like environment, it's common to use descriptors for stdin,stdout,stderr to send/get results and errors from commands. This is NOT the way that stuff is done in normal OS/400 commands like DSPUSRPRF, however. spawnp() is like spawn(), except that your PATH envvar is observed. Though, again, that won't help you with things like DSPUSRPRF. It will help you with unix-like utilities such as grep and find. system() can be used to run native OS/400 commands in your current job. Assuming that your current job is an interactive one, you do things like DSPUSRPRF. Example: #include <stdio.h> #include <stdlib.h> #include <stddef.h> int main(int argc, char **argv) { if (system("DSPUSRPRF USRPRF(QSYSOPR)") != 0) { fprintf(stderr, "DSPUSRPRF command failed with %s\n", _EXCP_MSGID); exit(255); } return 0; } But, as I said, this is off-topic for MIDRANGE-L and David will probably complain that it should be on C400-L. On Mon, 24 May 2004, Walt Fles wrote: > All, > Im trying to use spawn to call a command without having to specify a > complete path, ie > without having to say "/qsys.lib/mylib.lib/mypgm.pgm" > Is there something I have to set up in my environment? > > also, how do I call from within C commands such as "dspusrprf", or do a: > "call pgm(mylib/mypgm)" from within C. I've already did a > putenv("PATH=%LIB%") > but that does not seem to help. > > I am using WDS5722 on V5R2.
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.