Hi Guys,
I need some help. I am trying to create a shell script of commands I typically enter in Terminal, but I am having problems. Even the most basic command like 'clear' shows up in terminal as "Command not found".
An explanation, if I enter ~/USBDisk... this is meant to go in the current user's home folder in a sub-folder called USBDisk... but the script return "no such file or directory." The one where I am copying from /Volumes/USBDisk/.... this is always the name of the volume from where I want to copy from. But the the destination's username home folder can vary.
I am also trying to save a variable "diskno" but it is not saving correctly. It saves the string I wrote, and not the result of the diskutil command I typed. When I get rid of the ' at beginning and end, I get again a "command not found error".
Any help or advice is greatly appreciated.
I need some help. I am trying to create a shell script of commands I typically enter in Terminal, but I am having problems. Even the most basic command like 'clear' shows up in terminal as "Command not found".
An explanation, if I enter ~/USBDisk... this is meant to go in the current user's home folder in a sub-folder called USBDisk... but the script return "no such file or directory." The one where I am copying from /Volumes/USBDisk/.... this is always the name of the volume from where I want to copy from. But the the destination's username home folder can vary.
I am also trying to save a variable "diskno" but it is not saving correctly. It saves the string I wrote, and not the result of the diskutil command I typed. When I get rid of the ' at beginning and end, I get again a "command not found error".
Any help or advice is greatly appreciated.
Code:
#!/bin/bash
cd
mkdir USBDisk USBDisk/Backup USBDisk/Work USBDisk/Preboot
clear
#open -a Preview /Volumes/USBDisk/usr/listdisks.png
diskno='diskutil list |grep "USBDisk" |grep -o '\(disk[0-9]\)''
echo "We are backing up your USB Drive $diskno "
sudo dd if=/dev/r"$diskno" of=~/USBDisk/Backup/stick-back.img bs=51200
clear
echo Backup complete. About to start building Boot DVD image.
echo "Copying files to Work folder"
cp /Volumes/USBDisk/usr/bootcd/cdboot ~/USBDisk/Work/
cp /Volumes/USBDisk/usr/bootcd/106/Extra ~/USBDisk/Work/
cp /Volumes/USBDisk/Extra/com.apple.Boot.plist ~/USBDisk/Work/Extra/
echo "Building Preboot.dmg"
cp /Volumes/USBDisk/Extra/com.apple.Boot.plist ~/USBDisk/Preboot/Extra/
cp /Volumes/USBDisk/Extra/dsdt.aml ~/USBDisk/Preboot/Extra/
cp /Volumes/USBDisk/Extra/SMBIOS.plist ~/USBDisk/Preboot/Extra/
cp /Volumes/USBDisk/Extra/10.6/Extensions.mkext ~/USBDisk/Preboot/Extra/
cp /Volumes/USBDisk/usr/bootcd/106/mach_kernel ~/USBDisk/Preboot/Extra/
cp /Volumes/USBDisk/usr/bootcd/106/Extra/Themes ~/USBDisk/Preboot/Extra/
echo "Creating .DMG file"
hdiutil create ~/USBDisk/Work/Prebootraw.dmg -srcfolder ~/USBDisk/Preboot
hdiutil convert ~/USBDisk/Work/Prebootraw.dmg -format UDRO -o ~/USBDisk/Work/Preboot.dmg
rm ~/USBDisk/Work/Prebootraw.dmg
echo "Copy backup image to Work Folder"
cp /Volumes/USBDisk/usr/bootcd/Restore_Device ~/USBDisk/Work/
cp ~/USBDisk/Backup/stick-back.img ~/USBDisk/Work/Restore_Device/
echo "Create ISO file"
cd
cd ~/USBDisk/Work/
sudo hdiutil makehybrid -o ~/Desktop/BurnMe.iso ~/USBDisk/Work/ -iso -hfs -joliet -eltorito-boot ~/USBDisk/Work/cdboot no-emul-boot -hfs-volume-name "Boot-DVD" -joliet-volume-name "Boot-DVD"
echo "ISO file created, process completed. "