Detect floppy diskette

Joshua Oreman oremanj at get-linux.org
Tue Aug 26 09:04:37 PDT 2003


On Tue, Aug 26, 2003 at 08:17:35AM -0500 or thereabouts, Charles Howse wrote:
> Hi,
> Using bash, how can I silently check to see whether there is a floppy
> diskette in the drive?
> 
> When I do:
> # mount /dev/fd0 /mnt > dev/null 2>&1
> I still get an error msg on screen.

Probably the message is generated by the kernel and cannot be ignored.

Try this:
% perl
use POSIX qw/:fcntl_h dup2 setsid/;
if (fork) { exit; }
setsid;

my $fd = POSIX::open "/dev/null", O_WRONLY or die "Can't open /dev/null: $!\n";
dup2 $fd, 0;
dup2 $fd, 1;
dup2 $fd, 2;

sleep 5;

system "sudo mount /dev/fd0 /mnt";

%    # wait for an error within 5 seconds or so

If no error appears, I think you forgot the / on /dev/null up there :-) Make
sure to unmount the floppy afterwards.
If there is an error, it proves that it was/is a kernel message.

-- Josh

> 
> 
> 
> Thanks,
> Charles
> 
> 
> _______________________________________________
> freebsd-questions at freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-questions
> To unsubscribe, send any mail to "freebsd-questions-unsubscribe at freebsd.org"


More information about the freebsd-questions mailing list