Differences
This shows you the differences between two versions of the page.
Next revision Both sides next revision | |||
trayopen [2013/07/13 15:55] beandog created |
trayopen [2013/07/13 15:57] beandog |
||
---|---|---|---|
Line 35: | Line 35: | ||
exit(status); | exit(status); | ||
} | } | ||
+ | </code> | ||
+ | |||
+ | Just download the code, and compile it with gcc: | ||
+ | |||
+ | <code> | ||
+ | gcc trayopen.c -o trayopen | ||
+ | </code> | ||
+ | |||
+ | Then, running it, it will return a 0 if it's open, or a 1 if it's closed. | ||
+ | |||
+ | Here's a sample bash script to call it: | ||
+ | |||
+ | <code> | ||
+ | #!/bin/bash | ||
+ | trayopen /dev/dvd | ||
+ | if [[ $! -eq 0 ]]; then | ||
+ | echo "Open for business!" | ||
+ | elif [[ $! -eq 1 ]]; then | ||
+ | echo "Sorry, already occupied." | ||
+ | fi | ||
</code> | </code> |