Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Bad bash shell script has me stumped...
Message
General information
Forum:
Linux
Category:
Other
Miscellaneous
Thread ID:
00448801
Message ID:
00450510
Views:
26
>>>> if [ "$username" != "" -a "$password" != "" ]; then
>>>> useradd $username
>>>> echo $username:$password | chpasswd
>>>
>>>Again, I would do away with the echo and just say: chpasswd $username:$password
>>
>>I'll try that... it looks cleaner. But, I still have to get the 'if' statement syntax correct, and for
>>the life of me I can't see any errors.
>
>You could try taking out the semi colon and putting the 'then' on the next line.
>
>>>> else
>>>> echo "$username" >> /tmp/importerror.log
>>>
>>>How about losing the "'s? =) Does importerror.log exist?
>>
>>What 's'?
>
>Not 's'. I meant for that to read Quotation Mark's. =)
>
>j

I tried removing the ";" and putting the 'Then' on the next line. No joy.
I also tried it with and without the question marks. No joy.
I think it has something to do with the piping interfering with the If test.
When I remove the test and run the script everything works with one exception:
useradd won't add a user that has only a 5 digit number for a name. You can
add users with integer names using Kmuser, but I haven't found a way to get
useradd to accept them...
Any ideas?
JLK
Nebraska Dept of Revenue
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform