[EMAIL PROTECTED] writes: > Hi, > in order to justify learning another language I'd first need to be convinced > that python could easily do the following:- > > ReadSectors2Bufr(hdx, StartSectr, SectrCnt, Bufr); <-- like linux: dd > PrintDecOf4Bytes(Offset, Bufr); <-- and also 1 and 2 byte values > OverWriteBufr(Offset, Bufr, Byte); > WriteBufr2Sectors ..... <-- like linux: dd > > I guess one would normally use bash, but I'd rather invest effort > in python if it can do this. > > Thanks for any info.
In unix, disks are files like any other file. So if your programming language allows you to read and write files, it allows you to read and write disks. Just write the equivalent of: int fd=open("/dev/hda",O_RDWR,0); if(0<==fd){ check_errors(lseek(fd,SECT_SIZE*sect_num,SEEK_SET)); check_errors(read(fd,buffer,SECT_SIZE)); modify(buffer); check_errors(lseek(fd,SECT_SIZE*sect_num,SEEK_SET)); check_errors(write(fd,buffer,SECT_SIZE)); close(fd); } and be sure to have the access rights on /dev/hda (and to know what you're doing!). -- __Pascal Bourguignon__ http://www.informatimago.com/ Nobody can fix the economy. Nobody can be trusted with their finger on the button. Nobody's perfect. VOTE FOR NOBODY. -- http://mail.python.org/mailman/listinfo/python-list