OSX verify username and password in one line

I'm writing a script that has the need to verify the current user's username and password. I'm not entirely sure how to do this. I've read some things on "dscl" but am not sure that's the correct route for me to go.

The one condition i have is that i really need to have the verification happen in one line of code. I'm using a different scripting language (MEL) to execute the bash terminal command, so being prompted to enter a password doesn't really help me.

Appreciate any help!!Thanks!!

-drizzle

(I should mention Unix is not my native scripting language. I'm not a complete idiot when it comes to unix, but elaboration on any answers would be more than appreciated!)

*edit: I should have been clearer.. i have the username and password stored as a variable, i just need to verify that they are correct.

MEL used to be the maya embedded scripting language. What does that have to do with a bash terminal command? It sounds like you need the MEL syntax to execute a bash script or command.

I do not know MEL - you get to figure out how to execute something like this native UNIX statement:

/bin/bash -c '/folder/to/myscript.sh foo bar'

where foo is the valid username and bar is the valid password. And be able to see the status return code of the script a 1 (one) or a 0 (zero).

script lives in /somefolder/somewhere/you/put/it, with file permissions 755:

#!/bin/bash
trap 'exit 1' INT
echo -n 'Enter username: '
read u
echo -n 'password: '
read p
[[ "$1" = "$u"  && "$2" = "$p" ]] && exit 0 
exit 1

myscript.sh does all the stuff you cannot do in "one line", it has a status code of 0 if all is well, 1 otherwise.

Plus - as a wild guess - I believe that your question is probably ill-formed. There must be a way to run your MEL script process from bash itself under maya, maya is an executable. You are already running MEL.

You could construct your password query there, since you appear to have a hard-coded password and username anyway. Then either run or not run the entire maya/app/scripts bundle.
partial bash/Pseudocode ( I know nothing about maya)

#!/bin/bash
password=bar
username=foo

trap 'exit 1' INT
echo -n 'Enter username: '
read u
echo -n 'password: '
read p
[[ "$1" != "$username"  || "$2" != "$password" ]] && exit 1
# run maya bundle here
maya blah blah

Thank you for the quick reply, I think I didn't explain myself very well.

Basically, I built a UI in Maya. Within that UI the user will enter a UserName and a Password into their appropriate fields. What I'm trying to achieve is a way verify that the user and pass entered are actually valid and not misspelled or just plain wrong.

I am using Maya's "system" function to execute unix commands from within maya. That's why a one line verification would be best.

As far as i can tell there's no way for me to answer a prompt using this method. So for example i can't enter the username and then wait for a prompt to enter the password. Whatever command i send from maya to the terminal, it has to have a return answer of some kind.

Thanks

The system is designed to make this difficult, because the functionality you want would be as convenient for malicious password bruteforcing as it would be for more benign purposes. The system goes to some length to guarantee that password prompts get typed into by human beings in realtime. You may need the third-party expect brute-forcing tool to make it possible to hijack them so they aren't.

If you do get it working, it may be a severe security hole because of the way things in ps are liable to show their commandline parameters.

That's a real bummer. Makes a lot of sense though I guess. Thanks for your quick reply!

-Drizzle