ITEM: DS0624L

AIX PPP client dial out interactively instead of with pppdial


 ENV: AIX 4.1.5, Model 7249

 PROBLEM: Would like to know how to make a PPP connection 
          where login was performed manually instead of 
          using pppdial to dial out with a chat script.

*ACTION TAKEN:
        After MUCH experimentation, was able to successfully get PPP
        dial-out to work with a modification to motalk instead of
        pppdial.  This is the syntax I've come up with:

/usr/sbin/pppattachd nodaemon client tty0 connect \\
  "mydialer /dev/tty0 38400 \< `tty` > `tty`"

Where tty0 is my modem, 38400 is my baud rate, and the quotes around
`tty` are back-quotes.

Note that the nodaemon is needed to prevent pppattachd from 
disassociating itself from the controlling terminal.

mydialer is the modified version of motalk below - the only modification
here is that motalk has been changed to exit with I hit ~ instead of
when I hit \^C - since hitting \^C generates a signal that would also
kill pppattachd (unless you nohup /usr/sbin/pppattachd ...)

/*
  MOTALK:  MODEM CONNECTION PROGRAM FOR AIX v3.2 AND 4.1
   SPECIAL NOTICES
        INFORMATION IN THIS DOCUMENT IS CORRECT TO THE BEST OF
       OUR KNOWLEDGE AT THE TIME OF THIS WRITING.  PLEASE SEND
       FEEDBACK BY FAX TO "AIXServ Information" at (512) 823-5972.
        PLEASE USE THIS INFORMATION WITH CARE.  IBM WILL NOT BE
       RESPONSIBLE FOR DAMAGES OF ANY KIND RESULTING FROM ITS USE.
       THE USE OF THIS INFORMATION IS THE SOLE RESPONSIBILITY OF THE
       CUSTOMER AND DEPENDS ON THE CUSTOMER'S ABILITY TO EVALUATE
       AND INTEGRATE THIS INFORMATION INTO THEIR OPERATIONAL
       ENVIRONMENT.
   ABOUT THIS DOCUMENT
        This document is a FAX sheet which contains a C language
       source code listing.  This C program has been tested on AIX
       versions 3.2 and 4.1.
   DESCRIPTION
        The motalk program allows the user to easily connect to a
       modem port for programming and does not require any
       customization to the "/usr/lib/uucp/ Devices" file as with
       the cu utility.
        This C program is a modification of the original motalk
       program available for AIX version 3.2.
   PREREQUISITES
        The modem should be powered "on" and physically attached to
       the tty port using appropriate cabling.
                                                                FAX Page 1 of 4
*/

/**************************************************************************/
/*  motalk_41_32.c     Modem setup program                                */
/*                                                                        */
/*     Compile:  cc -o motalk motalk_41_32.c                              */
/*       Usage:  motalk /dev/tty? [speed]                                 */
/**************************************************************************/
\#include \
\#include \
\#include \
\#include \
\#include \
 FILE   *fdr, *fdw;
