LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 10-11-2004, 06:01 AM   #1
satimis
Senior Member
 
Registered: Apr 2003
Posts: 3,426

Rep: Reputation: 53
Seeking advice on bash script


Hi folks,

I have following script but it only worked once. Steps performed as follows;

save it /home/satimis/mkiso_new and chmod +x

[satimis@localhost satimis]$ cat mkiso_new

Code:
#!/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
Code:
#!/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:

Code:
[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
 
Old 10-11-2004, 07:08 AM   #2
MrBrain
LQ Newbie
 
Registered: Oct 2004
Posts: 6

Rep: Reputation: 0
Isn't "mkisofs_args="-R -o ${ISO_FILE}..." supposed to be "mkisofs_args="-R -o $ISO_FILE..."?
 
Old 10-11-2004, 07:12 AM   #3
mirradric
Member
 
Registered: May 2004
Location: Singapore
Distribution: Debian woody and debian sarge
Posts: 188

Rep: Reputation: 31
Quote:
Originally posted by lindsven
Isn't "mkisofs_args="-R -o ${ISO_FILE}..." supposed to be "mkisofs_args="-R -o $ISO_FILE..."?
Should be equivalent.
 
Old 10-11-2004, 07:37 AM   #4
satimis
Senior Member
 
Registered: Apr 2003
Posts: 3,426

Original Poster
Rep: Reputation: 53
Hi folks,

Tks for your advice. Problem still remains intact.

Made following change;
$ cat mkiso_new
Code:
#!/bin/sh

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

mkisofs_args="-R -o $ISO_FILE -l -hide-rr-moved .....
# ./mkiso_new /home/satimis/Working/
Remaining arguments /home/satimis/Working/
Adding /home/satimis/Working/
# ls /home/satimis/To_burn/
No printout
# ./mkiso_new /home/satimis/Working
Remaining arguments /home/satimis/Working
Adding /home/satimis/Working
# ls /home/satimis/To_burn/
No printout
# find / -name Image.iso
find: /proc/2665/task: No such file or directory

The funny thing is why it worked once only.

B.R.
satimis
 
Old 10-11-2004, 07:56 AM   #5
mirradric
Member
 
Registered: May 2004
Location: Singapore
Distribution: Debian woody and debian sarge
Posts: 188

Rep: Reputation: 31
First, you seem to be missing the -graft-point argument to mkisofs.
2nd, the arugments to mkiso_new cannot end with / or else you can't get the part for the left side of =

Last edited by mirradric; 10-11-2004 at 08:04 AM.
 
Old 10-11-2004, 09:58 AM   #6
satimis
Senior Member
 
Registered: Apr 2003
Posts: 3,426

Original Poster
Rep: Reputation: 53
Hi mirradric,

Tks for your advice.
Quote:
First, you seem to be missing the -graft-point argument to mkisofs.
Added "-graft-point"

$ cat mkiso_new
Code:
#!/bin/sh

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

mkisofs_args="-R -o $ISO_FILE -l -graft-point -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
Quote:
2nd, the arugments to mkiso_new cannot end with / or else you can't get the part for the left side of =
# ./mkiso_new /home/satimis/Working
Remaining arguments /home/satimis/Working
Adding /home/satimis/Working
[root@localhost satimis]# ls /home/satimis/To_burn/
No printout
[root@localhost satimis]# ./mkiso_new /home/satimis/Document
Remaining arguments /home/satimis/Document
Adding /home/satimis/Document
[root@localhost satimis]# ls /home/satimis/To_burn/
No printout
[root@localhost satimis]# find / -name Image.iso
find: /proc/2591/task: No such file or directory

One thing I can't resolve.

# ./mkiso_new /home/satimis/Working
Remaining arguments /home/satimis/Working
Adding /home/satimis/Working

only worked once having created an Image.iso. It never works again.

B.R.
satimis
 
Old 10-11-2004, 11:01 AM   #7
satimis
Senior Member
 
Registered: Apr 2003
Posts: 3,426

Original Poster
Rep: Reputation: 53
Hi folks,

Further to my last posting, following script works without problem

[satimis@localhost satimis]$ cat mkiso_01.iso
Code:
#!/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
Code:
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
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
seeking advice regarding Slackware adityavpratap Slackware 25 10-20-2005 11:47 AM
Seeking advice on HP printer selection satimis Fedora 0 02-22-2005 06:52 AM
Seeking advice for size optimiztion praj_linux Programming 5 10-11-2004 11:02 PM
Seeking advice on script satimis Programming 1 10-05-2004 03:02 PM
Seeking Diagnosis Advice... verbal Linux - Hardware 2 09-12-2003 06:11 AM


All times are GMT -5. The time now is 03:09 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration