[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
ubuntu shell script help
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /g/ - Technology

Thread replies: 27
Thread images: 2
File: full script.png (424 KB, 1502x1042) Image search: [Google]
full script.png
424 KB, 1502x1042
hey /g/
so im pretty new into the whole Linux/shell script thing. and so ive been practicing making shell scripts. now im trying to create a shell script that adds new user. ive done most of the script and it all runs fine except the password part. whenever a new user is created i cant login in with the password, it always returns with incorrect password error. any thoughts and help?
also no bully pls
and stop anything else please do tell xo
>>
>>52018881
I think #bash (the bash channel) on freenode is a better place to ask cuz they know bash inside out and they have good documentation. You can use Xchat to get on freenode.
>>
also the code if you want it or want to add something to it

clear


if [ "$EUID" -ne 0 ]

then echo "Please run as root"

exit

fi


while [ x$username = "x" ]; do

read -p "Please enter the username you wish to create: " username

read -s -p "Enter password: " password

if id -u $username >/dev/null 2>&1; then

echo "User already exists"

username=""

fi

done


while [ x$group = "x" ]; do

read -p "Please enter the group you would like to be in. If that group doesn't exist it will be made: " group

if id -g $group >/dev/null 2>&1; then

echo "Group exist"

else

groupadd $group

fi

done


read -p "Please confirm [y/n] " confirm

if [ "$confirm" = "y" ]; then

useradd -g $group -m $username

chage -d 0 $username

fi

exit

>>
>>52018957
ill try that too. thanks
>>
>>52018881

To see if the password is being inputted correctly, add in a:
echo $password >> $HOME/Password


See if there's an extra space being added in or something.
>>
File: 2015-12-23-221814_1366x768.png (92 KB, 1366x768) Image search: [Google]
2015-12-23-221814_1366x768.png
92 KB, 1366x768
>>52018881
You need -r with read to read in the password and username otherwise backslashes will get mangled. Also you should quote the variable names to prevent word splitting. Please visit #bash if you are serious about shell.

https://github.com/koalaman/shellcheck/wiki/SC2034

shellcheck.net
>>
no one is helping m3 :(
>>
>>52019158

Are you fucking blind?
>>
>>52019158
My negro friend, please look at this post >>52019131
>>
>>52019212
>>52019168
>>52019158
im sorry guys the internet is being a little weird :) ;( :)()(:( :):D
>>
>>52019275

It's okay anon.
>>
>>52019021
can you post on pastebin where to put it?
>>
>>52018957
>You can use Xchat to get on freenode.

Weechat or issr is better because it's like a command line interface. Which is more good looking.
>>
>>52019293
>not same fag
Really? You're just going to output that fucking password to a file so you can read it, after running the fucking script.

If that doesn't make sense, go read a book.
>>
>>52019312
>Weechat
i just need help desu
>>
>>52019312
Yeah, weechat is nice.
>>
>>52019293

You can put it at the end of the script.
>>
>>52019561
ill try that now brother
>>
>>52019343
Don't worry, we can probably help you. but you might check out IRC. Tried it out recently again for first time in like 15-17 years and people still use it. mostly tech people, programmers, hackers and that sort of thing, but great for real time tech help.
>>
>>52018881
https://fixubuntu.com
>>
thanks for all the new resources brothers and sisters
>>
why are you putting x in front of the variables for the condition check?
>>
>>52019757
honestly, i dont know. i found some of the code online.
>>
>>52018881
>using nano unironically
>>
>>52019867
thanks senpai
>>
>>52019312
>not using ERC
>>
ive fixed it. thank you bros :)
Thread replies: 27
Thread images: 2

banner
banner
[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y] [Home]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.