Simple sh called by PHP to create users HELP


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Simple sh called by PHP to create users HELP
# 1  
Old 11-27-2013
Simple sh called by PHP to create users HELP

Hello! Im trying to create a shell script that will be executed by PHP like:
PHP Code:
$return shell_exec("./makeUser.sh $user $pass"); 
My shell script looks like:
Code:
#!/bin/bash

NAME=$1
PWD=$2

pass=$(perl -e 'print crypt($ARGV[0], "password")' $PWD)
useradd -m -p $pass $NAME
[ $? -eq 0 ] && echo "0" || echo "1"

The problem I having is that the user is getting created but the password is not getting set. How can I solve this issue?

Thanks
# 2  
Old 11-27-2013
I'm astonished that it even creates the user. How is this script being run? Your httpd should not have root access.
# 3  
Old 11-27-2013
I guess I forgot the sudo part on the shell_exec() and I have to enter my pass when I run this. As bad as it is the company setup http to have sudo access (im told). There is a python script that does this but there is some issues with it and no one at the office knows python or shell scripting. In short this is my poor attempt to port that code into PHP (Im also a n00b on shell scripting).
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Homework & Coursework Questions

Simple loop to mail all active users.

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: Send a fortune to all active/logged in users 2. Relevant commands, code, scripts, algorithms: So I understand... (8 Replies)
Discussion started by: kjcraig77
8 Replies

2. UNIX for Dummies Questions & Answers

Ubuntu Server - simple network and users configuration

Hello, I am new to Ubuntu Server. Can you please suggest very simple configuration to network. Need: 1. Ubuntu Server (already installed) 2. Connect to it 1 Linux Mint computer (already installed) + 1 computer with Windows 7 (already installed). Need to create 3 groups with... (2 Replies)
Discussion started by: ABQw
2 Replies

3. Shell Programming and Scripting

Create multiple users with individual passwords to users

hi, i am new to shell scripts i write a shell script to create multiple users but i need to give passwords to that users while creating users, command to write this script (1 Reply)
Discussion started by: DONFOX
1 Replies

4. 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

5. Shell Programming and Scripting

Help making simple perl or bash script to create a simple matrix

Hello all! This is my first post and I'm very new to programming. I would like help creating a simple perl or bash script that I will be using in my work as a junior bioinformatician. Essentially, I would like to take a tab-delimted or .csv text with 3 columns and write them to a "3D" matrix: ... (16 Replies)
Discussion started by: torchij
16 Replies

6. UNIX for Dummies Questions & Answers

create a file called -a

Can I create a file called '-a' in unix.Or can i open it with vi ? vi \-a will give u an error that -a is invalid option for vi. (2 Replies)
Discussion started by: Swayam
2 Replies

7. Shell Programming and Scripting

Create new users

Hi , i would like to create a new user over unix ,which are these commands to used and which are the directories to handler? Thank you (3 Replies)
Discussion started by: dimitris
3 Replies

8. UNIX Desktop Questions & Answers

How to create users on HP UX????

I new to unix and I'm using a HP UX and I'm logging in as user: root. I wish to create new users by using the 'useradd' command. When I keyed in' useradd -u 101 -g group john', the reply was 'Group group specified with -g does not exist'. I've read the man page on useradd and I still don't... (8 Replies)
Discussion started by: mascotlee
8 Replies

9. Shell Programming and Scripting

Need help with ksh script that uses sqlplus, called from PHP

I have a ksh script that connects to sqlplus and dumps the query results into a file. The script works file when I run it from the command line, however, when I call it from PHP using system(), exec(), or shell_exec() commands, the script doesn't seem to run the query. It will create the text file... (7 Replies)
Discussion started by: j2owilson
7 Replies

10. Shell Programming and Scripting

cpio in shell called from php

I have a php program that calls a shell script, this part works fine and most of the commands work. However, I have a cpio command in the shell script, and for some reason this doesn't work. If I catch the return code, it's 1 which means it terminated with an error, but I get no other indication of... (3 Replies)
Discussion started by: mmarino
3 Replies
Login or Register to Ask a Question