Showing posts with label ubuntu. Show all posts
Showing posts with label ubuntu. Show all posts

Tuesday, January 24, 2012

How to run a unix command from a C program

The C function used to run the command is
system();

for eg:
system("ls");
execute ls command whereas

system("pwd");
execute pwd command.

A sample C program

#include<stdio.h>
#include<stdlib.h>
main()
    {
    char c[10]="pwd";
    system(c);
    }

It produces the output as


'pwd' is a unix command for showing the present working directory.

How to install mysql in ubuntu

open a terminal window and type the following command

sudo apt-get install mysql-server

It will install mysql with no password

How to install java in ubuntu

open a terminal window and type the following command,

sudo apt-get install openjdk-6-jdk

then it will prompt for the password. You have to give the password and press enter. Then it will be done within a few minutes.