unixln.c - #include<stdio.h>#include<stdlib.h>#include<unistd.h>#include<errno.h>#include<sys/types.h>#include<sys/wait.h>/sys function void sys(const

unixln.c -...

This preview shows page 1 - 3 out of 3 pages.

#include<stdio.h> #include<stdlib.h> #include<unistd.h> #include<errno.h> #include<sys/types.h> #include<sys/wait.h> //sys function void sys(const char *cmdstr) { int pid; pid=fork(); if(pid==0) execl("/bin/bash","bash","-c",cmdstr,NULL); else waitpid(pid,NULL,0); } //main function int main(int argc, char *argv[]) { int num1,num,i,res; char file1[1000],file2[1000],ln[100]; printf("1.Link \n2.ls\n3.copy\n4.move"); scanf("%d",&num1); switch(num1) { case 1:{ printf("Enter file1 name \n"); scanf("%s",file1); printf("Enter file2 name \n"); scanf("%s",file2); printf("1.Hardlink \n 2.Softlink\n"); scanf("%d",&num); switch(num) { case 1: //if(link(argv[1],argv[2])==-1) if(link(file1,file2)==-1) { printf("Link Error\n"); return 1; } break; case 2: if(symlink(file1,file2)==-1) { printf("Link Error\n"); return 1; } break; } printf("Files Linked\n"); printf("Inode number of linked files\n"); //display the inode linked files char str[100]; sprintf(str,"ls -i %s %s\n",file1,file2); system(str); break; } case 2:{ printf("Enter the ls command ");
Image of page 1

Subscribe to view the full document.

Image of page 2
Image of page 3
  • Summer '18
  • Anonymus
  • scanf, int argc, int pid

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern

Ask Expert Tutors You can ask 0 bonus questions You can ask 0 questions (0 expire soon) You can ask 0 questions (will expire )
Answers in as fast as 15 minutes