use POSIX;

my $drive = '/dev/sdz';
open(B,">$drive");
$s= (stat("rand"))[7];
my $buf;
my $pos;
my $o;
	open(A,"rand");
	seek(A,0,0);
	sysread A, $buf, 128*1024*1024;
	close(A);
	binmode(B);

#while (!eof(B)) {
	while(1) {
		print B  $buf;
		if (! print B  $buf) {
			print "Error writing, out is now at " . tell(B) . "\n";
			exit 1;
		}

		$pos+=128*1024*1024;
		print 128*1024*1024 . " bytes written to $drive; now @ position $pos";
		print  "\n";
}

close(B);
