Detect floppy diskette

Charles Howse chowse at charter.net
Tue Aug 26 13:00:34 PDT 2003


> 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.

Looks good, now...I have to insert this perl code into a bash script as
a function.
This generates a syntax error:
#!/usr/local/bin/bash

Chkflp(){
/usr/bin/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;
}
<remainder of bash script>




More information about the freebsd-questions mailing list