#!/usr/bin/perl use strict; use warnings; print "Content-type:text/html\n\n"; print "USB test"; print ""; my $mounted = `df -h | grep /dev/sda1`; if ($mounted eq '') { print '

USB device not connected

'; print $mounted; } else { print '

Device is connected

'; } print ''; #### #!/usr/bin/perl print "Content-type:text/html\n\n"; print "Umount"; system("sudo", "umount", "/dev/sda1"); print ""; #### $ mount -a #### $ mount /dev/sda1 on /mnt/usbstick type vfat (rw,relatime,uid=1000,gid=1000,fmask=0137,dmask=0027,codepage=437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro) #### $ curl http://localhost/cgi-bin/admin/Q/panel/panelmin.pl USB test

Device is connected

##
## $ curl http://localhost/cgi-bin/admin/Q/panel/umount.pl Umount #### $ curl http://localhost/cgi-bin/admin/Q/panel/panelmin.pl USB test

USB device not connected

##
## $ df -h | grep /dev/sda1 /dev/sda1 15G 366M 15G 3% /mnt/usbstick #### $ sudo umount /dev/sda1 $ df -h | grep /dev/sda1 #### $ mount -a (as superuser) $ df -h | grep /dev/sda1 /dev/sda1 15G 366M 15G 3% /mnt/usbstick #### $ perl panelmin.pl Content-type:text/html USB test

Device is connected

##
## $ perl umount.pl Content-type:text/html Umount #### $ perl panelmin.pl Content-type:text/html USB test

USB device not connected

##
## $ df -h | grep /dev/sda1 #### use autodie qw(:all)