Adding users from a txt fille


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Adding users from a txt fille
# 8  
Old 10-14-2014
Thanks, I'll test this code
# 9  
Old 10-17-2014
Quote:
Originally Posted by Akshay Hegde
password=$(perl -e 'print crypt($ARGV[0], "password")' $password)
Hello, I am quite new to linux and was wondering what this line of code did?

Thank you very much!
# 10  
Old 10-17-2014
password= Assignment to a shell variable
$() call to a subprocess
perl -e call the perl binary to execute code from command line, instead of file source code
'print crypt($ARGV[0], "password")' display the result of calling the perl function crypt
crypt($ARGV[0], "password") crypt will return a digest of whatever was given as argument. $ARGV[0] is the first argument from the command line, in this case the last $password term. "password" is what's called SALT string. It can be anything. Not to confuse with $password
$password Argument given at the command line, in the form of perl variable, to crypt (presumably a string that represents a clear text password)

Best way of learn is to try:
Change password and random_text to anything you want
Code:
perl -e 'print crypt("password", "random_text")'


Last edited by Aia; 10-17-2014 at 06:02 PM.. Reason: More
These 2 Users Gave Thanks to Aia For This Post:
# 11  
Old 10-21-2014
Quote:
Originally Posted by roghde
Hello, I am quite new to linux and was wondering what this line of code did?

Thank you very much!

Another solution is to use openssl to generate encrypted passwords (it automatically chooses salt values for you, but you could duplicate what the perl code was doing by usint the -salt pa option

Code:
password=$(openssl passwd "$password")

Code:
password=$(openssl passwd -salt pa "$password")

Notice how the $password variable is quoted above, this is to protect against white space in the password.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Adding Extra Column in txt file base on Condition

HI Guys, I have below input. Output Base on Below Condition. 1> if forth column is empty and next coming line have same name with \es then add that column name on all rows 2>rest of all are es:vsDataEUtranCellFDD Input:- CCL01736 CCL01736_7A_1 es:vsDataEUtranCellFDD ... (3 Replies)
Discussion started by: pareshkp
3 Replies

2. Shell Programming and Scripting

Simple script for adding users

Hi guys, I've a simple linux script (made by my friend), which adds users to the system from userlist file. it also creates user home dir and copies certain files to the directory. To be honest, am a newbie in scripting so am unable to fully understand how the script is working. unfortunately,... (30 Replies)
Discussion started by: vish6251
30 Replies

3. UNIX for Dummies Questions & Answers

Adding new columns to txt files

Dear all, I have a question. I have a txt.file as below. i want to add 3 more columns: column3=conlum 2*column2; column4=(1-column2)*(1-column2); column5=1-column3-column4. Do you know how to do it? Thanks a lot! file: column1 column2 a 1 b 20 c 30 d 3 ... (2 Replies)
Discussion started by: forevertl
2 Replies

4. AIX

adding users via smit

I apologize if this is a simple/stupid question. When I add users in smit as root, many(most) of the fields are automatically popluated with some basic default values. Some other admins here have access to create users via sudo, however when they create users (sudo smit users), the user gets... (3 Replies)
Discussion started by: mshilling
3 Replies

5. AIX

Adding column in a .txt file

Helle, I want to create a .ksh script in order to realize the following : I have a .txt file organized in a bloc of information, each bloc start with 000 as following: 000... 001... 003... 004... 000... 001... 003... 004... . . My aim is to add a new... (6 Replies)
Discussion started by: zainab2006
6 Replies

6. UNIX for Dummies Questions & Answers

Adding users question

Hello there, I want to add new users to my system, so, being logged in as root I do useradd -m user_name, and the new user is added to the system. The problem is that it has more privileges than I expected. If I do su user_name then I am allowed to do cat /etc/passwd , so it is... (4 Replies)
Discussion started by: help.goes.here
4 Replies

7. UNIX for Dummies Questions & Answers

Adding EMPTY columns to Tab-delimited txt file

Hi I have a txt file with 4 columns where I need to add 4 empty columns in the middle meaning that I need what is currently column 4 to be column 8 in a new file. The idea is that I have to use the file as input in a program that reads the data in column 1 and 8, so the content of the other... (8 Replies)
Discussion started by: Banni
8 Replies

8. Shell Programming and Scripting

Adding delimiter to logged in users

Hi guys! Just was wanting to run a command that would allow me to seperate the currently logged in users. Basically from this format: user1 user2 user3 To: user1|user2|user3 (Note the lack of a pipe at the end, not sure if thats possible) Basically it needs to be in this... (11 Replies)
Discussion started by: crawf
11 Replies

9. UNIX for Dummies Questions & Answers

Adding users to /etc/group

I'm using SAM to add users on an HP and they're adding fine. But in /etc/group it only lists the group names. It's not adding the users in there. Is there a way to have them put in there without going into SAM and modifying the group and adding them? I guess what I want to happen is when I add... (1 Reply)
Discussion started by: golfhakker
1 Replies

10. Shell Programming and Scripting

Adding users

Anyone have a simple shell script that will prompt and accept screen input for each field that is required in the /etc/passwd file? (3 Replies)
Discussion started by: Relykk
3 Replies
Login or Register to Ask a Question