Path: utzoo!utgpu!water!watmath!clyde!bellcore!rutgers!ucsd!ames!pacbell!att!whuts!homxb!homxc!mlm
From: mlm@homxc.UUCP (M.MILLIMAN)
Newsgroups: comp.sys.ibm.pc
Subject: Help sending text to com2:
Message-ID: <3012@homxc.UUCP>
Date: 10 Aug 88 03:07:22 GMT
Organization: AT&T Bell Laboratories, Holmdel
Lines: 43

I have been trying to write a simple C program to accept a telephone number
on the command line then send the appropriate modem commands with the tele-
phone number to com2 where my modem is connected.  The following program
goes off-hook then on-hook when the program terminates, but does not dial the
number.  It must be seeing the ATDT command but not the number.  I have tried
the more primitive open and write commands with no success.  This is the
first program I have written for my PC in a while, but it should not be
that hard.  I could spend the time pondering this question, but I am sure
someone else has already figured this out.

Thanks for the help,
Mark L. Milliman
mlm@homxc.att.com

/* dial.c - This simple program reads the telephone number from the command
	line and commands any Hayes compatible modem to dial the number then
	prompt the user to answer the phone.
	
	Version 1.0:  May 18, 1988  Mark Milliman
*/

#include 

main(argc, argv)
    int argc;
    char *argv[];
{
    char *com_port,*phno;
    FILE *modem;
    
    com_port = "com2";
    phno = argv[1];
    if ((modem = fopen(com_port,"w")) == NULL)  {
    	fprintf(stderr,"%s couldn't open file %s\n",argv[0],com_port);
    	exit(1);
}
    printf("Phone Number:  %s\n", phno);   /* debug */
    fprintf(modem,"ATDT %s\n", phno);
    printf("\nHit any key to exit\n");     /* debug */
    while(kbhit() == 0)  {}                /* debug */
    exit(0);
}