Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

zeppenwolf

macrumors regular
Original poster
Nov 17, 2009
129
3
All I want is the name of the startup drive as it appears on the desktop.

'set' has nothing, 'bless' is about doing, not reading, google gets me only 'how to make a bootable USB drive'...

Thx.
 
Wow, well I'm glad I asked-- I would never have got there. At first, it seemed really odd to me that we have to go to AS to get the answer...

But perhaps UNIX doesn't really have the concept of a 'startup drive', so maybe it really is natural..?

Anyway, thanks for that.
 
Wow, well I'm glad I asked-- I would never have got there. At first, it seemed really odd to me that we have to go to AS to get the answer...

But perhaps UNIX doesn't really have the concept of a 'startup drive', so maybe it really is natural..?

Anyway, thanks for that.

It does only it is called the root of the system you could find it using the mount command.

Code:
MacUser2525:~$ mount
/dev/disk4s2 on / (hfs, local, journaled)
devfs on /dev (devfs, local, nobrowse)
/dev/disk3s2 on /Volumes/WD_1 (hfs, local, journaled)
/dev/disk2s2 on /Volumes/WD_3 (hfs, local, journaled)
/dev/disk0s2 on /Volumes/WD_2 (hfs, local, journaled)
/dev/disk5s2 on /Volumes/WD_4 (hfs, local, journaled)
/dev/disk1s2 on /Volumes/Mavericks_GM (hfs, local, journaled)
/dev/disk1s4 on /Volumes/Mavericks_Clone (hfs, local, journaled)
/dev/disk1s5 on /Volumes/Sea_To_Do (hfs, local, journaled)
/dev/disk1s6 on /Volumes/Mavericks_TMBack (hfs, local, journaled)
map -hosts on /net (autofs, nosuid, automounted, nobrowse)
map auto_home on /home (autofs, automounted, nobrowse)

Since it seems to list the root first then this would get you to start up drive/volume.

Code:
MacUser2525:~$mount | cut -d ' ' -f 1 | head -n 1
/dev/disk4s2
 
Wow, well I'm glad I asked-- I would never have got there. At first, it seemed really odd to me that we have to go to AS to get the answer...

But perhaps UNIX doesn't really have the concept of a 'startup drive', so maybe it really is natural..?

Anyway, thanks for that.

You're welcome.

I don't understand why you'd think it's odd to use AppleScript. It has the capability, it works the same across a broad range of OS versions (since you didn't specify), and it's a single command. There are other ways of getting the info, but I think they're all more complex. For example, the output of 'bless --getBoot' identifies the device-name, the output of 'diskutil list' shows all partitions with names and devices, and an 'awk' program could be written to parse diskutil's output. But why do that when AppleScript has the feature immediately available?

Also, I don't know what programming language you're using that has getStartupVolumeName() as a function. It's not in C or Objective-C, AFAICT.
 
Here's my contribution to solve the problem as stated. A bash function...

Code:
function getStartupVolumeName() { mount | grep "on / " | cut -f1 -d' ' | xargs diskutil info | grep "Volume Name" | perl -an -F'/:\s+/' -e 'print "$F[1]"'; }

This is not the only way to do it, but it does work...

Code:
mac$ getStartupVolumeName
Macintosh HD

If you issue the 'set' command, you will see the function show up. So, is that as clean as the oascript version? :p
 
chown33> I don't understand why you'd think it's odd to use AppleScript

Agreed, but I didn't say that. I said that I found it odd that "that we have to go to AS", which is very different.

IOW, what I found surprising is only that UNIX does not have a one-step or even a two-step solution, ( and probably my surprise is due to my Macentricity ). Your solution requires 3 bash commands and two pipes... mfram's, well... Holy cow!


chown33> I don't know what programming language you're using that has getStartupVolumeName()

Sorry, that was my attempt to cram into the Subject line what I wanted to exist, not what I wanted translated. Why I chose a C/ObjC type of name, well, that's perhaps my Ccentricity...

Anyway, FWIW, the script I was working on is a success, although my desire to get the Startup Volume Name was a fairly silly case of barking up the wrong tree.

I saw an applescript on the web which Hides All Desktop Icons, next to one which UnHides... I was annoyed that they were separate scripts taking up double space in the Services menu, and I wanted to create one script which would toggle between states. And it works! But of course I went bash instead of AS. For posterity:

Code:
#!/bin/bash

# have to exand the ~
deskPath=~/Desktop

# query any, the first, item listed on Desktop
firstItemOnDesk=`ls -1 $deskPath | head -1`

# test for existence of string "hidden" in ls output
lsString="`ls -dOl "${deskPath}/$firstItemOnDesk" | grep hidden`"

# hiddenB ? show : hide
if [ -n "$lsString" ]; then
        chflags nohidden ~/Desktop/*
else
        chflags hidden ~/Desktop/*
fi
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.