Sponsored Content
Top Forums Shell Programming and Scripting Convert unix script in to php Post 302664929 by susindram on Sunday 1st of July 2012 11:39:21 AM
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
 

10 More Discussions You Might Find Interesting

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

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

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

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

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

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

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

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

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

10. 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
CHSH(1) 							   User Commands							   CHSH(1)

NAME
chsh - change login shell SYNOPSIS
chsh [options] [LOGIN] DESCRIPTION
The chsh command changes the user login shell. This determines the name of the user's initial login command. A normal user may only change the login shell for her own account; the superuser may change the login shell for any account. OPTIONS
The options which apply to the chsh command are: -h, --help Display help message and exit. -R, --root CHROOT_DIR Apply changes in the CHROOT_DIR directory and use the configuration files from the CHROOT_DIR directory. -s, --shell SHELL The name of the user's new login shell. Setting this field to blank causes the system to select the default login shell. If the -s option is not selected, chsh operates in an interactive fashion, prompting the user with the current login shell. Enter the new value to change the shell, or leave the line blank to use the current one. The current shell is displayed between a pair of [ ] marks. NOTE
The only restriction placed on the login shell is that the command name must be listed in /etc/shells, unless the invoker is the superuser, and then any value may be added. An account with a restricted login shell may not change her login shell. For this reason, placing /bin/rsh in /etc/shells is discouraged since accidentally changing to a restricted shell would prevent the user from ever changing her login shell back to its original value. FILES
/etc/passwd User account information. /etc/shells List of valid login shells. /etc/login.defs Shadow password suite configuration. SEE ALSO
chfn(1), login.defs(5), passwd(5). shadow-utils 4.1.5.1 05/25/2012 CHSH(1)
All times are GMT -4. The time now is 07:13 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy