From owner-freebsd-questions@FreeBSD.ORG Tue Aug 26 13:00:34 2003 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id D060816A4BF for ; Tue, 26 Aug 2003 13:00:34 -0700 (PDT) Received: from remt19.cluster1.charter.net (remt19.cluster1.charter.net [209.225.8.29]) by mx1.FreeBSD.org (Postfix) with ESMTP id 14F8243FBD for ; Tue, 26 Aug 2003 13:00:32 -0700 (PDT) (envelope-from chowse@charter.net) Received: from [66.168.145.25] (HELO moe) by remt19.cluster1.charter.net (CommuniGate Pro SMTP 4.0.6) with ESMTP id 135856744 for questions@freebsd.org; Tue, 26 Aug 2003 16:00:30 -0400 From: "Charles Howse" To: Date: Tue, 26 Aug 2003 15:00:23 -0500 Message-ID: <002a01c36c0c$af801500$04fea8c0@moe> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook, Build 10.0.2616 In-Reply-To: <20030826160456.GD11087@webserver> X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 Importance: Normal Subject: RE: Detect floppy diskette X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Aug 2003 20:00:34 -0000 > Try this: > % perl > use POSIX qw/:fcntl_h dup2 setsid/; > if (fork) { exit; } > setsid; >=20 > my $fd =3D POSIX::open "/dev/null", O_WRONLY or die "Can't open=20 > /dev/null: $!\n"; > dup2 $fd, 0; > dup2 $fd, 1; > dup2 $fd, 2; >=20 > sleep 5; >=20 > system "sudo mount /dev/fd0 /mnt"; >=20 > % # wait for an error within 5 seconds or so >=20 > If no error appears, I think you forgot the / on /dev/null up=20 > 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; =20 my $fd =3D POSIX::open "/dev/null", O_WRONLY or die "Can't open=20 /dev/null: $!\n"; dup2 $fd, 0; dup2 $fd, 1; dup2 $fd, 2; =20 sleep 5; }