c program to implement the unix or linux command to
implement
ls -l >output.txt
Answer Posted / rahul magdum
#include sys/types.h
#include unistd.h
#include sys/stat.h
main()
{
Int pid=fork();
Int fd=creat("op.txt",S_IRWXU);
If(pid!=0 && pid!=-1)
{
close(1); // stdout
dup(fd); // replace file descriptor
execlp("ls","ls","-l",null);
close(fd);
}
}
Is This Answer Correct ? | 22 Yes | 7 No |
Post New Answer View All Answers
Explain the mount and unmount system calls?
Explain c program to implement the unix or linux command to implement ls -l >output.txt?
What is the first process created by the kernel in unix?
Tell me how to protect a process from others to kill?
Explain the difference between command and utility in unix?
Name the command which is used to execute system calls from exe?
What is the fork() system call?
Explain the mount system calls?
Explain the unmount system calls?
What are the possible return values of kill() system call?
What is the difference between command and utility in unix?
How to protect a process from others to kill?
The very first process created by the kernel in unix is?