home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sys.hp
- Path: sparky!uunet!ukma!wupost!sdd.hp.com!scd.hp.com!hpscdm!cupnews0.cup.hp.com!pasq
- From: pasq@cup.hp.com (Mark Di Pasquale)
- Subject: Interface w/ lp from a C Program
- Sender: news@cupnews0.cup.hp.com
- Message-ID: <BxBMIJ.6DL@cup.hp.com>
- Date: Sat, 7 Nov 1992 00:54:19 GMT
- Organization: Hewlett-Packard
- X-Newsreader: TIN [version 1.1.4 PL6]
- Lines: 60
-
- -----------------------------------------------------------
- Tried to post this, but the thread disappeared...
- Subject: Re: Printing from a process
- Newsgroups: comp.unix.programer,comp.unix.misc,comp.sys.hp
- References: <1992Oct16.191940.5762@CS.ORST.EDU>
- X-Newsreader: TIN [version 1.1.4 PL6]
- X-Newsreader: TIN [version 1.1.4 PL6]
- -----------------------------------------------------------
-
- John Wesley Herberg (herberj@prism.CS.ORST.EDU) wrote:
- :
- : Can someone tell me how to interface w/the lp daemon in HP-UX 8.xx from
- : a C program. Forking lp isn't acceptable. I've looked through the books,
- : manuals, & header files w/no luck. I did read something about creating a pipe
- : & sending that pipe's name to the daemon, but it wasn't specific enough for me
- : to do the coding. Any references, details, or examples would help a lot.
-
- John,
-
- This may not answer you question directly, but I hope it can help:
-
- You can set up a buffer in your C program like this:
-
- #define SLEN 256
-
- char buffer[SLEN];
-
- Then, load the buffer with a UN*X command to be executed, like this:
-
- sprintf(buffer, "lp -dlj %s", FILE_NAME);
-
- where FILE_NAME is a string that points to the file you wish
- to print.
-
- Then have your program execute this command by using a pipe, like this:
-
- FILE *pd;
-
- if ((pd = popen(buf, "r")) != NULL) {
- while (fgets(buf, SLEN, pd) != ESTN);
- else
- printf("error: could not open pipe\n");
-
- pclose(pd);
-
- --
- Regards,
- Mark DiPasquale, GSY Support Planning & Training
-
- (All appropriate disclaimers apply)
-
- _______ ________________________________________________________________
- /
- / Mark DiPasquale c/o Hewlett-Packard
- ____ ___ / 19111 Pruneridge Avenue, MS 44M9
- / / / / Cupertino, CA 95014
- __/ __/ _____/ Email: pasq@cup.hp.com
- / Phone: (1/408) 447-0911 FAX: (1/408) 447-0177
- ___________ __/ __________________________________________________________
-
-