#include <stdio.h>
#include <string.h>
#include <stdlib.h>

#define NSLOOKUP "/usr/bin/nslookup"

#define DEBUG

int nslookup(char*, char*);


main () {
int rc;


printf("Izvrsavam komandu ...\n");

rc=nslookup("mala.vet.bg.ac.yu", "vet.bg.ac.yu.");

printf("Izvrsio program ... RC=%d\n", rc);
}



int nslookup(char *server, char* domain) {
FILE *prog;
char line[100], ch;

sprintf(line, "%s - %s", NSLOOKUP, server);
if ((prog=popen(line, "w"))==NULL)
   return 1;

sprintf(line, "ls -d %s", domain);
printf("2>>>%s", line);
fprintf(prog, server);

/*
while ((ch=fgetc(prog))!=EOF) {
   if (ch!=0) 
      printf("%c", ch);
   }
*/

fprintf(prog, "exit\n");


#ifdef DEBUG
   printf("PCLOSE ...\n");
#endif 

pclose(prog);

return 0;
}



