hi all,
i have made my machine a freeBSD machine instead of a centos machine and my script doesnt work anymore and i was wondering if anyone can help me into why, i thought the commands are the same, here it is -
#!/bin/bash
source=/vol/cha-work/_ARCHIVE/to_be_archived/audio
temp=/mnt/archive/temp
dest=/vol/cha-archive/audio
echo "is this archive for an audio tar press (t) or an audio directory press (d)"
read option
d)
cd "$source"
echo "please specify full path to directory you want to be made into a tar"
read -e dir
# echo "please enter ID number ie ID1234"
# read id
# echo "please specify where you want the tar file to be stored"
# read -e dest
cd "$dir"
base=$(basename "$dir")
echo -e "COPY "$base" to "$temp"\n"
echo -e "CREATE "$base".tar in "$temp"\n"
echo -e "COPY "$base".tar to "$dest"\n"
echo -e "REMOVE "$base".tar from "$temp" \n"
echo -e "REMOVE "$base" from "$temp"\n"
echo -e "REMOVE "$base" from "$source"/"$dir"\n"
echo "is this information correct, press (yes) or press (no)"
read correct
case $correct in
yes)
echo "the script will now continue";;
no)
echo "please re-run the script inputting correct details"
exit;;
*)
echo "invalid selection, please re-run the script"
exit;;
esac
date >> /vol/cha-work/_ARCHIVE/inventories/"$base".csv
echo "" >> /vol/cha-work/_ARCHIVE/inventories/"$base".csv
# echo -e ""$id"\n" >> /vol/cha-work/_ARCHIVE/inventories/"$base".csv
echo -e ""$source"/"$dir"\n" >> /vol/cha-work/_ARCHIVE/inventories/"$base".csv
echo -e "how many files = `find . -type f | wc -l`\n" >> /vol/cha-work/_ARCHIVE/inventories/"$base".csv
echo -e "size of directory = `du -sh`\n" >> /vol/cha-work/_ARCHIVE/inventories/"$base".csv
ls -R >> /vol/cha-work/_ARCHIVE/inventories/"$base".csv
cd ..
if ! cp -R "$base" "$temp" ; then
echo "something went wrong with the recursive copy command, please do manually"
exit
fi
cd "$temp"
chmod -R 777 "$temp"
if ! tar -cf "$base".tar "$base" ; then
echo "something went wrong creating the tar, please do manually"
exit
fi
if ! cp "$base".tar "$dest" ; then
echo "something went wrong copying the tar, please do manually"
exit
fi
if ! rm -f "$temp"/"$base".tar ; then
echo "something went wrong removing the tar, please do manually"
exit
fi
if ! rm -rf "$temp"/"$base" ; then
echo "something went wrong removing from temp, please do manually"
exit
fi
cd "$source"/"$dir"
cd ..
if ! rm -rf "$base" ; then
echo "something went wrong removing from source, please do manually"
exit
fi;;
*)
echo "invalid selection, please re-run the script"
exit;;
esac
many thanks,
rob