Skip to content

Instantly share code, notes, and snippets.

@geekman
Created December 23, 2015 15:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save geekman/016890c6c046908eb4bd to your computer and use it in GitHub Desktop.
Save geekman/016890c6c046908eb4bd to your computer and use it in GitHub Desktop.
ejects the DVD-ROM drive (using Python)
#!/usr/bin/env python
#
# ejects the cdrom drive
#
# kernel references:
# - Documentation/ioctl/cdrom.txt
# - include/uapi/linux/cdrom.h
#
from fcntl import ioctl
import sys, os
CDROMEJECT = 0x5309
fd = os.open(sys.argv[1], os.O_RDONLY | os.O_NONBLOCK)
ioctl(fd, CDROMEJECT, 0);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment