Re: Handling failed mount (media not connected)
--- Robert Huff [EMAIL PROTECTED] wrote: L Goodwin writes: My backup script (sh) works fine except when the backup drive (USB Flash drive) is not plugged in. I'm using mount_msdosfs to mount the backup drive. What is the best way to handle mount_msdosfs error? If the drive is not mounted, I want to detect the failure and execute error-handling code. First approximation, using sh: ls /dev | grep da4s1 if [ $? -eq 0 ]; then # drive is available else # drive is not available if (Replace da4s1 with whatever the flash drive gets created as.) Oh, yeah. Thanks, Robert! Now, sendmail has stopped working again (was working last night). Now, sendmail thinks on it for awhile, then returns 0, but mailq returns /var/spool/mqueue is emptyTotal requests: 0 I was testing outgoing email by disconnecting the network cable. Now, nothing (also tried with it connected). Robert Huff Pinpoint customers who are looking for what you sell. http://searchmarketing.yahoo.com/ ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: Handling failed mount (media not connected)
--- Garrett Cooper [EMAIL PROTECTED] wrote: Robert Huff wrote: L Goodwin writes: My backup script (sh) works fine except when the backup drive (USB Flash drive) is not plugged in. I'm using mount_msdosfs to mount the backup drive. What is the best way to handle mount_msdosfs error? If the drive is not mounted, I want to detect the failure and execute error-handling code. First approximation, using sh: ls /dev | grep da4s1 if [ $? -eq 0 ]; then # drive is available else # drive is not available if (Replace da4s1 with whatever the flash drive gets created as.) Robert Huff Possibly better (using sh again..): #!/bin/sh error_handling_func() { err_code=$1; shift; # do something here... exit $err_code; } # This assumes that you have: #1. cam/pass support built into the kernel. #2. your USB device is interpreted as a SCSI device (which should be the case). #3. your USB device is unique / identifiable by a string. camcontrol | grep 'Device string' || error_handling_func $? # do something here since it passed.. Also, FWIW conditionals are actually done like: if {statement} ; then elif {statement}; then else fi in Bourne shells. Also, mount_msdosfs should return a non-zero exit code. Thanks, Garrett. I was wondering about the [] vs. {} (every code example I've seen uses the square brackets). It's been 10 years since I did any serious shell scripting. I finally installed the MAN and INFO pages on the server I'm working on yesterday -- much faster than accessing them online! I'd like to see all MAN pages show return values and where any output goes, and more examples that cover each combination of the former in a real-world scenario. If *NIX/BSD is going to take on Windows, they need to be better in every significant way (which includes better documentation for those who are not already experts). Park yourself in front of a world of choices in alternative vehicles. Visit the Yahoo! Auto Green Center. http://autos.yahoo.com/green_center/ ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Handling failed mount (media not connected)
My backup script (sh) works fine except when the backup drive (USB Flash drive) is not plugged in. I'm using mount_msdosfs to mount the backup drive. What is the best way to handle mount_msdosfs error? If the drive is not mounted, I want to detect the failure and execute error-handling code. I tried executing it in a subshell, which works when it FAILS, but not when it WORKS. Also tried trap mount command 0, but it did not help. Moody friends. Drama queens. Your life? Nope! - their life, your story. Play Sims Stories at Yahoo! Games. http://sims.yahoo.com/ ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Handling failed mount (media not connected)
L Goodwin writes: My backup script (sh) works fine except when the backup drive (USB Flash drive) is not plugged in. I'm using mount_msdosfs to mount the backup drive. What is the best way to handle mount_msdosfs error? If the drive is not mounted, I want to detect the failure and execute error-handling code. First approximation, using sh: ls /dev | grep da4s1 if [ $? -eq 0 ]; then # drive is available else # drive is not available if (Replace da4s1 with whatever the flash drive gets created as.) Robert Huff ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: Handling failed mount (media not connected)
Robert Huff wrote: L Goodwin writes: My backup script (sh) works fine except when the backup drive (USB Flash drive) is not plugged in. I'm using mount_msdosfs to mount the backup drive. What is the best way to handle mount_msdosfs error? If the drive is not mounted, I want to detect the failure and execute error-handling code. First approximation, using sh: ls /dev | grep da4s1 if [ $? -eq 0 ]; then # drive is available else # drive is not available if (Replace da4s1 with whatever the flash drive gets created as.) Robert Huff Possibly better (using sh again..): #!/bin/sh error_handling_func() { err_code=$1; shift; # do something here... exit $err_code; } # This assumes that you have: #1. cam/pass support built into the kernel. #2. your USB device is interpreted as a SCSI device (which should be the case). #3. your USB device is unique / identifiable by a string. camcontrol | grep 'Device string' || error_handling_func $? # do something here since it passed.. Also, FWIW conditionals are actually done like: if {statement} ; then elif {statement}; then else fi in Bourne shells. Also, mount_msdosfs should return a non-zero exit code. Cheers, -Garrett ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]