home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / sys / hp / 12649 < prev    next >
Encoding:
Text File  |  1992-11-08  |  2.3 KB  |  72 lines

  1. Newsgroups: comp.sys.hp
  2. Path: sparky!uunet!ukma!wupost!sdd.hp.com!scd.hp.com!hpscdm!cupnews0.cup.hp.com!pasq
  3. From: pasq@cup.hp.com (Mark Di Pasquale)
  4. Subject: Interface w/ lp from a C Program
  5. Sender: news@cupnews0.cup.hp.com
  6. Message-ID: <BxBMIJ.6DL@cup.hp.com>
  7. Date: Sat, 7 Nov 1992 00:54:19 GMT
  8. Organization: Hewlett-Packard
  9. X-Newsreader: TIN [version 1.1.4 PL6]
  10. Lines: 60
  11.  
  12. -----------------------------------------------------------
  13. Tried to post this, but the thread disappeared...
  14. Subject: Re: Printing from a process
  15. Newsgroups: comp.unix.programer,comp.unix.misc,comp.sys.hp
  16. References: <1992Oct16.191940.5762@CS.ORST.EDU>
  17. X-Newsreader: TIN [version 1.1.4 PL6]
  18. X-Newsreader: TIN [version 1.1.4 PL6]
  19. -----------------------------------------------------------
  20.  
  21. John Wesley Herberg (herberj@prism.CS.ORST.EDU) wrote:
  22. : Can someone tell me how to interface w/the lp daemon in HP-UX 8.xx from
  23. : a C program.  Forking lp isn't acceptable.  I've looked through the books,
  24. : manuals, & header files w/no luck.  I did read something about creating a pipe
  25. : & sending that pipe's name to the daemon, but it wasn't specific enough for me
  26. : to do the coding.  Any references, details, or examples would help a lot.
  27.  
  28. John,
  29.  
  30. This may not answer you question directly, but I hope it can help:
  31.  
  32. You can set up a buffer in your C program like this:
  33.  
  34.     #define SLEN    256
  35.  
  36.     char buffer[SLEN];
  37.  
  38. Then, load the buffer with a UN*X command to be executed, like this:
  39.  
  40.     sprintf(buffer, "lp -dlj %s", FILE_NAME);
  41.      
  42.     where FILE_NAME is a string that points to the file you wish
  43.     to print.
  44.  
  45. Then have your program execute this command by using a pipe, like this:
  46.  
  47.     FILE *pd;
  48.  
  49.       if ((pd = popen(buf, "r")) != NULL) {
  50.             while (fgets(buf, SLEN, pd) != ESTN);
  51.       else
  52.         printf("error: could not open pipe\n");
  53.     
  54.     pclose(pd);
  55.  
  56. --
  57. Regards,
  58. Mark DiPasquale, GSY Support Planning & Training
  59.  
  60. (All appropriate disclaimers apply)
  61.  
  62.  _______       ________________________________________________________________
  63.             /     
  64.            /                   Mark DiPasquale c/o Hewlett-Packard
  65.           ____       ___  /    19111 Pruneridge Avenue, MS 44M9
  66.          /     /    /    /     Cupertino, CA  95014
  67.       __/   __/    _____/      Email: pasq@cup.hp.com
  68.                   /            Phone: (1/408) 447-0911  FAX: (1/408) 447-0177
  69.  ___________   __/   __________________________________________________________
  70.  
  71.