Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Seeking help on re-editing a script

Hi folks,

I have following command line embedded on a desktop icon and a script. They work for me, burning a CD from pre-set directories and added directories.

Command line
xterm -hold -T "CDMaker by satimis" -e "su -c /path/to/cdmake"

Script:-
#!/bin/bash
# Set ISO filename...
user=$(whoami)
now=$(date +%Y.%m.%d.%R)
ISO_File="/home/satimis/To_burn/image_${user}_${now}.iso"
dir1="/home/satimis/Document/"
dir2="/home/satimis/Photo/"

# Loop to get directories...
echo "Enter directories to burn. Leave blank to end list"
entry="empty"
list=""
count=0
until [ -z $entry ]; do
echo -n "Enter a directory: "
read entry
if [ $entry != "" ]; then
list="$list $1$entry"
fi
done

# Create ISO file...
mkisofs -R -o "$ISO_File" -l -graft-points -hide-rr-moved
/Document/=$dir1
/Photo/=$dir2
$list

# Burn ISO file to disc
cdrecord dev=ATA:0,0,0 -v -eject $ISO_File

# Remove ISO file
rm $ISO_File
- END -

Steps taken as follow;
1)Clicking the icon starting xterm
2)Enter password to login as root
3)Enter further directories, if any, with corresponding path in the form of /Dir_AAA/=/path/to/Dir_AAA, etc. (cdrecord format). (If no further entry just hit to continue)

Remark:
dir1="/home/satimis/Document/"
dir2="/home/satimis/Photo/"
are permanently added.

Then the script will take care of the rest and a CD is burnt finally.


Now I need to re-edit;
1)The command line as
xterm -hold -T "CDMaker by satimis" -e /path/to/cdmake"

Let the script to handle login as root to execute commands on background.

2)Re-edit the script to perform

a)
Login as root after ISO_File created because USER is not allowed to burn CD.
(I don't want to add USER to the wheel using this route. Hoping to learn more on script)

b)
Re-edit the script to perform following steps.

b-1)
The script is evoked by the revised command line

b-2)
Before
dir1="/home/satimis/Document/"
dir2="/home/satimis/Photo/"

are added, confirmation is now required. It will pop up for entry of yes or no. If yes they will be added. If no they will not be added. The script will continue to next command asking for adding of further directory/directories with corresponding path.

Remark:
dir1="/home/satimis/Document/"
dir2="/home/satimis/Photo/"
are still added on the script

b-3)
After an ISO_file created, it will continue to login as root asking for input of root password.

b-4)
After a CD burnt, xterm will close. I'll remove the option -hold later to get it done.

I have tried several days re-editing the script with following syntax

>>>>
read -p "Add /home/satimis/Document/ ?"
if [ "$REPLY" = "yes" ]; then
# do stuff
else
# cancel
fi
<<<<

I could not make any progress. I'm searching for some guide line where to start, where to care, etc. Becasue changing any syntax on the script may affect another command.

I'm only about 7 day old on Bash programming.

Please advise. TIA

B.R.
Satimis
Sign In or Register to comment.