Created
May 18, 2013 19:40
-
-
Save fabioadrianosoares/5605551 to your computer and use it in GitHub Desktop.
Copiar CD para ISO
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* eject.c | |
** Copyright Paul Dwerryhouse, 1997-2004 | |
*/ | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <errno.h> | |
#include <string.h> | |
#include <unistd.h> | |
#include <fcntl.h> | |
#include <limits.h> | |
#include <sys/ioctl.h> | |
#include <linux/cdrom.h> | |
#define CDDEVICE "/dev/cdrom" /* CDROM device */ | |
int main(int argc,char **argv) | |
{ | |
int cdrom; /* CDROM device file descriptor */ | |
/* Open the CDROM device. The linux/cdrom.h header file specifies that | |
** it must be given the O_NONBLOCK flag when opening. My tests showed | |
** that if this isn't done, this program will not work. | |
*/ | |
if ((cdrom = open(CDDEVICE,O_RDONLY | O_NONBLOCK)) < 0) { | |
perror("open"); | |
return 1; | |
} | |
int status = 0; | |
status = ioctl(cdrom,CDROM_DRIVE_STATUS, CDSL_CURRENT); | |
printf("Status: %i", status); | |
// http://www.mjmwired.net/kernel/Documentation/ioctl/cdrom.txt | |
/* returno | |
#define CDS_NO_INFO 0 // if not implemented | |
#define CDS_NO_DISC 1 | |
#define CDS_TRAY_OPEN 2 | |
#define CDS_DRIVE_NOT_READY 3 | |
#define CDS_DISC_OK 4 | |
*/ | |
/* Use ioctl to send the CDROMEJECT command to the device | |
*/ | |
// if (ioctl(cdrom,CDROMEJECT,0)<0) { | |
// perror("ioctl"); | |
// return 1; | |
// } | |
close(cdrom); | |
return 0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/sh | |
while true ; do | |
echo -n "Informe o nome para o proximo arquivo: " | |
read caminho | |
destino="/tera/iso/"$caminho".iso" | |
while [ -f $destino ] ; do | |
echo Ja existe o arquivo $destino. | |
echo -n "Informe outro nome para o proximo arquivo: " | |
read caminho | |
destino="/tera/iso/"$caminho".iso" | |
done | |
status=`/home/fabio/bin/cdstatus` | |
while [ "$status" != "Status: 4" ] ; do | |
status=`/home/fabio/bin/cdstatus` | |
sleep 1 | |
echo "Aguardando cd ("$status")" | |
done | |
echo -n "Aguardando 30 segundos para comecar: " | |
for i in . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ; do echo -n .; sleep 1; done | |
echo "" | |
echo Copiando para $destino | |
readom dev=/dev/sr0 -nocorr -noerror -v -f=$destino | |
eject | |
echo "" | |
echo "" | |
echo "" | |
ls -l $destino | |
echo "" | |
echo "" | |
echo "" | |
done | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment