LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 11-03-2008, 05:43 PM   #61
frenchn00b
Senior Member
 
Registered: Jun 2007
Location: E.U., Mountains :-)
Distribution: Debian, Etch, the greatest
Posts: 2,546

Original Poster
Rep: Reputation: 57

Hi,
So finally, this is my version made in bash/sh, with works when you get a crash of your machine and wanna burn in rescue mode rw
I hope you like it
Improvements are encouraged and email/private message are also too

Code:
#!/bin/sh

echo " "
echo "Beware, this is very buggy program, no warranty, possible loss of data!"
echo "version 0.01 Frenchn00b, 3 Nov 2008 on Debian Etch"
if [ "$1" == "--help" ]  ; then
	echo "Use:"
	echo "    burnthefolder arg1 [arg2] [arg3] [arg4]"
	echo " "
	echo "Arg1:"
	echo "--debug" 
	echo "--help	this help" 
	echo "arg1	specify the device to burn eg /dev/hdc "
	echo " "
	echo "Arg2:"
	echo "--burn	to start burning with growisofs"
	echo "--simulate	to simulate burning"
	echo "Arg3:"
	echo "--noeject	Do not eject the media after burning"
	echo "--nosound	Do not start any sounds after burning"
echo "Arg3 Arg4:"
echo "  Arg3	--temp"

echo "  Arg4	folder where the temp files are generated eg /tmp/frenchn00b  and not /tmp/frenchn00b/  "

	exit 0
fi

if [ "$3" == "--temp" ] ; then
	TMPFILLOC="$4"
	if [ "$4" == "" ] ; then
		TMPFILLOC="/tmp"
	fi	
	else
	TMPFILLOC="/tmp"
fi

maxsizeofyourdevice=4294967296
echo "Maxsizeofyourdevice set to 4294967296"
SIZE=0
LISTTMP=""
LISTTMPH=""
TOTAL_SIZE=0
TO_BURN=""
CDROM="0"


  
if  [ "$CDROM" == "0" ] ; then
    ISO=`mktemp $TMPFILLOC/isoXXX`
    ISOH=`mktemp $TMPFILLOC/isoXXX`
    echo " "
    echo "temp files: $ISO $ISOH generated"
    LISTTMP="$LISTTMP $ISO "
    LISTTMPH="$LISTTMPH $ISOH "
    CDROM="1"
fi


for X in *
do
  SIZEH=`du -h "$X" | tail -n 1 | cut -f 1`
  SIZE=`du -b "$X" | tail -n 1 | cut -f 1`
 


  if [  `expr $SIZE + $TOTAL_SIZE` -gt "$maxsizeofyourdevice" ] 
then 
CDROM="0"
if  [ "$CDROM" == "0" ] ; then
    ISO=`mktemp $TMPFILLOC/isoXXX`
    ISOH=`mktemp $TMPFILLOC/isoXXX`
    echo " "
    echo "temp files: $ISO $ISOH generated"
    LISTTMP="$LISTTMP $ISO "
    LISTTMPH="$LISTTMPH $ISOH "
    CDROM="1"
fi

    TO_BURN="$(pwd)/$X"
    TOTAL_SIZE="$SIZE"
    if [ "$1" == "--debug" ]  ; then
    	echo "1:$SIZEH/${TOTAL_SIZE}: $TO_BURN" 
    else
    	echo "1:$SIZE/${TOTAL_SIZE}/$maxsizeofyourdevice: $TO_BURN" 
    fi
    echo "$SIZEH: $TO_BURN"  > "$ISOH"
    echo "$TO_BURN"  > "$ISO"
    CDROM="0"

  else
    TO_BURN="$(pwd)/$X"
    TO_BURNTOTAL="$TO_BURN $X "
    TOTAL_SIZE=`expr $SIZE + $TOTAL_SIZE`
    if [ "$1" == "--debug" ]  ; then
    	echo "2:$SIZEH/${TOTAL_SIZE}: $TO_BURN" 
    else
    	echo "2:$SIZE/${TOTAL_SIZE}/$maxsizeofyourdevice: $TO_BURN" 
    fi
    echo "$SIZEH: $TO_BURN"  >> "$ISOH"
    echo "$TO_BURN"  >> "$ISO"

  fi
	
done

#echo "DONE"
 
if [ "$1" == "--debug" ]  ; then
	echo " "
	echo "------------"
	echo "DEBUG Mode:"
	echo "$LISTTMP"
	for each in $LISTTMP ; do
		echo "$each:"
		cat "$each"
	done
fi

if [ "$1" == "--debug" ]  ; then
	echo " "
	echo "------------"
	echo "DEBUG Mode (human):"
	echo "$LISTTMPH"
	for each in $LISTTMPH ; do
		echo "$each:"
		cat "$each"
	done
fi

if [ ! "$1" == "--debug" ]  ; then

if [ "$2" == "--simulate" ]  ; then
	echo " "
	echo "------------"
	echo "Simulation type on $1 media, no burning of $LISTTMP"
	for each in $LISTTMP ; do
		echo "growisofs -Z $1 -R -J -path-file $each"
		echo "$each:"
		cat "$each"
	done
fi

if [ "$2" == "--burn" ]  ; then
	echo " "
	echo "------------"
	echo "Burn on $1 media, no burning of $LISTTMP"
	for each in $LISTTMP ; do
	echo " "
	echo "------------"
		echo "growisofs -Z $1 -R -J -path-file $each"
		growisofs -Z "$1" -R -J -path-file "$each"
		echo "$each:"
		cat "$each"
		echo "Burning of $each to $1: Done"
		echo "Enter a new dvd media and press a key please"
		if [ ! "$3" == "--nosound" ]  ; then 
			aplay /usr/share/sounds/KDE_Beep.ogg
		fi
		if [ ! "$3" == "--noeject" ]  ; then 
			eject "$1"
		fi
		read lkfdjsjkdklfdsa
	done
fi


fi
Enjoy !!
 
Old 11-03-2008, 06:43 PM   #62
frenchn00b
Senior Member
 
Registered: Jun 2007
Location: E.U., Mountains :-)
Distribution: Debian, Etch, the greatest
Posts: 2,546

Original Poster
Rep: Reputation: 57
Damn !
Not working

could anyone debug it... the error is where is teh line growisofs is :

I have no idea how to use growisofs...


Code:
#!/bin/sh

echo " "
echo "Beware, this is very buggy program, no warranty, possible loss of data!"
echo "version 0.01 Frenchn00b, 3 Nov 2008 on Debian Etch"
if [ "$1" == "--help" ]  ; then
	echo "Use:"
	echo "    burnthefolder arg1 [arg2] [arg3] [arg4]"
	echo " "
	echo "Arg1:"
	echo "--debug" 
	echo "--help	this help" 
	echo "arg1	specify the device to burn eg /dev/hdc "
	echo " "
	echo "Arg2:"
	echo "--burn	to start burning with growisofs"
	echo "--simulate	to simulate burning"
	echo "Arg3:"
	echo "--noeject	Do not eject the media after burning"
	echo "--nosound	Do not start any sounds after burning"
echo "Arg3 Arg4:"
echo "  Arg3	--temp"

echo "  Arg4	folder where the temp files are generated eg /tmp/frenchn00b  and not /tmp/frenchn00b/  "

	exit 0
fi

if [ "$3" == "--temp" ] ; then
	TMPFILLOC="$4"
	if [ "$4" == "" ] ; then
		TMPFILLOC="/tmp"
	fi	
	else
	TMPFILLOC="/tmp"
fi

maxsizeofyourdevice=4294967296
echo "Maxsizeofyourdevice set to 4294967296"
SIZE=0
LISTTMP=""
LISTTMPH=""
TOTAL_SIZE=0
TO_BURN=""
CDROM="0"


  
if  [ "$CDROM" == "0" ] ; then
    ISO=`mktemp $TMPFILLOC/isoXXX`
    ISOH=`mktemp $TMPFILLOC/isoXXX`
    echo " "
    echo "temp files: $ISO $ISOH generated"
    LISTTMP="$LISTTMP $ISO "
    LISTTMPH="$LISTTMPH $ISOH "
    CDROM="1"
fi


for X in *
do
  SIZEH=`du -h "$X" | tail -n 1 | cut -f 1`
  SIZE=`du -b "$X" | tail -n 1 | cut -f 1`
 


  if [  `expr $SIZE + $TOTAL_SIZE` -gt "$maxsizeofyourdevice" ] 
then 
CDROM="0"
if  [ "$CDROM" == "0" ] ; then
    ISO=`mktemp $TMPFILLOC/isoXXX`
    ISOH=`mktemp $TMPFILLOC/isoXXX`
    echo " "
    echo "temp files: $ISO $ISOH generated"
    LISTTMP="$LISTTMP $ISO "
    LISTTMPH="$LISTTMPH $ISOH "
    CDROM="1"
fi

    TO_BURN="$(pwd)/$X"
    TOTAL_SIZE="$SIZE"
    if [ "$1" == "--debug" ]  ; then
    	echo "1:$SIZEH/${TOTAL_SIZE}: $TO_BURN" 
    else
    	echo "1:$SIZE/${TOTAL_SIZE}/$maxsizeofyourdevice: $TO_BURN" 
    fi
    echo "$SIZEH: $TO_BURN"  > "$ISOH"
    echo "$TO_BURN"  > "$ISO"
    CDROM="0"

  else
    TO_BURN="$(pwd)/$X"
    TO_BURNTOTAL="$TO_BURN $X "
    TOTAL_SIZE=`expr $SIZE + $TOTAL_SIZE`
    if [ "$1" == "--debug" ]  ; then
    	echo "2:$SIZEH/${TOTAL_SIZE}: $TO_BURN" 
    else
    	echo "2:$SIZE/${TOTAL_SIZE}/$maxsizeofyourdevice: $TO_BURN" 
    fi
    echo "$SIZEH: $TO_BURN"  >> "$ISOH"
    echo "$TO_BURN"  >> "$ISO"

  fi
	
done

#echo "DONE"
 
if [ "$1" == "--debug" ]  ; then
	echo " "
	echo "------------"
	echo "DEBUG Mode:"
	echo "$LISTTMP"
	for each in $LISTTMP ; do
		echo "$each:"
		cat "$each"
	done
fi

if [ "$1" == "--debug" ]  ; then
	echo " "
	echo "------------"
	echo "DEBUG Mode (human):"
	echo "$LISTTMPH"
	for each in $LISTTMPH ; do
		echo "$each:"
		cat "$each"
	done
fi

if [ ! "$1" == "--debug" ]  ; then

if [ "$2" == "--simulate" ]  ; then
	echo " "
	echo "------------"
	echo "Simulation type on $1 media, no burning of $LISTTMP"
	for each in $LISTTMP ; do
		echo "growisofs -Z $1 -R -J -path-file $each"
		echo "$each:"
		cat "$each"
	done
fi

if [ "$2" == "--burn" ]  ; then
	echo " "
	echo "------------"
	echo "Burn on $1 media, no burning of $LISTTMP"
	for each in $LISTTMP ; do
	echo " "
	echo "------------"
		echo "nonhuman iso list: $LISTTMP "
		echo "human iso list: $LISTTMPH "
		echo "  "
		echo "start burning $each ? so press enter ..."
		echo "if you would like to append on dvd instead of create new media, type append followed by enter"
		printf ":>"
		read questionapp
		if [ "$questionapp" == "append"  ] ; then
			echo "growisofs -M $1 -R -J < $each"
			growisofs -M "$1" -R -J  -path-list "$(cat $each)"
			else
			echo "growisofs -Z $1 -R -J < $each"
			growisofs -Z "$1" -R -J -path-list "$(cat $each)"

###growisofs -Z /dev/hdb -R -J  -r -l -iso-level 2      -path-list bur/iso423
		fi

		echo "$each:"
		cat "$each"
		echo "Burning of $each to $1: Done"
		echo "Enter a new dvd media and press a key please"
		if [ ! "$3" == "--nosound" ]  ; then 
			aplay /usr/share/sounds/KDE_Beep.ogg
		fi
		if [ ! "$3" == "--noeject" ]  ; then 
			eject "$1"
		fi
		read lkfdjsjkdklfdsa
	done
fi


fi
 
Old 11-05-2008, 06:35 PM   #63
frenchn00b
Senior Member
 
Registered: Jun 2007
Location: E.U., Mountains :-)
Distribution: Debian, Etch, the greatest
Posts: 2,546

Original Poster
Rep: Reputation: 57
FINALLY I MADE IT
I CAN FINALLY BURN MY 160GB of data that have crashed!
because I used 0 0 in the /etc/fstab (wrong wrong)


SCRIPT WITH CHOICES MADE IN BASH FOR DVD BACKUP IN RESCUE MODE
SEARCH CODERS TO MAKE THIS SCRIPT EVEN BETTER

NO X REQUIRED
SKIP MODE TOO
APPEND MODE TOO
LISTISO TOO

AND MANY OTHER FEATURES (well, not really )



WORKING AND HARDLY TESTED, buggy

Code:
#!/bin/sh

echo " "
echo "Beware, this is very buggy program, no warranty, possible loss of data!"
echo "version 0.01 Frenchn00b, 3 Nov 2008 on Debian Etch"
if [ "$1" == "--help" ]  ; then
	echo "Use:"
	echo "    burnthefolder arg1 [arg2] [arg3] [arg4]"
	echo " "
	echo "Arg1:"
	echo "--debug" 
	echo "--help	this help" 
	echo "arg1	specify the device to burn eg /dev/hdc "
	echo " "
	echo "Arg2:"
	echo "--burn	to start burning with growisofs"
	echo "--simulate	to simulate burning"
	echo "Arg3:"
	echo "--noeject	Do not eject the media after burning"
	echo "--nosound	Do not start any sounds after burning"
echo "Arg3 Arg4:"
echo "  Arg3	--temp"

echo "  Arg4	folder where the temp files are generated eg /tmp/frenchn00b  and not /tmp/frenchn00b/  "

	exit 0
fi

if [ "$3" == "--temp" ] ; then
	TMPFILLOC="$4"
	if [ "$4" == "" ] ; then
		TMPFILLOC="/tmp"
	fi	
	else
	TMPFILLOC="/tmp"
fi

maxsizeofyourdevice=4294967296
echo "Maxsizeofyourdevice set to 4294967296"
SIZE=0
LISTTMP=""
LISTTMPH=""
TOTAL_SIZE=0
TO_BURN=""
CDROM="0"


  
if  [ "$CDROM" == "0" ] ; then
    ISO=`mktemp $TMPFILLOC/isoXXX`
    ISOH=`mktemp $TMPFILLOC/isoXXX`
    echo " "
    echo "temp files: $ISO $ISOH generated"
    LISTTMP="$LISTTMP $ISO "
    LISTTMPH="$LISTTMPH $ISOH "
    CDROM="1"
fi


for X in *
do
  SIZEH=`du -h "$X" | tail -n 1 | cut -f 1`
  SIZE=`du -b "$X" | tail -n 1 | cut -f 1`
 


  if [  `expr $SIZE + $TOTAL_SIZE` -gt "$maxsizeofyourdevice" ] 
then 
CDROM="0"
if  [ "$CDROM" == "0" ] ; then
    ISO=`mktemp $TMPFILLOC/isoXXX`
    ISOH=`mktemp $TMPFILLOC/isoXXX`
    echo " "
    echo "temp files: $ISO $ISOH generated"
    LISTTMP="$LISTTMP $ISO "
    LISTTMPH="$LISTTMPH $ISOH "
    CDROM="1"
