Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8017381
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T20:49:46+00:00 2026-06-04T20:49:46+00:00

I’m creating a system that allow me to create users automatically after an inscription.

  • 0

I’m creating a system that allow me to create users automatically after an inscription. In this way, i’ve made a Perl script that generate a random password, crypt it with “mkpasswd” and then create an user with “useradd”, after that user-infos are sended to a database.

I’ve search documentation, and i’ve try to use the php exec function to call the Perl program.

$command = "/server/backoffice/scripts/usercreation.pl $username";
exec($command, $result);
print_r($result);

The usercreation.pl script work fine in a terminal, but for a unknown reason, it just not work from php, nothing happen, i know that the problem come from the useradd syntax or if not it come from the useradd command. The error value returned is 255 <=> 0xff <=> -1 .

I think the problem come from the –password option of useradd, in fact, this option use mkpasswd and maybe it could disturb the shell or something else like that :p

The complete useradd command used by the Perl program:

system("/usr/sbin/useradd $username -m -d $home --expiredate $expire --shell $shell --gid $gid --password $c_password");

EDIT:
The usercreation.pl file on pastebin (has been truncated to the part we are investigate):
http://pastebin.com/DgFdndXf

The php one :
http://pastebin.com/pQhADNzg

The web server used is nginx/0.7.65.

The version of php used is PHP 5.3.3-1.

uname -a

Linux openco 2.6.35-32-generic #67-Ubuntu SMP Mon Mar 5 19:35:26 UTC 2012 i686 GNU/Linux

Thanks for all!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T20:49:48+00:00Added an answer on June 4, 2026 at 8:49 pm

    The useradd must be run as root, so you will need sudo to specify that nginx can run your script as root.

    Be extremely careful with this stuff; make sure you sanitize user names and escape your command properly as well using escapeshellarg().

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm trying to create an if statement in PHP that prevents a single post
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
Basically, what I'm trying to create is a page of div tags, each has
this is what i have right now Drawing an RSS feed into the php,
I've got a string that has curly quotes in it. I'd like to replace

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.