Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
i have created three child process from one parent. And different child has different functions. Child 2 has got function to load file called "wc" to count file1 and and its required to get their files by command line arguments.
I can get the files through command line but couldn't get the files when child 2 process start.
Read man page for execvp (or what do you use to launch wc?). You can pass an array of null-terminated strings to it to make it child process arguments. You need to declare the array of pointers, allocate the strings and fill them in the general case.
// Code got from google to get file from command line
int main ( int argc, char *argv )
if ( argc != 2 ) /* argc should be 2 for correct execution */
/* We print argv assuming it is the program name */
printf( "usage: %s filename", argv );
// We assume argv is a filename to open
FILE *file = fopen( argv, "r" );
/* fopen returns 0, the NULL pointer, on failure */
if ( file == 0 )
printf( "Could not open file\n" );
/* read one character at a time from file, stopping at EOF, which
indicates the end of the file. Note that the idiom of "assign
to a variable, check the value" used below works because
the assignment statement evaluates to the value assigned. */
while ( ( x = fgetc( file ) ) != EOF )
printf( "%c", x );
fclose( file );
I need to read the file from commandline when child 2 process..