Posts Tagged ‘6th sem computer science’

System Software Lab Programs ( UNIX Programs ) – 2b

// March 6th, 2009 // Comments // Engineering, Unix and System Software Lab

Subject : System Software Laboratory

Branch : Information Science & Engineering

Semester : 6

University : VTU

………………………………………………………………………………………………………………………….
PART -B

………………………………………………………………………………………………………………………….

2. b) C program to create a file with 16 bytes of arbitrary data from the beginning and another 16 bytes of arbitrary data from an offset of 48. Display the file contents to demonstrate how the hole in file is handled.

……………………………………………………………………………………………………………………………

#include<stdio.h>

#include<unistd.h>

main()

{

FILE *fp;

int i,j;

char ch;

fp=fopen(“text.txt”,”w”);

ch=’a';

for(i=o;i<16;i++)

{

fwrite(&ch,1,1,fp);

ch++;

}

fseek(fp,48L,1);

ch=’A';

for(j=0;j<16;j++)

{

fwrite(&ch,1,1,fp);

ch++;

}

fclose(fp);

fp=fopen(“text.text”,’r”);

while((fread(&ch,1,1,fp))!=0)

print(“%c”,ch);

fclose(fp);

}

[Request : If you are going to post this program on any other website please link back to original post ]


System Software Lab Programs ( UNIX Programs ) – 2a

// March 5th, 2009 // Comments // Engineering, Unix and System Software Lab

Subject : System Software Laboratory

Branch : Information Science & Engineering

Semester : 6

University : VTU

………………………………………………………………………………………………………………………….
PART -B

………………………………………………………………………………………………………………………….

2a.  Shell script that accepts two file names as arguments, checksif the permissions for these files are identical and if the permissions are identical, outputs the common permissions,  otherwise outputs each file name followed by its permissions.

……………………………………………………………………………………………………………………………

#include<sys/types.h>

#include<sys/stat.h>

#include<unistd.h>

clear

if [ $# -ne 2]

then

echo -e “n Two arguments are not passed n”

else

{

ls -l $1>file1

ls -l $2>file2

cut -c 1-10 file1>file3

cut -c 1-10 file2>file4

cmp file3 file4>res

if test -s res

then

echo -e “n Files are having different permissionn”

cat file1

cat file2

else

{

echo -e “n Both files have same attributesn”

cat file1

cat file2

}

fi

}

fi

[Request : If you are going to post this program on any other website please link back to original post ]

System Software Lab Programs ( UNIX Programs ) – 1B

// March 4th, 2009 // Comments // Engineering, Unix and System Software Lab

Subject : System Software Laboratory

Branch : Information Science & Engineering

Semester : 6

University : VTU

………………………………………………………………………………………………………………………….
PART -B

………………………………………………………………………………………………………………………….

1. b) C program that creates a child process to read commands from the standard input and execute them (a minimal implementation of a shell – like program). You can assume that no arguments will be passed to the commands to be executed.

……………………………………………………………………………………………………………………………

#include,stdio.h>

#include<unistd.h>

#include<string.h>

main()

{

int pid,n,i;

char cmd[30];

printf(“n Enter the number of commands : “);

scanf(“%d”,&n);

pid=fork();

system(“clear”);

if(!pid)

{

for(i=0;i<n;i++)

{

printf(“n Enter the command : “);

scanf(“%s”,cmd);

system(cmd);

}

}

else

{

wait(100);

exit(1);

}

printf(“n Parent process is completed..nn”);

return 0;

}

[Request : If you are going to post this program on any other website please link back to original post ]

System Software Lab Programs ( UNIX Programs )

// March 3rd, 2009 // Comments // Engineering, Unix and System Software Lab

Subject : System Software Laboratory

Branch : Information Science & Engineering

Semester : 6

University : VTU

………………………………………………………………………………………………………………………….
PART -B

………………………………………………………………………………………………………………………….

1. a) Non-recursive shell script that accepts any number of arguments and prints them in the Reverse order, ( for example, if the script is named rags, then executing rags A B C should produce C B A on the standard output).

……………………………………………………………………………………………………………………………

if [ $# -eq 0]

then

echo -e “No arguments”

else

a=($*)

echo -3 “Arguments are”

echo $*

let x=$#

echo -2 “Arguments in reverse order ”

while [ $x -ne -1]

do

echo -e “${a[$x]}”

let x=x-1

done

fi

[Request : If you are going to post this program on any other website please link back to original post ]