Originally Posted By: Virtual1
partlist is the list of partitions. you're doing them explicitly one at a time, using multiple variables.

now assign all of this into a single variable called partlist:
3 APM JHFS+ "$alpha" 480M JHFS+ "$bravo" 480M JHFS+ "$charlie" R

and try to run it this way:

diskutil partitionDisk /dev/disk1 ${partlist}

Yessir, i eventually managed to divine that 'single variable' intent. (you shoulda/coulda specified those details in post #1 though)



Originally Posted By: Virtual1
The issue is, I am BUILDING the partition list, and then partitioning. The script assembles it. The number of partitions, their size, and their names, are all variable.

Great, show us the "build code" for that script. (or, preferably, the whole thing).

If you stick with that 'Swiss Army Knife' approach, you could write a shell script which prompts the user to enter the data. [ask for the number of partitions first, and use that value to set the repeat loop that collects the name/size info.] You can employ either Bash's select function (where you offer some options and the user selects one), or even an AppleScript dialog with a text box can be used (via osascript) to get text from the user. Alternatively, write the whole thing in AppleScript... and —once the variable data is all gathered —simply:

do shell script ("diskutil partitionDisk " & a & b & c & e & f & etc. )

Either way —including your own current copy/paste technique —it's a tedious process (due to having to support so many variables [as well as a varying number of variables] in such a "universal" script).



Originally Posted By: Virtual1
This requires using ONE variable, not three or ten.

I'm not convinced of that. It's all a matter of approach. I'm positive that a shell script could be designed to put those pieces "together" for diskutil without having to jam them into a single variable.

But as i also suggested: if you have (for example) three service disks, then it's probably smarter to just custom-tailor three separate saved scripts for those typical cases... instead of trying to create some monster script to handle every possible case [which is pretty much like replicating all the work that simply using Disk Utility's GUI already entails in the first place.]



Originally Posted By: Virtual1
Here's one attempt:

apple:~ v1 $ partme="diskutil partitionDisk /dev/disk2 3 APM JHFS+ \"Service Tiger\" 480M JHFS+ \"Service Leopard\" 480M JHFS+ \"Service Snow\" R"
apple:~ v1 $ echo $partme
diskutil partitionDisk /dev/disk2 3 APM JHFS+ "Service Tiger" 480M JHFS+ "Service Leopard" 480M JHFS+ "Service Snow" R
apple:~ v1 $ $partme
There appear to be too many arguments for the number of partitions you specified

Understood... but that's not a “script”. That's just copy/pasting stuff onto the command line.

Why not write and save a real shell script?... you know, to a file... with an actual name... which one could later run as a command:

dsv 4

(where 4 would be a runtime arg denoting the disk number. E.g., /dev/disk4)


The same error will still occur in saved script versions, if you try to employ that 'single variable' business. But there's no need to attempt such tricks anyway. Just assemble the parts as i did in my first post.

I still say you're better off saving several custom scripts, where the only unknown is which number to put for /dev/disk_ (or possibly one script with two unknowns: disk number and number of partitions... depending on how "diverse" those service disks are).

Last edited by Hal Itosis; 06/08/11 05:36 AM. Reason: FINAL CLEANUP (sorry)