Hello all! I am fairly new to linux. I am using fedora7 bash. I am using an awk statement to extract several fields from a file and assign them to variables within awk. With some fields in that file and some variables made within awk i would like to use useradd and set specifications for the account. Via the command line i can successfully add the user by manually adding in information however i would like to use the information from the text file. I need to know what is the syntax for using useradd within awk. So far, my code looks like this

system("useradd -G " var1 " -g " var2 " -m -s "$1" -u "$2" -K PASS_MIN_LEN=4 -K PASS_MAX_LEN=7 -p "*" "usrname")

i know this syntax is off but i just dont know how to use it within awk. Please help

simply assign to a variable first

cmd = "useradd -G " var1 " -g " var2 " -m -s " $1 " -u " $2 " -K PASS_MIN_LEN=4 -K PASS_MAX_LEN=7 -p \047*\047" "usrname"
print cmd # to see if your cmd is correct
system(cmd)
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.