fi

    TO_BURN="$(pwd)/$X"
    TOTAL_SIZE="$SIZE"
    if [ "$1" == "--debug" ]  ; then
    	echo "1:$SIZEH/${TOTAL_SIZE}: $TO_BURN" 
    else
    	echo "1:$SIZE/${TOTAL_SIZE}/$maxsizeofyourdevice: $TO_BURN" 
    fi
    echo "$SIZEH: $TO_BURN"  > "$ISOH"
    echo "$TO_BURN"  > "$ISO"
    CDROM="0"

  else
    TO_BURN="$(pwd)/$X"
    TO_BURNTOTAL="$TO_BURN $X "
    TOTAL_SIZE=`expr $SIZE + $TOTAL_SIZE`
    if [ "$1" == "--debug" ]  ; then
    	echo "2:$SIZEH/${TOTAL_SIZE}: $TO_BURN" 
    else
    	echo "2:$SIZE/${TOTAL_SIZE}/$maxsizeofyourdevice: $TO_BURN" 
    fi
    echo "$SIZEH: $TO_BURN"  >> "$ISOH"
    echo "$TO_BURN"  >> "$ISO"

  fi
	
done

#echo "DONE"
 
if [ "$1" == "--debug" ]  ; then
	echo " "
	echo "------------"
	echo "DEBUG Mode:"
	echo "$LISTTMP"
	for each in $LISTTMP ; do
		echo "$each:"
		cat "$each"
	done
fi

if [ "$1" == "--debug" ]  ; then
	echo " "
	echo "------------"
	echo "DEBUG Mode (human):"
	echo "$LISTTMPH"
	for each in $LISTTMPH ; do
		echo "$each:"
		cat "$each"
	done
fi

if [ ! "$1" == "--debug" ]  ; then

if [ "$2" == "--simulate" ]  ; then
	echo " "
	echo "------------"
	echo "Simulation type on $1 media, no burning of $LISTTMP"
	for each in $LISTTMP ; do
		echo "growisofs -Z $1 -R -J -path-file $each"
		echo "$each:"
		cat "$each"
	done
fi

if [ "$2" == "--burn" ]  ; then
	cdburncounter=1
	# echo $cdburncountermax cdburncounter
	cdburncountermax="`ls -1 $4 | while read n ; do  let counter+=1 ; clear ; echo $counter ;  done  `" ; echo $cdburncountermax
	echo " "
	echo "------------"
	echo "Burn on $1 media, no burning of $LISTTMP"
	for each in $LISTTMP ; do
	echo " "
	echo "------------"
		echo "nonhuman iso list: $LISTTMP "
		echo "human iso list: $LISTTMPH "
		echo "  "

		SIZEFR=0 
		cat $each | while read fi ; do    incr=` du -b "$fi" |tail -n 1 | cut -f 1 ` ; let SIZEFR+=$incr ; echo "$SIZEFR" > "$4/filesz" ;   done 
		printf "The final size of the archive is "
		printf `cat $4/filesz`
		sizelof=`cat $4/filesz`
## here pleazse below help, dont know how to calc
##		THEVQLUEFINQL1=`echo  $maxsizeofyourdevice - $sizelof  | bc `
##		THEVQLUEFINQL2=`echo  THEVQLUEFINQL1 /  $maxsizeofyourdevice * 100 ) | bc `
 		echo " of $maxsizeofyourdevice ie  $THEVQLUEFINQL2"
		questionapp="checkcd"
		while [  "$questionapp" == "checkcd" ] ||  [  "$questionapp" == "listiso" ]  ||  [  "$questionapp" == "listisoless" ]  ||  [  "$questionapp" == "ejectin" ]  ||  [  "$questionapp" == "ejectout" ]   ||  [  "$questionapp" == "umountcd" ]  ; do
			echo " "
			echo "- if you would like to append the $each on dvd instead of create new media, type append followed by enter"
			echo "- if you would like to skip $each on dvd instead of create new media, type skip followed by enter"
			echo "- if you would like to listiso or listisoless to list the iso $each"
			echo "- if you would like to checkcd to ls cdrom"
			echo "- ejectin to slot in the cdrom"
			echo "- umountcd to umount the cdrom"
			echo "- ejectout to eject the cdrom"
			echo "- Enter to continue for new DVD disc to be burnt"
			printf "CD$cdburncounter/:>"
			read questionapp
			if [  "$questionapp" == "checkcd" ]  ; then
				echo "Cdrom: $1"
				 mount "$1" `cat /etc/fstab | grep /dev/hdb  | awk ' { print $2 }  '`
				 ls   `cat /etc/fstab | grep $1  | awk ' { print $2 }  '`
				 umount `cat /etc/fstab | grep $1  | awk ' { print $2 }  '`
			fi 
 
			if [  "$questionapp" == "listiso" ]  ; then
				cat "$each"
			fi
			if [  "$questionapp" == "ejectin" ]  ; then
				eject -t "$1"
			fi
			if [  "$questionapp" == "ejectout" ]  ; then
				eject  "$1"
			fi

			if [  "$questionapp" == "umountcd" ]  ; then
				printf "Unmount $1 "
				echo `cat /etc/fstab | grep $1  | awk ' { print $2 }  '`
                		 umount `cat /etc/fstab | grep $1  | awk ' { print $2 }  '`
			fi

			if [  "$questionapp" == "listisoless" ]  ; then
				cat "$each" | less
			fi

	        done 

		if  [ ! "$questionapp" == "append"  ]  &&  [ ! "$questionapp" == "skip"  ] ; then
			clear
			echo " "
			echo "start burning $each ? so press enter ..."
			echo "- if you would like to append the $each on dvd instead of create new media, type append followed by enter"
			echo "- if you would like to skip $each on dvd instead of create new media, type skip followed by enter"
			printf "CD$cdburncounter/:>"
			read questionapp
		fi
 
 
		if [ "$questionapp" == "append"  ] ; then
			echo "growisofs -M $1 -R -J < $each"
			growisofs -M "$1" -R -J  -path-list "$each"
			echo " $each burnt to $1"
			let cdburncounter+=1
			printf "The final size of the archive $cdburncounter over $cdburncountermax is "
			echo `cat $4/filesz`
			# echo $cdburncountermax cdburncounter
		fi


		if [ "$questionapp" == "skip"  ] ; then
			echo "growisofs -M $1 -R -J < $each"
			echo " $each skipped, to $1"
			let cdburncounter+=1
			printf "The final size of the archive $cdburncounter over $cdburncountermax is "
			echo `cat $4/filesz`
			# echo $cdburncountermax cdburncounter
		fi
 
		if [ ! "$questionapp" == "append"  ] &&  [ ! "$questionapp" == "skip"  ]  ; then
			echo "growisofs -Z $1 -R -J < $each"
			growisofs -Z "$1" -R -J -path-list  "$each"
			echo " $each burnt to $1"
			let cdburncounter+=1
			printf "The final size of the archive $cdburncounter over $cdburncountermax is "
			echo `cat $4/filesz`
			# echo $cdburncountermax cdburncounter
		fi



		
		echo " "
		echo "Enter a new dvd media and press a key please"
		if [ ! "$3" == "--nosound" ]  ; then 
			#aplay /usr/share/sounds/KDE_Beep.ogg
			beep
		fi
		if [ ! "$3" == "--noeject" ]  ; then 
			eject "$1"
		fi
		read lkfdjsjkdklfdsa
	done
fi


fi


##growisofs -Z /dev/hdb -R -J  -r -l -iso-level 2      -path-list bur/iso423
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
mount /dev/hdc /dev/cdrom doesn't work ShrikesHarvest Linux - Newbie 10 02-21-2009 08:05 AM
/dev/hdc no longer linked to /dev/cdrom - why? Ook Slackware 3 08-25-2007 01:00 AM
why has udev swapped /dev/hdc and /dev/hdd ? chaosbear Linux - Hardware 2 08-09-2006 04:23 AM
I cannot access EITHER CD drive! And there's no /dev/hdc or /dev/hdd or /dev/cdrom! Dmalic Linux - Hardware 13 11-18-2005 08:11 PM
ln: creating symbolic link `/dev/dvd' to `/dev/hdc': Permission denied qazwsx27 Fedora 3 06-14-2005 03:09 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 04:08 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration