Results 1 to 8 of 8
  1. #1


    Member Since
    Jan 21, 2012
    Posts
    3
    Mac Script Problems
    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.

  2. #2

    vansmith's Avatar
    Member Since
    Oct 19, 2008
    Location
    Toronto
    Posts
    19,782
    Specs:
    2012 13" MBP (2.5 i5, 8GB)
    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

  3. #3

    Dysfunction's Avatar
    Member Since
    Mar 17, 2008
    Location
    Tucson, AZ
    Posts
    6,881
    Specs:
    Way... way too many specs to list.
    /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!

  4. #4

    vansmith's Avatar
    Member Since
    Oct 19, 2008
    Location
    Toronto
    Posts
    19,782
    Specs:
    2012 13" MBP (2.5 i5, 8GB)
    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

  5. #5

    Dysfunction's Avatar
    Member Since
    Mar 17, 2008
    Location
    Tucson, AZ
    Posts
    6,881
    Specs:
    Way... way too many specs to list.
    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!

  6. #6


    Member Since
    Jan 21, 2012
    Posts
    3
    Well, I don't care about that, I know how to do it. I was just looking for a faster way...
    But okay...

  7. #7

    vansmith's Avatar
    Member Since
    Oct 19, 2008
    Location
    Toronto
    Posts
    19,782
    Specs:
    2012 13" MBP (2.5 i5, 8GB)
    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

  8. #8

    Dysfunction's Avatar
    Member Since
    Mar 17, 2008
    Location
    Tucson, AZ
    Posts
    6,881
    Specs:
    Way... way too many specs to list.
    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!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Terminal -- shell script -- script will only read two lines of a file
    By Straitsfan in forum OS X - Apps and Games
    Replies: 0
    Last Post: 01-30-2011, 10:04 PM
  2. Running a script within Mac 10.6
    By hso in forum OS X - Operating System
    Replies: 2
    Last Post: 11-23-2010, 09:01 PM
  3. Perl Script Problems
    By marvelaz in forum OS X - Development and Darwin
    Replies: 3
    Last Post: 01-18-2010, 10:54 PM
  4. Really Need Help Regarding MAC Script
    By MACSCRIPT in forum OS X - Apps and Games
    Replies: 2
    Last Post: 08-13-2008, 08:15 AM
  5. Mac script.
    By iBox in forum OS X - Apps and Games
    Replies: 8
    Last Post: 04-22-2008, 09:10 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •