I want to create a program in C language that would allow me to run a command in the terminal.
I have made a program in shell script which would give me the ip of any website that is opened in my browser. This shell script is executed by entering this command in the terminal:
sudo tcpdump -n dst port 80 -i eth
My professor told me to create a program in C language which would open the terminal and enter this command and then my shell script would work.
Please tell me how to create such a program.
Best Answer
you could use the system() function available in stdlib.h to run commands.
You could read more about it over here http://linux.about.com/library/cmd/blcmdl3_system.htm