int    fd;
struct termio term_save, stdin_save;
 void Exit(int sig)
{        if (fdr) fclose(fdr);
        if (fdw) fclose(fdw);
        ioctl(fd, TCSETA, &term_save);
        close(fd);
        ioctl(fileno(stdin), TCSETA, &stdin_save);
        exit(sig);
}main(int argc, char *argv[])
{        char   *b, buffer[80];
        int    baud = 0, num;
        struct termio term, tstdin;
           if (argc \< 2 || !strcmp(argv[1], "-?")) {
                  fprintf(stderr, "USAGE:  motalk /dev/tty? [speed]\\n");
                  exit(1);
          }
           if ((fd = open(argv[1], O_RDWR|O_NDELAY)) \< 0 ) {
                  perror(argv[1]);
                  exit(errno);
          }
           if (argc > 2) {
                switch(atoi(argv[2])) {
                        case 300:
                                baud = B300;
                                break;
                        case 1200:
                                baud = B1200;
                                break;
                        case 2400:
                                baud = B2400;
                                break;
                        case 4800:
                                baud = B4800;
                                break;
                        case 9600:
                                baud = B9600;
                                break;
                        case 19200:
                                baud = B19200;
                                break;
                        case 38400:
                                baud = B38400;
                                break;
                        default:
                                baud = 0;
                                fprintf(stderr,
                                        "%s: %s is an unsupported baud\\n",
                                        argv[0], argv[2]);
                                exit(1);
                }
        }
/*      SAVE STDIN AND TTY STATE. ALSO TRAP SIGNALS   */
        ioctl(fd, TCGETA, &term_save);
        ioctl(fileno(stdin), TCGETA, &stdin_save);
        signal(SIGHUP,  Exit);
        signal(SIGINT,  Exit);
        signal(SIGQUIT, Exit);
        signal(SIGTERM, Exit);
 /*      SET STDOM TP RAW MODE, NO ECHO    */
        ioctl(fileno(stdin), TCGETA, &tstdin);
        tstdin.c_iflag = 0;
        tstdin.c_lflag &=  ~(ICANON | ECHO);
        tstdin.c_cc[VMIN] = 0;
        tstdin.c_cc[VTIME] = 0;
        ioctl(fileno(stdin), TCSETA, &tstdin);
 /*      SET TTY STATE   */
        ioctl(fd, TCGETA, &term);
        term.c_cflag |= CLOCAL|HUPCL;
        term.c_iflag &= ~ICRNL;   /*  TO AVOID UN-NEEDED BLANK LINES  */
          if (baud > 0) {
                  term.c_cflag &= ~CBAUD;
                  term.c_cflag |= baud;
          }
        term.c_lflag &= ~(ICANON | ECHO);   /*  TO FORCE RAW MODE     */
        term.c_cc[VMIN] = 0;
        term.c_cc[VTIME] = 10;
        ioctl(fd, TCSETA, &term);
        fcntl(fd, F_SETFL, fcntl(fd, F_GETFL, 0) & ~O_NDELAY);
 /*      OPEN TTY FOR READ AND WRITE  */
          if ((fdr = fopen(argv[1], "r")) == NULL ) {
                  perror(argv[1]);
                  exit(errno);
          }
          if ((fdw = fopen(argv[1], "w")) == NULL ) {
                  perror(argv[1]);
                  exit(errno);
          }
 /*      ALL I/O IS UNBUFFERED */
        setbuf(stdin, 0);
        setbuf(stdout, 0);
        setbuf(fdr, 0);
        setbuf(fdw, 0);
 /*      TALK TO THE MODEM  */
        puts("Ready... \^C to exit");
        while (1) {
                if ((num = read(fileno(stdin), buffer, 80)) > 0)
                        write(fileno(fdw), buffer, num);

                /* MODIFICATIONS TO MOTALK TO EXIT WHEN ~ HIT HERE */
                        Exit(0);

                if ((num = read(fileno(fdr), buffer, 80)) > 0)
                        write(fileno(stdout), buffer, num);
        }
        Exit(0);
}       /*       E N D    O F    P R O G R A M        */

/*
                                                               FAX Page 3 of 4
  READER'S COMMENTS
   Please fax this form to (512) 823-5972, attention "AIXServ Information".
   Use this form to tell us what you think about this document.  If you have
  found errors in it, or if you want to express your opinion about it (such
  as organization, subject matter, appearance) or make suggestions for
  improvement, this is the form to use.
   If you need technical assistance, contact your local branch office, point
  of sale, or 1-800-CALL-AIX (for information about support offerings).
  These services may be billable.  Faxes on a variety of subjects may be
  ordered free of charge from 1-800-IBM-4FAX (415-855-4329 outside U.S.,
  from fax machine phone).
   When you send comments to IBM, you grant IBM a nonexclusive right to use
  or distribute your comments in any way it believes appropriate without
  incurring any obligation to you.
   Be sure to print your name and fax number below if you would like a reply.
   NOTE: If you have a Problem Report or Item Number, supplying that number
        may help us determine why a procedure did or did not work in your
        specific situation.
 +----------------------------------------------------------------------------+
|                                                                            |
|   Problem Report or Item \#:               Branch Office or Customer \#:     |
|                                                                            |
|          ___________________________      ______________________________   |
|                                                                            |
|                                                                            |
|                                                                            |
|   Name:  ___________________________      Fax Number: __________________   |
|                                                                            |
|   Comments: ____________________________________________________________   |
|                                                                            |
|   ______________________________________________________________________   |
|                                                                            |
|   ______________________________________________________________________   |
|                                                                            |
|   ______________________________________________________________________   |
|                                                                            |
|   ______________________________________________________________________   |
|                                                                            |
|   ______________________________________________________________________   |
|                                                                            |
|   ______________________________________________________________________   |
|                                                                            |
|   ______________________________________________________________________   |
|                                                                            |
|   ______________________________________________________________________   |
|                                                                            |
|   ______________________________________________________________________   |
|                                                                            |
|   ______________________________________________________________________   |
|                                                                            |
|   ______________________________________________________________________   |
|                                                                            |
|   ______________________________________________________________________   |
|                                                                            |
+----------------------------------------------------------------------------+
   END OF DOCUMENT (motalk_41_32.c)                             FAX Page 4 of 4
*/


Support Line: AIX PPP client dial out interactively instead of with pppdial ITEM: DS0624L
Dated: September 1997 Category: N/A
This HTML file was generated 99/06/24~13:30:15
Comments or suggestions? Contact us