Getting info after running a command

E

Evil Homer

Guest
I was wondering if there is any way to retrieve information that is output by the computer in the terminal and then use that information in a later command automatically? I am trying to write a script that will unmount the volume and then wipe the drive. I know that I need to type mount and then I need the informaiton from /dev/disk0s*, where the star varies from computer to computer and mount tells me what that number is on that particular computer. I need someway to get that number with a script and then use it in a dd command. Anyone know how to get that number? Thanks
 

rman


Retired Staff
Joined
Dec 24, 2002
Messages
12,637
Reaction score
168
Points
63
Location
Los Angeles, California
Your Mac's Specs
14in MacBook Pro M1 Max 32GB 2TB
I have several questions for you. When you say wipe the disk, I am assuming that you want to format the disk (initialize).

How many disks are there on each system?
How many systems are you going to run this script on?
Are the disk to be wiped have the same name for the disk?

And since you are using the dd command, it does not appears that you are doing a wipe, but a dump.

What I am trying to do is walk you through creating this script you want, because I think there is a better method, than the way you are going.
 
OP
E

Evil Homer

Guest
I am trying to scrub all information from the drive. There is only 1 disk on each system. I am going to run this script on every computer that is going to be redistributed. The disk can have the same name when it is done.

I am open to learn a new method, but usind the dd command is the one that I have been told to use, but if you have a better way that would be cool.
 

rman


Retired Staff
Joined
Dec 24, 2002
Messages
12,637
Reaction score
168
Points
63
Location
Los Angeles, California
Your Mac's Specs
14in MacBook Pro M1 Max 32GB 2TB
I don't know if this works in OS X, I have use it in other favors of unix.

The command mkfs would be easier to use than dd as in mkfs /dev/disk0s14. This would create a new file system on the raw partition of /dev/disk0s14.

Okay, first step how are you getting the line of information that you want to parse the number of the disk from?

I am asking this because I do most of my shell scripting in IRIX and AIX.
 
OP
E

Evil Homer

Guest
I was going to use AppleScript to write the script and the line of code was "do shell script mount" That is supposed to display the information about the drive which will include the disk number.
 

rman


Retired Staff
Joined
Dec 24, 2002
Messages
12,637
Reaction score
168
Points
63
Location
Los Angeles, California
Your Mac's Specs
14in MacBook Pro M1 Max 32GB 2TB
I have not worked with AppleScript so I can not help you there.
 
OP
D

dr_springfield

Guest
Just run a command like:
"mount | grep disk | cut -d' ' -f1"
and you should have the names of the mounted HDs.
 
OP
E

Evil Homer

Guest
Okay, that command shows me only the mounted HD's, but how can I use the result of that command in another command using applescript?
 
OP
D

dr_springfield

Guest
I don't know. Forget using applescript, just write a shell script to do it, it'll be much easier. Like:
myDisk=`mount | grep disk | cut -d' ' -f1`
dowhateverto $myDisk
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top