Hi folks,
How to automatically date the input directories
I have following script with preset directories which can be dated automatically when they are copied for burning
Script:-
Code:
#!/bin/bash
set -x
#Set directory path...
user=$(whoami)
now=$(date +%Y.%m.%d.%R)
ISO_File="/tmp/satimis/image_${user}_${now}.iso"
# Temporary file to store the resulting mkisofs command
CmdFile_1=/tmp/satimis/.TmpBurnCD$$
list=""
CopyDir(){
name=$1
dir=$2
if [ "$Default" = "" ];then
list="$list \"$name=$dir\""
else
if [ "$Default" = "yes" ];then
list="$list \"$name=$dir\""
fi
fi
}
# Preset directories for copying...
B123() {
CopyDir "/B123_${now}/" "/pathto/B123"
}
C123() {
CopyDir "/C123_${now}/" "/pathto/C123/"
}
D123() {
CopyDir "/D123_${now}/" "/pathto/D123/"
# Choosing preset directores for copying
REPLY="B"
until [ -z "$REPLY" ]
do
echo "Choose any of the following:"
echo
echo "[B]123"
echo "[C]123"
echo "[D]123"
echo "[A]ll
echo
echo "[Enter] = Exit"
echo
read
case "$REPLY" in
# Accept upper or lowercase input...
"B" | "b" )
B123
;;
"C" | "c" )
C123
;;
"D" | "d" )
D123
;;
"A" | "a" )
B123
C123
D123
;;
* )
#Default option.
# Do nothing for other keys
;;
esac
done
# Loop to get other directories...
echo "Enter directories to burn. Leave blank to end list"
entry="empty"
until [ -z $entry ]; do
echo -n "Enter a directory (eg: /ABC/=/pathto/ABC): "
read entry
if [ "$entry" != "" ]; then
list="$list \"$entry\""
fi
done
# If at least one directory has been entered....
if [ "$list" != "" ];then
#Construct the mkisofs command...
echo "/usr/bin/mkisofs -R -l -o $ISO_File -hide-rr-moved -graft-points \
$list" > "$CmdFile_1"
.......
.....
Now my problem is unable to automatically date additional directories input. I tried many variation on;
if [ "$entry" != "" ]; then
and
list="$list \"$entry\""
without result, such as;
"$entry" != "_${now}"
"$entry" "!_${now}"= ""
"$entry" != ""_${now}
list="$list \"$entry\_${now}\""
list="$list \"$entry${now}\""
etc.
Since the pattern of input is "/ABC/=/pathto/ABC" I'm not allowed to separate it.
Any advice. TIA
B.R.
satimis