Month: May 2008

How to change password – non interactively in simple way

How to change password – non interactively in simple way

Introduction –

This is the simple way to change password of user on Unix/Linux system non interactively! This script is really helpful for updating password in bulk or adding new users and setting  there password in bulk. Another method is to expect tool please refer article on expect!!

Let’s see the script now –

root@arun:~# cat /script/
#! /bin/bash

if [ $# -eq 2 ]; then
echo “Script to change password non-interactively”
echo “——————————————-”
echo ” * Usage: username   password”
exit 1
passwd  $1<<ARUN

How to use it ?

root@arun:~# ./
* Usage: username   password

root@arun:~# ./  myuser   mypwd
Script to change password non-interactively
Enter new UNIX password: Retype new UNIX password: passwd: password updated successfully
Thank you,
Arun Bagul

PHP – Hide user input using batch script (windows)

PHP – Hide user input using batch script (windows)

Introduction –  I was looking for a PHP CLI (command line) script through which I can hide the user input details like password etc on windows platform. I didn’t find any script in php, which hide the password details while user giving input through command prompt. Then I got an idea to hide the password script using batch command. I tried to find out the batch script through which I can take the inputs and then pass the php script. Finally I found a wonderful batch script, which takes the input user name and password (hidden).

** Batch Script => input.bat

@echo off
SET /P uname=Enter Username:
echo hP1X500P[PZBBBfh#b##fXf-V@`$fPf]f3/f1/5++u5>
set /p password=Enter password :<nul
for /f “tokens=*” %%i in (‘’) do set password=%%i
c:\php\php.exe d:\php\test.php %uname% “%password%”

Execute the batch  file  on window system (DOS prompt) will take the inputs and give the inputs to php script. To execute batch file just double click on input.bat file…

Thank you,
Arun Bagul and Santhosh Tirunahari