after my first week of reading and doing some tutorials i decided to try my own program. i run a liux machine with enlightenment desktop. so i decided to try a menu c program to make some things easy for me. i know bash shell scripting and wrote a nice script, but want to import it to the C lanquage.
i am trying to call the whois command with the domain name from the user input for the domain name or ip address. the problem is after calling the whois -h whois.arin.net command i need the doman or ip to follow to be able to look it up. please help with suggestions. if i can learn this, that will help me out a lot with other programs i want to take from the bash script to the C language. this is just one of many that will be linked to one large c program.
here is the code.
do i use the gets or scanf or would it be better to use a pointer. ?????????
#include <stdio.h>
#include <stdlib.h>
#define exit 4
int menu(void); /* main menu */
int arin(void); /* 1. arin.net */
int apnic(void); /* 2. apnic.net */
int ripe(void); /* 3. ripe.net */
char input[100];
int main()
{
int choice = 0;
while (choice != exit)
{
choice = menu();
if (choice == 1)
arin();
else
if (choice == 2)
apnic();
else
if (choice == 3)
ripe();
}
printf("\n\nThank you for using linshell\n\n");
return 0;
}
/* arin.net */
int arin(void)
{
printf("Domain or IP: ");
gets(input);
system("whois -h whois.arine.net %d",input);
}
/* apnic.net */
int apnic(void)
{
printf("Domain or IP: ");
}
/* ripe.net */
int ripe(void)
{
printf("Domain or IP: ");
}
/* display the main menu */
int menu(void)
{
int option = 0;
do
{
printf("\n\n");
printf("\t1. arin\n");
printf("\t2. apnic\n");
printf("\t3. ripe\n");
printf("\t4. exit");
printf("\n\n");
printf(" Select: ");
scanf("%d", &option);
}
while (option < 1 || option > 4);
return option;
}
after reading many websites and doing the tutorials i will be getting a book.
thanks,
enlinux