How do I write a C program to emulate the Unix LS-L command?

Asked by Last Modified  

Follow 1
Answer

Please enter your answer

#include <stdio.h> #include <unistd.h> #include <sys/types.h> #include <sys/wait.h> #include <stdlib.h> int main() { int pid; //process id pid = fork(); //create another process if ( pid < 0 ) { //fail printf(“\nFork...
read more
#include <stdio.h> #include <unistd.h> #include <sys/types.h> #include <sys/wait.h> #include <stdlib.h> int main() { int pid; //process id pid = fork(); //create another process if ( pid < 0 ) { //fail printf(“\nFork failed\n”); exit (-1); } else if ( pid == 0 ) { //child execlp ( “/bin/ls”, “ls”, “-l”, NULL ); //execute ls } else { //parent wait (NULL); //wait for child printf(“\nchild complete\n”); exit (0); } } read less
Comments

#include <stdio.h> #include <unistd.h> #include <sys/types.h> #include <sys/wait.h> #include <stdlib.h> int main() { int pid; //process id pid = fork(); //create another process if ( pid < 0 ) { //fail printf(“\nFork...
read more
#include <stdio.h> #include <unistd.h> #include <sys/types.h> #include <sys/wait.h> #include <stdlib.h> int main() { int pid; //process id pid = fork(); //create another process if ( pid < 0 ) { //fail printf(“\nFork failed\n”); exit (-1); } else if ( pid == 0 ) { //child execlp ( “/bin/ls”, “ls”, “-l”, NULL ); //execute ls } else { //parent wait (NULL); //wait for child printf(“\nchild complete\n”); exit (0); } } read less
Comments

Related Questions

What is openstack ?
OpenStack is open source platform for building and managing cloud computing platforms for public and private clouds in a cloud computing environment.
Vivek
I am working as Tech support executive with windows and Linux total of 4 years of experience , Not getting enough calls / opportunities ... Which domain is good for change Sap basis consultant / any other suggestions are welcome
Learn Cloud Computing(Microsoft Azure,AWS,Google Cloud) or Devops. Make your career in this field. Your previous experience will use in this field.
Vamshi

Now ask question in any of the 1000+ Categories, and get Answers from Tutors and Trainers on UrbanPro.com

Ask a Question

Related Lessons

Be prepared to get trained--init
Before starting the training,students must be mentally prepared for acceptance of new knowledge. Students must attend training with open minded forgetting the position they are working.This will help...
S

Smartnub Softsolutions

0 0
0

LINUX - SETTING UP YUM REPOSITORY
If we buy RHEL 7 the system by default will be connected to Red Hat Network (RHN). All packages and updates will be installed from RHN. So RHN will be our main source and repository. Since we have...
A

Aseem A.

1 0
0

How to detect duplicate address manually in a network from Linux ?
Below script will help you to detect duplicate IP address in a subnet The key command is the arping command which will send out an ARP packet with DAD (duplicate address detection) If the return...

Introduction to Programming Languages
What is a Programming Language? A programming language is a formal computer language or constructed language designed to communicate instructions to a machine, particularly a computer. Programming languages...

UNDERSTANDING PROCESSES - RED HAT ENTERPRISE LINUX
What is a Process An instance of a program is called a Process. Any command that you give to your Linux machine starts a new process. It is possible that for the same program we have multiple processes. Types...
A

Aseem A.

1 0
0

Recommended Articles

Applications engineering is a hot trend in the current IT market.  An applications engineer is responsible for designing and application of technology products relating to various aspects of computing. To accomplish this, he/she has to work collaboratively with the company’s manufacturing, marketing, sales, and customer...

Read full article >

Business Process outsourcing (BPO) services can be considered as a kind of outsourcing which involves subletting of specific functions associated with any business to a third party service provider. BPO is usually administered as a cost-saving procedure for functions which an organization needs but does not rely upon to...

Read full article >

Information technology consultancy or Information technology consulting is a specialized field in which one can set their focus on providing advisory services to business firms on finding ways to use innovations in information technology to further their business and meet the objectives of the business. Not only does...

Read full article >

Microsoft Excel is an electronic spreadsheet tool which is commonly used for financial and statistical data processing. It has been developed by Microsoft and forms a major component of the widely used Microsoft Office. From individual users to the top IT companies, Excel is used worldwide. Excel is one of the most important...

Read full article >

Looking for Linux Training?

Learn from the Best Tutors on UrbanPro

Are you a Tutor or Training Institute?

Join UrbanPro Today to find students near you