New To Mac-Forums?

Welcome to our community! Join the discussion today by registering your FREE account. If you have any problems with the registration process, please contact us!

Get your questions answered by community gurus Advice and insight from world-class Apple enthusiasts Exclusive access to members-only contests, giveaways and deals

Join today!

 
Start a Discussion
 

Mac-Forums Brief

Subscribe to Mac-Forums Brief to receive special offers from Mac-Forums partners and sponsors

Join the conversation RSS
OS X - Development and Darwin Discussion and questions about development for Mac OS X.

Mac Script Problems


Post Reply New Thread Subscribe

 
Thread Tools
xXRiLeYXx

 
Member Since: Jan 21, 2012
Posts: 3
xXRiLeYXx is on a distinguished road

xXRiLeYXx is offline
Okay. I will say that I came from another forum searching for help, as no one there really knows anything about Mac scripts, but seem to know everything else about FreeBSD, Linux, and of course Windows.

I know many languages including those like C++ and Java, and I know a bit about the Mac syntax and a couple of it's commands, but I am stumbling when it comes to this script as I have never written a shell script for mac.

Can someone please help me and tell me what I am doing wrong?

Code:
#!/bin/bash
echo Enter Username:
read user
sudo dscl localhost -read /Search/Users/$user | grep GeneratedUID | cut -c15-
echo Copy above line for GUID:
read guid
sudo cat /var/db/shadow/hash/$guid | cut -c169-216
echo Above is the mac hash...
Any help is appreciated.
QUOTE Thanks
vansmith

 
vansmith's Avatar
 
Member Since: Oct 19, 2008
Location: Toronto
Posts: 17,757
vansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond repute
Mac Specs: 2012 13" MBP (2.5 i5, 8GB)

vansmith is offline
I'm not sure why the *nix people couldn't help since you're writing a bash script. Anyway...

You'll have to be a little more specific. What about the above isn't working? What are you trying to accomplish and what are you getting when you run this?

Important Links: Community Guidelines : Use the reputation system if you've been helped.
M-F Blog :: Write for the blog
Writing a Quality Post
QUOTE Thanks
Dysfunction

 
Dysfunction's Avatar
 
Member Since: Mar 17, 2008
Location: Tucson, AZ
Posts: 6,638
Dysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant future
Mac Specs: 2008 and 2011 15" mbps, late 11 iMac, iPhone 4s, and too many ipods and other stuff

Dysfunction is offline
/var/db/shadow/ <-- for starters does this directory exist? It doesn't on my Mac.

I also generally don't like $user, it's too close to an already defined system variable.

Additionally, I'd personally do something like :
Code:
i=sudo dscl localhost -read /Search/Users/mike | grep GeneratedUID | cut -c15-

cat $i
Instead of making the user copy/paste

mike
This machine kills fascists
Got # ? phear the command line!
QUOTE Thanks
vansmith

 
vansmith's Avatar
 
Member Since: Oct 19, 2008
Location: Toronto
Posts: 17,757
vansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond repute
Mac Specs: 2012 13" MBP (2.5 i5, 8GB)

vansmith is offline
Instead of $user, you could use the following (that's not a typo - there's no slash between /Search and $HOME since $HOME contains the slash):
Code:
/Search$HOME
Like Dys, also I don't have /var/db/shadow nor do I have /Search.

Important Links: Community Guidelines : Use the reputation system if you've been helped.
M-F Blog :: Write for the blog
Writing a Quality Post
QUOTE Thanks
Dysfunction

 
Dysfunction's Avatar
 
Member Since: Mar 17, 2008
Location: Tucson, AZ
Posts: 6,638
Dysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant future
Mac Specs: 2008 and 2011 15" mbps, late 11 iMac, iPhone 4s, and too many ipods and other stuff

Dysfunction is offline
yea, but you will get results from

sudo dscl localhost -read /Search/Users/$USER



Oh and other than that.. No, I will not help you parse out and decrypt a password.

mike
This machine kills fascists
Got # ? phear the command line!
QUOTE Thanks
xXRiLeYXx

 
Member Since: Jan 21, 2012
Posts: 3
xXRiLeYXx is on a distinguished road

xXRiLeYXx is offline
Well, I don't care about that, I know how to do it. I was just looking for a faster way...
But okay...
QUOTE Thanks
vansmith

 
vansmith's Avatar
 
Member Since: Oct 19, 2008
Location: Toronto
Posts: 17,757
vansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond repute
Mac Specs: 2012 13" MBP (2.5 i5, 8GB)

vansmith is offline
Quote:
Originally Posted by xXRiLeYXx View Post
Can someone please help me and tell me what I am doing wrong?
Quote:
Originally Posted by xXRiLeYXx View Post
Well, I don't care about that, I know how to do it. I was just looking for a faster way...
But okay...
Is there something wrong or do you want a quicker way? Care to explain what it is that you're trying to accomplish? Knowing this will help make this a quicker process.

Important Links: Community Guidelines : Use the reputation system if you've been helped.
M-F Blog :: Write for the blog
Writing a Quality Post
QUOTE Thanks
Dysfunction

 
Dysfunction's Avatar
 
Member Since: Mar 17, 2008
Location: Tucson, AZ
Posts: 6,638
Dysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant future
Mac Specs: 2008 and 2011 15" mbps, late 11 iMac, iPhone 4s, and too many ipods and other stuff

Dysfunction is offline
Quote:
Originally Posted by xXRiLeYXx View Post
Well, I don't care about that, I know how to do it. I was just looking for a faster way...
But okay...
If you knew how to do it, scripting it would be a simple matter of passing the same commands. Without knowing what the failing point is, it's impossible to tell you what you're doing wrong. Although, since you're running sudo commands, you're not in an environment where you can access what you want to.

mike
This machine kills fascists
Got # ? phear the command line!
QUOTE Thanks

Post Reply New Thread Subscribe


« Slightly Better authorization sample fails only in Leopard | Programming C on Xcode »
Thread Tools

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread
Thread Starter
Forum
Replies
Last Post
Three tremendous problems with my Mac. Please help me. (long read) DismantleDesign Apple Notebooks 4 02-23-2010 04:52 PM
Need to know how much RAM your Mac can hold? iLaugh Other Hardware and Peripherals 6 12-13-2009 01:49 PM

All times are GMT -4. The time now is 02:35 AM.

Powered by vBulletin
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
X

Welcome to Mac-Forums.com

Create your username to jump into the discussion!

New members like you have made this community the ultimate source for your Mac since 2003!


(4 digit year)

Already a member?