PDA

View Full Version : Seeking advice on script



satimis
5th October 2004, 06:00 PM
Hi folks,

I have following script saved to /usr/sbin/make_iso_file

1)

function make_iso_file ()
{
# initialize the following loop
# we're going to build the args to mkisofs, set it to the empty string
mkisofs_args="-R -o Image.iso -J -hide-rr-moved Document=/home/satimis/Document Photo=/home/satimis/Photo"
# and set the paths variable to all the remaining command-line arguments
paths="$@"
# and now iterate through all paths given on the command-line
for path in $paths
do
# for each path given, add the appropriate graft-point to mkisofs's arguments
mkisofs_args="${mkisofs_args} ${path##*/}=${path}"
done

# and now call mkisofs
mkisofs $mkisofs_args
}



2)
My goal is to create an ISO image applying following command line

# mkisofs -R -o Image.iso -J -hide-rr-moved Document=/path/to/Document Photo=/path/to/Photo"

from following directories;
Document=/path/to/Document
Photo=/path/to/Photo

plus argument for adding further directories with variated path, such as

dir-A=/path/to/dir-A
dir-B=/path/to/dir-B
etc.

which are added during executing the file "make_iso_file"

3)
# chmod +x /usr/sbin/make_iso_file

4)
# /usr/sbin/make_iso_file
/usr/sbin/make_iso_file: line 15: unexpected EOF while looking for matching `''
/usr/sbin/make_iso_file: line 22: syntax error: unexpected end of file

Kindly advise how to fix the problem. TIA

B.R.
satimis

crackers
6th October 2004, 04:51 AM
If that's the entire contents of the script file, then, no, it's not going to work. There's two issues at first glance:

1) The first line of the script needs to be


#!/bin/sh

2) You've only written a function - there's nothing in what you posted that executes that function.

I don't know if that's the issue, though, but it's at least a starting point...

satimis
11th October 2004, 12:08 PM
Hi crackers,

Tks for your advice. Now I re-arrange the scipt as follow and save it /home/satimis/mkiso_new;

[satimis@localhost satimis]$ cat mkiso_new


#!/bin/sh

ISO_FILE=/home/satimis/To_burn/Image.iso

mkisofs_args="-R -o ${ISO_FILE} -l -hide-rr-moved \
Document=/home/satimis/Document \
Photo=/home/satimis/Photo \
Working=/home/satimis/Working"

# set the paths variable to all the remaining command-line arguments
paths="$@"

echo "Remaining arguments ${paths}"

# iterate through all paths given on the command-line

for path in $paths
do
if [ -d $path ] ; then
echo "Adding ${path}"
else
echo "Dir ${path} doesn't exist"
exit 1
fi

# for each path given, add the appropriate graft-point to mkisofs's arguments
mkisofs_args="${mkisofs_args} ${path##*/}=${path}"

done

# and now call mkisofs

1)
# sh -vx ./mkiso_new

#!/bin/sh

ISO_FILE=/home/satimis/To_burn/Image.iso
+ ISO_FILE=/home/satimis/To_burn/Image.iso

mkisofs_args="-R -o ${ISO_FILE} -l -hide-rr-moved \
Document=/home/satimis/Document \
Photo=/home/satimis/Photo \
Working=/home/satimis/Working"
+ mkisofs_args=-R -o /home/satimis/To_burn/Image.iso -l -hide-rr-moved Document=/home/satimis/Document Photo=/home/satimis/Photo Working=/home/satimis/Working

# set the paths variable to all the remaining command-line arguments
paths="$@"
+ paths=

echo "Remaining arguments ${paths}"
+ echo 'Remaining arguments '
Remaining arguments

# iterate through all paths given on the command-line

for path in $paths
do
if [ -d $path ] ; then
echo "Adding ${path}"
else
echo "Dir ${path} doesn't exist"
exit 1
fi

# for each path given, add the appropriate graft-point to mkisofs's arguments
mkisofs_args="${mkisofs_args} ${path##*/}=${path}"

done

# and now call mkisofs

2)
[root@localhost satimis]# ./mkiso_new /home/satimis/Working
Remaining arguments /home/satimis/Working
Adding /home/satimis/Working

[root@localhost satimis]# ls /home/satimis/To_burn/
Image.iso

[root@localhost satimis]# mount -t iso9660 /home/satimis/To_burn/Image.iso -o loop /mnt/floppy

Files can be read.

[root@localhost satimis]# umount /mnt/floppy


3)
[root@localhost satimis]# rm /home/satimis/To_burn/Image.iso


[root@localhost satimis]# ./mkiso_new /home/satimis/Working

[root@localhost satimis]# ./mkiso_new /home/satimis/Document
/homesatimis/Photo
/home/satimis/Working

[root@localhost satimis]# ./mkiso_new /home/satimis/Document/
/homesatimis/Photo/
/home/satimis/Working/

None of them can create Image.iso

Remark:


[root@localhost satimis]# ./mkiso_new /home/satimis/Working
Remaining arguments /home/satimis/Working
Adding /home/satimis/Working

etc. indicated.

I can't find out the cause.


4)
With following command, Image.iso can be creaded

# mkisofs -R -o /home/satimis/To_burn/Image.iso -l -graft-point -hide-rr-moved /Document/=/home/satimis/Document/ /Photo/=/home/satimis/Photo/ /Working/=/home/satimis/Working/
......
Total translation table size: 0
Total rockridge attributes bytes: 735885
Total directory bytes: 1953792
Path table size(bytes): 14456
Max brk space used 5e2000
138979 extents written (271 MB)

Image.iso created on /home/satimis/To_burn

Could you please shed me some light. TIA

B.R.
satimis

satimis
11th October 2004, 05:13 PM
Hi folks,

Further to my last posting, following script works without problem

[satimis@localhost satimis]$ cat mkiso_01.iso
#!/bin/sh

ISO_FILE=/home/satimis/To_burn/Image.iso

mkisofs -R -o ${ISO_FILE} -l -graft-point -hide-rr-moved \
/Document/=/home/satimis/Document/ \
/Photo/=/home/satimis/Photo/ \
/Working/=/home/satimis/Working/

[satimis@localhost satimis]$ ./mkiso_01.iso
INFO: UTF-8 character encoding detected by locale settings.
Assuming UTF-8 encoded filenames on source filesystem,
use -input-charset to override.
.......
.........
Total translation table size: 0
Total rockridge attributes bytes: 736242
Total directory bytes: 1953792
Path table size(bytes): 14456
Max brk space used 5e2000
138985 extents written (271 MB)
[satimis@localhost satimis]$ ls /home/satimis/To_burn/
Image.iso

An Image.iso was created under /home/satimis/To_burn/


Now the remaining works are;

1) How to make /Working/=/home/satimis/Working/ variable, keeping the other 2 directories permanent.

i.e.
/Working/=/home/satimis/Working/ plus
/dir-AAA/=/path/to/dir-AAA/
/dir-BBB/=/path/to/dir-BBB/
etc. can be added as optional. Or they can be ignored without added.

2) How to make "Image_01.iso" changed.

i.e. "01" can be changed to read as "02 or 03 or 04, etc."

TIA

B.R.
satimis

tashirosgt
11th October 2004, 07:13 PM
The way I read your non-working script, it never executes the mkisofs command. It just builds the arguments to it. Did omit a line when you pasted in the message composition window?

satimis
12th October 2004, 03:22 AM
The way I read your non-working script, it never executes the mkisofs command. It just builds the arguments to it. Did omit a line when you pasted in the message composition window?Hi tashirosgt,

Tks for your response.

I got the first script from a folk (say, folk-A) on another forum as follow but it did not work;
function make_iso_file ()
{
# initialize the following loop
# we're going to build the args to mkisofs, set it to the empty string
mkisofs_args="-R -o Image.iso -J -hide-rr-moved Document=/home/satimis/Document Photo=/home/satimis/Photo"
# and set the paths variable to all the remaining command-line arguments
paths="$@"
# and now iterate through all paths given on the command-line
for path in $paths
do
# for each path given, add the appropriate graft-point to mkisofs's arguments
mkisofs_args="${mkisofs_args} ${path##*/}=${path}"
done

# and now call mkisofs
mkisofs $mkisofs_args
}

Another folk (say, folk-B) came and rearraged it as follow;
code:cat mkiso_satamis.txt
#!/bin/sh

make_iso_file () {

mkisofs_args="-R -o Image.iso -J -hide-rr-moved Document=/home/satimis/Document Photo=/home/satimis/Photo"

# set the paths variable to all the remaining command-line arguments
paths="$@"
echo "Remaining arguments ${paths}"

# iterate through all paths given on the command-line
for path in $paths
do
# for each path given, add the appropriate graft-point to mkisofs's arguments
mkisofs_args="${mkisofs_args} ${path##*/}=${path}"
done

# and now call mkisofs
echo "mkisofs $mkisofs_args"
}

make_iso_file /home/j65nko/pic/rWedding /home/j65nko/pic/BirthdayI adjusted the 2nd script to suit my case. But unfortunately it still did not work. Then folk-B adjusted his scipt as follow;
#!/bin/sh

mkisofs_args="-R -o Image.iso -J -hide-rr-moved \
Document=/home/satimis/Document \
Photo=/home/satimis/Photo"

# set the paths variable to all the remaining command-line arguments
paths="$@"

echo "Remaining arguments ${paths}"

# iterate through all paths given on the command-line

for path in $paths
do
if [ -d $path ] ; then
echo "Adding ${path}"
else
echo "Dir ${path} doesn't exist"
exit 1
fi

# for each path given, add the appropriate graft-point to mkisofs's arguments
mkisofs_args="${mkisofs_args} ${path##*/}=${path}"

done

# and now call mkisofs

mkisofs ${mkisofs_args}Sorry I omitted the last line "mkisofs ${mkisofs_args}"
But it still can't work. I tried it several times with different syntax without result.

# ./mkiso_new /home/satimis/Document
........
mkisofs: Error: '/home/satimis/Document/Reference/LinuxPartitionHowTo-1/www.linu xplanet.com/linuxplanet/tutorials/3174/1/index.html' and '/home/satimis/Document /HardDrive_Partitioning_Moving_etc/LinuxPartitionHowTo-1/www.linuxplanet.com/lin uxplanet/tutorials/3174/1/index.html' have the same Rock Ridge name 'index.html' .
mkisofs: Error: '/home/satimis/Document/Reference/LinuxPartitionHowTo-1/www.linu xplanet.com/linuxplanet/tutorials/3174/1/index.html' and '/home/satimis/Document /HardDrive_Partitioning_Moving_etc/LinuxPartitionHowTo-1/www.linuxplanet.com/lin uxplanet/tutorials/3174/1/index.html' have the same Rock Ridge name 'index.html' .
mkisofs: Unable to sort directory /home/satimis/Document/HardDrive_Partitioning_ Moving_etc/LinuxPartitionHowTo-1/www.linuxplanet.com/linuxplanet/tutorials/3174/ 1

# ./mkiso_new /home/satimis/Document/

Remaining arguments /home/satimis/Document/
Adding /home/satimis/Document/
INFO: UTF-8 character encoding detected by locale settings.
Assuming UTF-8 encoded filenames on source filesystem,
use -input-charset to override.
mkisofs: No such file or directory. Invalid node - =/home/satimis/Document/
Finally I created another script as listed on my last posting. It works for me. I repeat my script as follow;
#!/bin/sh

ISO_FILE=/home/satimis/To_burn/Image.iso

mkisofs -R -o ${ISO_FILE} -l -graft-point -hide-rr-moved \
/Document/=/home/satimis/Document/ \
/Photo/=/home/satimis/Photo/ \
/Working/=/home/satimis/Working/Now what I'm trying to add are as follows;

1) How to make /Working/=/home/satimis/Working/ variable, keeping the other 2 directories
/Document/=/home/satimis/Document/
/Photo/=/home/satimis/Photo/
permanent.

i.e.
/Working/=/home/satimis/Working/ plus if needed
/dir-AAA/=/path/to/dir-AAA/
/dir-BBB/=/path/to/dir-BBB/
etc. can be added as optional. Or they can be ignored without added.

2) How to make "Image_01.iso" changed.

i.e. "01" can be changed to read as "02 or 03 or 04, etc."

TIA

B.R.
satimis

tashirosgt
12th October 2004, 06:17 PM
It's going to be too confusing to talk about several scripts at once. What I notice about the "folk B adjusted his .." script is that you did not specify the option -graft-points to mkisofs (its "-graft-points" not "graft-point"). But you were trying to specify them in the arguments to mkisofs. What happens if you fix that?

mugga
26th October 2004, 01:17 PM
I don't know if this is a help, but I have created a couple of scripts called "makeISO" & "burnISO" that I use to create ISO images and then burn them...they are at my site here: http://mwynwood.com/bw/?module=portfolio

Hope they help...