You are not logged in.
Hey there. Any ideas how I could use a bash script to automatically mount an iso? For example if I click on an iso file in rox then it'll mount it to /mnt/iso? Iv'e tried setting up a file /usr/bin but I can't seem to get it figured out. I know the command is this
mount -t iso9660 -o loop,ro my.iso /my/mountpoint
and that works swimmingly from within a term. It's just a pain having to type it out every time. And I can never remember it.
Hopefully this is possible as I found a bash script today to view all the pictures within an archive in imagmagick. Which is incredibly useful.
Thanks, hope this makes sense
*edit* just found this but you need to be root, has a naff gui, and uses KDE.... But it's a start.
#! /usr/bin/env bash
mountdir=`kdialog --inputbox "Enter directory name to mount iso to"`;
if [[ ! -e "$mountdir" ]]; then
kdialog --yesno "Directory does not exist, create it?" && mkdir "$mountdir";
if [[ ! -e "$mountdir" ]]; then
echo "Cannot mount iso image.";
exit 1;
fi
fi
mount -t iso9660 -o loop "$1" "$mountdir";
Offline
You could add this to your .bashrc file.
mountiso() {
if [ "`mount | grep /mnt/iso`" ]; then
echo "/mnt/iso is already in use"
return
fi
if [ ! "$1" ]; then
echo "missing iso image argument"
return
fi
if [ ! -f $1 ]; then
echo "$1: iso image not found"
return
fi
mount -t iso9660 -o loop,ro $1 /mnt/iso
}
Usage would be 'mountiso my.iso'.
This has the /mnt/iso hardcoded, but you could easily pass that it and use $2 as the second argument. NOTE: Spacing/quoting is VERY important in bash scripting; you're better of copy/pasting this than retyping it. Oh, and I didn't really test it either...
Follow the link below, sign up, and accept one promotional offer. If I can get five suckers (err... friends) to do this, I'll get a free iPod. Then you too can try to get a free iPod. Thanks! http://www.freeiPods.com/?r=11363142
Offline
cheers
Offline