Convert unix script in to php


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Convert unix script in to php
# 1  
Old 07-01-2012
Convert unix script in to php

Hi All,

I have one shell script and like to convert into GUI for user creation..Any way to convert shell script into php?

Please find the below for my script.

Code:
$ more user.sh
#!/bin/ksh
set -x
pwfile="/etc/passwd"    shadowfile="/etc/shadow"
gfile="/etc/group"

######Want to check user account already exist###############

echo "Add new user account name to create"
echo -n "creation login name: "     ; read login
LOG=`grep -i $login $pwfile|awk -F: '{print $1}'`
if [ "$LOG" =  "$login" ] ; then
echo "user account found"
exit 0
fi

echo -n "full name of user creation: " ; read fullname

echo -n "similer_profile of team member: " ;read similer_profile

############ want to check similler profile having in the server########
SIMILOGIN_Profile=`grep -i $similer_profile $pwfile|awk -F: '{print $1}'`
#echo "Value of SIMILOGIN_Profile :$SIMILOGIN_Profile"
if [ "$SIMILOGIN_Profile"  -ne "$similer_profile" ] ;then
echo "similer_profile not found"
elif [ "$SIMILOGIN_Profile"  = "$similer_profile" ] ;then
Profile_homedirectory=`grep -i $SIMILOGIN_Profile $pwfile`
echo $Profile_homedirectory
Genericid_search=`id -a $SIMILOGIN_Profile`
echo $Genericid_search
fi
echo -n "userID: " ; read userID
UID_Exist=`grep -i $userID $pwfile|awk -F: '{print $3}'`
if [ "$UID_Exist" =  "$userID" ] ; then
echo "user ID found"
exit 0
fi

groupiD=`id -a $SIMILOGIN_Profile |awk '{print $3}'|cut -d "," -f1|cut -d "(" -f1 |cut -d "=" -f2`
secondory_group=`id -a $SIMILOGIN_Profile |awk '{print $NF}'|cut -d"," -f2|cut -d "(" -f1`
HomeDirectory=`grep -i $similer_profile $pwfile|awk '{print $2}' |cut -d ":" -f2 |sed s/$SIMILOGIN_Profile/$login/g`
#HomeDirectory_search=`grep -i $similer_profile $pwfile|awk '{print $2}' |cut -d ":" -f2`
#HomeDirectory=$HomeDirectory_search |`sed s/$SIMILOGIN_Profile/$login/g`
shell=`grep -i $similer_profile $pwfile|awk '{print $2}' |cut -d ":" -f3`
#echo -n "gid: "     ; read groupiD
#echo -n "GenricID: " ; read GenricID
#echo -n "HomeDirectory " ; read HomeDirectory
#echo -n "shell: "     ; read shell


sudo /usr/sbin/useradd -u $userID -g $groupiD -G $secondory_group -c "$fullname" -m -d $HomeDirectory -s $shell $login
user_account_status=`grep -i $login $pwfile|awk -F: '{print $1}'`
if [ "$user_account_status" -ne  "$login" ] ; then
echo "user_account_status not created"
elif [ "$user_account_status" = "$login" ] ; then
password=`sudo passwd  $login`
fi
echo -n "Enter the password" ; read passwd
server_name=`hostname`
echo -n "Enter the CO number: " ; read CO
echo -n "Enter the mailID: " ; read mailID
mailx -s "Acount has been created for your change order" $mailID <<EOF
--------------------------------------------------
Server name : $server_name
Change order number : $CO
User name  $login
password   $passwd
---------------------------------------------------
EOF
$

Thanks,
Susi.SSmilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Script to convert dos to UNIX in Solaris

Hi Team, I am trying to implement a script in Solaris, that required to find the list of files inside directories and convert those to dos2unix conversion, Can someone please help here.. Below is the example of scenario.... (1 Reply)
Discussion started by: Logics123
1 Replies

2. Shell Programming and Scripting

Convert UNIX rights in a number in a sh script

Hello, i'm trying to write a script sh to convert the rights of a folder or file in a number. Explain: ls -l = rwxrwxrwx so i must display 777. Do you known where i can find so convert script Thanks Use code tags, thanks. (11 Replies)
Discussion started by: steiner
11 Replies

3. Shell Programming and Scripting

UNIX or Perl script to convert JSON to CSV

Is there a Unix or Perl script that converts JSON files to CSV or tab delimited format? We are running AIX 6.1. Thanks in advance! (1 Reply)
Discussion started by: warpmail
1 Replies

4. UNIX for Dummies Questions & Answers

How to convert R$Timestamp in Sql*Plus within a UNIX Shell Script?

I need to compare a R$Timestamp field sql within a Unix Shell Script. In straight SQL the following code works fine: Table Name: LL_UNIT_TRANSACTION UT Field: R$Timestamp Where TRUNC(UT.R$Timestamp) >= TRUNC(SYSDATE -7) the following returns no data within the Unix Shell Script... (2 Replies)
Discussion started by: Dapconsult
2 Replies

5. Shell Programming and Scripting

Need a unix script to convert date into Julian format in a text file

The 6th & 7th column of the text files represents date & time. I need this to be converted in julian format using command "date +%s -d <date>". I know the command, but dont know how to use it on the script 0 dbclstr-b IXT_Web Memphis_Prod_SQL_Full Memphis-Prod-SQL-Full-Application-Backup... (4 Replies)
Discussion started by: ajiwww
4 Replies

6. Shell Programming and Scripting

how to convert a shell script to a php script for displaying next word after pattern match

I have a shell script which I made with the help of this forum #!/bin/sh RuleNum=$1 cat bw_rules | sed 's/^.*-x //' | awk -v var=$RuleNum '$1==var {for(i=1;i<=NF;i++) {if($i=="-bwout") print $(i+3),$(i+1)}}' Basically I have a pages after pages of bandwidth rules and the script gives... (0 Replies)
Discussion started by: sb245
0 Replies

7. UNIX for Dummies Questions & Answers

Unix script to convert .csv file to.xls format

I have a .csv file in Unix box i need a UNIX script to convert the.csv files to.xls format. Its very urgent please help me. (1 Reply)
Discussion started by: moon_friend
1 Replies

8. Shell Programming and Scripting

convert unix script to perl

Hi, I have these lines in a unix script: FILEONE = /<filepath1>/<filename1.txt> FILENEW = /<filepath2>/<filename2.txt> head -5 $FILEONE | sed '1d' > $FILENEW PARAM1 = `cat $FILENEW | awk '{print $2;}' ` echo "Param1 Value: $PARAM1" What's the correct syntax of the above lines if same... (2 Replies)
Discussion started by: gholdbhurg
2 Replies

9. Shell Programming and Scripting

Sample Unix script file to convert .xml to .csv

Dear all, Can you send me a script file the changes .xml to .csv file. Thanks, Srinivasa (4 Replies)
Discussion started by: srinivasaphani
4 Replies

10. Shell Programming and Scripting

how to convert unix .ksh script to windows .batch script

I am using awk in my .ksh script but when I am trying to run in windows its not recognising awk part of the ksh script , even when I changed it to gawk it does not work, this is how my .ksh and .bat files look like. thanx. #!/bin/ksh egrep -v "Rpt 038|PM$|Parameters:|Begin |Date: |End... (1 Reply)
Discussion started by: 2.5lt V8
1 Replies
Login or Register to Ask a Question