ok, complete beginner here looking for a bit of help.
I have a bash script to unmount one of my volumes without me having to go into Diskutil. It works fine when entering from the command line within terminal, showing results as it goes.
I've attempted to write an applescript to run the terminal and execute the command. After a few seconds it does unmount the volume (without showing results in the terminal) but then Applescript gets an error saying the volume failed to unmount.
Any ideas would be greatly appreciated.
APPLESCRIPT:
tell application "Terminal"
activate
do shell script "disk"
end tell
tell application "Terminal"
quit
end tell
Here is the BASH Script:
#!/bin/bash
##
# Mount/Unmount disks by Volume Name
##
if [ -z "dWerx" ] ; then
echo "usage : disk dWerx"
echo "Mounts dWerx if it's not mounted, and"
echo "unmounts it if it is already mounted."
exit 1
fi
NAME=dWerx
PART=`diskutil list|grep "$NAME"|awk '{print $NF}'`
if [ -z `ls -1 /Volumes/ | grep "$NAME" | awk '{print $NF}'` ] ; then
##
# check that PART appears to be a disk partition
##
echo Checking $NAME $PART
if [ `file /dev/$PART | awk '{print $2}'` = "block" ]; then
echo Mounting $NAME $PART
diskutil mount /dev/$PART
else
echo /dev/$PART does not appear to be a disk partition - exiting
exit 1
fi
else
echo unmounting $NAME $PART
diskutil unmount /Volumes/"$NAME"
fi
Thanks,
Daz
I have a bash script to unmount one of my volumes without me having to go into Diskutil. It works fine when entering from the command line within terminal, showing results as it goes.
I've attempted to write an applescript to run the terminal and execute the command. After a few seconds it does unmount the volume (without showing results in the terminal) but then Applescript gets an error saying the volume failed to unmount.
Any ideas would be greatly appreciated.
APPLESCRIPT:
tell application "Terminal"
activate
do shell script "disk"
end tell
tell application "Terminal"
quit
end tell
Here is the BASH Script:
#!/bin/bash
##
# Mount/Unmount disks by Volume Name
##
if [ -z "dWerx" ] ; then
echo "usage : disk dWerx"
echo "Mounts dWerx if it's not mounted, and"
echo "unmounts it if it is already mounted."
exit 1
fi
NAME=dWerx
PART=`diskutil list|grep "$NAME"|awk '{print $NF}'`
if [ -z `ls -1 /Volumes/ | grep "$NAME" | awk '{print $NF}'` ] ; then
##
# check that PART appears to be a disk partition
##
echo Checking $NAME $PART
if [ `file /dev/$PART | awk '{print $2}'` = "block" ]; then
echo Mounting $NAME $PART
diskutil mount /dev/$PART
else
echo /dev/$PART does not appear to be a disk partition - exiting
exit 1
fi
else
echo unmounting $NAME $PART
diskutil unmount /Volumes/"$NAME"
fi
Thanks,
Daz