OpenVMS Source Code Demos
popen_demo.c
// =====================================================
// title : popen_demo.c
// author : Neil Rieck
// edit : 2023-08-10
// platform: DEC-C on OpenVMS-8.4
// notes : since OpenVMS then the script must be DCL
// =====================================================
#include <stdio.h>
#include <stdlib.h>
int main(void) {
char buf[1023];
long lc = 0;
FILE *pp;
pp = popen("dir *.c/col=1/width=file=50/date/size", "r");
if (pp != NULL) {
while (1) {
char *line;
buf[0] = '\0';
line = fgets(buf, sizeof buf, pp);
if (line == NULL) break;
lc += 1;
printf("lc: %ld data: %s", lc, buf);
}
pclose(pp);
}
return 0;
}