Showing posts with label Linux : System Programming using C. Show all posts
Showing posts with label Linux : System Programming using C. Show all posts

Sunday, 17 May 2015

Linux : executing multiple commands from command line

Command line argument is used to giving input to our prgrame at load time. Using this simple code we can execute multiple commands. Here i used exec family of functions to execute each commands. Whenever we  are using using exec family of functions try to execute the exec function in child process.

Note : How to rrun this code from terminal
           $ ./a.out "ls;pwd;cal"
           $  ./a.out "ls;pwd;cal;umask;ps -e"

Linux : Non local goto

In programming goto is used to skip some statements of the code/  to make a loop. If we are setting the label above and calling label  below, then it will act as a loop. But if setting  the label below and calling the label above , so we can skip some staments. This goto local tothe function only. 
   
   Using non-local goto we can jump between functions. Here setting the label is done by using one function setjmp(), calling the label using longjmp().


Friday, 15 May 2015

Linux : Search link between two files.

There are two types of links are present bet ween files. One is Hard link and another one is Soft link.

command to creat hard link file :
$ln  file_name1 file_name2

Note: the file_name1 should create using vi editor or using cat command  before making the link.

command to make soft link files/symbolic link files.
$ln -s file_name1 file_name2