Skip to content
Advertisement

output mountpoint on (usb)device detection

I want to create a bash script that will output the mount point from an inserted USB device. I have two commands (between “do” “and” done”) that work separately but not together in a bash script. The script looks for a UUID file use the $UUID filename in the lsblk command to extract the mountpoint The mount point must be in a variable so that I can continue to use this in the same bash script. I’ve had this so far:

JavaScript

The echo new device works and can see the $UUID but the lsblk command does nothing. When put the command lsblk --noheadings --output MOUNTPOINT /dev/disk/by-uuid/**realuuid** in the terminal it works. does anyone know what’s wrong?

Advertisement

Answer

The problem was a timing issue and can be solved by adding (for me) minimum sleep time of 0.2 sec between detecting and executing the command

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement