OSD ALL PROGRAM
EXP1
Title:-Inode information
import os
import sys
import types
import stat
import subprocess
name = raw_input("Enter file name")
fd = os.open(name,os.O_RDWR|os.O_CREAT)
sta = os.fstat(fd)
print "Inode number is %d" %sta.st_ino
print "Dev id is %d" %sta.st_dev
print "Size is %d" %sta.st_size
print "Bolcksize is %d" %sta.st_blksize
print "link is %d" %sta.st_nlink
subprocess.call(["ls","-l",name])
os.close(fd)
EXP2
Title:-PIPE and socket
import os,sys
fdr,fdw=os.pipe()
pid=os.fork()
if pid:
os.close(fdw)
a=os.fdopen(fdr)
str=a.read()
str=str[::-1]
print str
sys.exit(0)
else:
os.close(fdr)
str1=raw_input("enter the data")
ls=os.fdopen(fdw,'w')
ls.write(str1)
sys.exit(0)
EXP3
Title:-client server communication
import os,socket
s=socket.socket()
host="localhost"
port=12345
s.bind((host,port))
f=open('rec.txt','wb')
s.listen(10)
while True:
c,addr=s.accept()
print"The connected client is=",addr
l=c.recv(1024)
while(l):
f.write(l)
l=c.recv(1024)
f.close()
c.close()
C:\Users\aa\Pictures\server 1.png
------------------------client-------------------------------------
import os,socket
s=socket.socket()
host="localhost"
port=12345
s.connect((host,port))
print"The connection is established with server"
f=open('send.txt','rb')
l=f.read(1024)
while(l):
s.send(l)
l=f.read(1024)
f.close()
s.shutdown(socket.SHUT_WR)
C:\Users\aa\Pictures\client 1.png
EXP4
import os
if os.path.exists('/sys/firmware/efc'):
print"booted with UEFI"
else:
print "booted with legacy BIOS"
EXP5
ramdisk
include<iostream>
#include<stdlib.h>
using namespace std;
int main(){
cout<<"Creating Ramdisk...\n\n";
system("mkdir /mnt/ramdisk");
system("mount -t tmpfs -o size=256M tmpfs /mnt/ramdisk");
cout<<"Ramdisk created at /tmp/ramdisk/ "<<endl<<endl;
cout<<"Total size available on ramdrive:\n";
system("df -h /mnt/ramdisk");
cout<<"\n\n";
cout<<"Amount of Ramdrive used:\n";
system("du -h /mnt/ramdisk/");
system("cp input.txt /mnt/ramdisk");
system("cp calc.cpp /mnt/ramdisk");
return 0;
}
Title:-Inode information
import os
import sys
import types
import stat
import subprocess
name = raw_input("Enter file name")
fd = os.open(name,os.O_RDWR|os.O_CREAT)
sta = os.fstat(fd)
print "Inode number is %d" %sta.st_ino
print "Dev id is %d" %sta.st_dev
print "Size is %d" %sta.st_size
print "Bolcksize is %d" %sta.st_blksize
print "link is %d" %sta.st_nlink
subprocess.call(["ls","-l",name])
os.close(fd)
EXP2
Title:-PIPE and socket
import os,sys
fdr,fdw=os.pipe()
pid=os.fork()
if pid:
os.close(fdw)
a=os.fdopen(fdr)
str=a.read()
str=str[::-1]
print str
sys.exit(0)
else:
os.close(fdr)
str1=raw_input("enter the data")
ls=os.fdopen(fdw,'w')
ls.write(str1)
sys.exit(0)
EXP3
Title:-client server communication
import os,socket
s=socket.socket()
host="localhost"
port=12345
s.bind((host,port))
f=open('rec.txt','wb')
s.listen(10)
while True:
c,addr=s.accept()
print"The connected client is=",addr
l=c.recv(1024)
while(l):
f.write(l)
l=c.recv(1024)
f.close()
c.close()
C:\Users\aa\Pictures\server 1.png
------------------------client-------------------------------------
import os,socket
s=socket.socket()
host="localhost"
port=12345
s.connect((host,port))
print"The connection is established with server"
f=open('send.txt','rb')
l=f.read(1024)
while(l):
s.send(l)
l=f.read(1024)
f.close()
s.shutdown(socket.SHUT_WR)
C:\Users\aa\Pictures\client 1.png
EXP4
import os
if os.path.exists('/sys/firmware/efc'):
print"booted with UEFI"
else:
print "booted with legacy BIOS"
EXP5
ramdisk
include<iostream>
#include<stdlib.h>
using namespace std;
int main(){
cout<<"Creating Ramdisk...\n\n";
system("mkdir /mnt/ramdisk");
system("mount -t tmpfs -o size=256M tmpfs /mnt/ramdisk");
cout<<"Ramdisk created at /tmp/ramdisk/ "<<endl<<endl;
cout<<"Total size available on ramdrive:\n";
system("df -h /mnt/ramdisk");
cout<<"\n\n";
cout<<"Amount of Ramdrive used:\n";
system("du -h /mnt/ramdisk/");
system("cp input.txt /mnt/ramdisk");
system("cp calc.cpp /mnt/ramdisk");
return 0;
}
Comments
Post a Comment