I was asked to put together a script that will write hex to a block device until it is full using a variable for the block size. I think that I have accomplished this with the script below, with help from the chatterbox (thanks everyone).
My problem now is, how can I terminate the script? I was hoping that when the block device was full, it would just error out, and then I could work it from there, but it doesn't. When this is run against /dev/hdaX it works, but does not terminate. Is there a way in which I can write to the device until it is full and then end the script?#!/usr/bin/perl die "Usage: hexperlscript <blocksize> <destination file>\n" unless @AR +GV == 2; ($input, $output) = @ARGV; if ($input % 512 == 0) { $input = $input * .5; open ( DEST, '>>', $output ) or die "Cannot create ouput file. $! \n"; while (1 < 2) { for(0..0xff){$n=sprintf"%02x",$_;print DEST "$n" x $input;} print DEST "$n" x $input; } } else { print "Blocksize must be divisable by 512.\nExiting.\n"; END; }
A little background: I have some forensics guys that I work with that want to use this in order to test where data is written between two or more drives on a SCSI device. This is really the first script that I have ever put together that does something useful so (as always) all comments are welcome.
Thank you,
ghettofinger
In reply to Block device status and script termination by ghettofinger
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |