Sponsored Content
Homework and Emergencies Homework & Coursework Questions Create script to add user and create directory Post 302505738 by pbhound on Thursday 17th of March 2011 04:39:29 PM
Old 03-17-2011
Create script to add user and create directory

first off let me introduce myself. My name is Eric and I am new to linux, I am taking an advanced linux administration class and we are tasked with creating a script to add new users that anyone can run, has to check for the existence of a directory. if the directory does not exist then it has to be created. if it doe then it has to just proceed with the new user addition.


1. The problem statement, all variables and given/known data:

how do i get this script to be able to create the directory if it does not exist?
or how do i get this script to run as root?
thanks in advance


2. Relevant commands, code, scripts, algorithms:
i have the script partially written i have rudimentary if/then/else statement where the first line reads:
Code:
echo "What department are you assigned to?"
read department     # $department
sleep 2
echo "you are assigned to the: $department"
sleep 7
clear

if [ -d /home/timberwolves/$department ]
then 
         echo "directory exists"
         sleep 3
         echo "what is your first name"
         read FirstName    # $FirstName
         sleep 2
         clear
         echo "what is your last name?"
         read LastName     # $LastName
         echo "You entered: $LastName"
         sleep 2
         clear
         echo "Please type your password (must be at least  characters)"
         read password      # $password
         sleep 2
         clear
         echo "The password you chose is: $password"
         sleep 7
         clear
         echo "Your login name will be: $FirstName"
         sleep 2
         clear
         echo "Your home directory will be: /home/timberwolves/$department/$FirstName
          sleep 7
          clear
else
mkdir -p /home/timberwolves/$department
         echo "what is your first name"
         read FirstName    # $FirstName
         sleep 2
         clear
         echo "what is your last name?"
         read LastName     # $LastName
         echo "You entered: $LastName"
         sleep 2
         clear
         echo "Please type your password (must be at least  characters)"
         read password      # $password
         sleep 2
         clear
         echo "The password you chose is: $password"
         sleep 7
         clear
         echo "Your login name will be: $FirstName"
         sleep 2
         clear
         echo "Your home directory will be: /home/timberwolves/$department/$FirstName
          sleep 7
          clear
fi

3. The attempts at a solution (include all code and scripts):
google searches


4. Complete Name of School (University), City (State), Country, Name of Professor, and Course Number (Link to Course):
ECPI college or technology in virginia beach VA, Mr. Blow CIS305 advanced UNIX administration.

we do not have a direct link to the course


Note: Without school/professor/course information, you will be banned if you post here! You must complete the entire template (not just parts of it).

Last edited by Scott; 03-17-2011 at 05:47 PM.. Reason: Added code tags
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Create file in each user directory

Hi, Im newbie, I wanna to create file in each user directory, how to make that script, maybe someone can give me example, im confusing coz i have to change form one user directory to other Thank U. (8 Replies)
Discussion started by: cleks
8 Replies

2. UNIX for Dummies Questions & Answers

how to write script to create directory

Please help. I am the beginner. Don't understand about archive file. How to create a directory for the files from each archive with name of directory which equivalent to the base name of the archive. eg I have file abc.txt. How can I create a directory name abc. Thank you (1 Reply)
Discussion started by: snail
1 Replies

3. Shell Programming and Scripting

create a new directory from cgi script

hello. i hav accepted name of directory from user through a form.now i need to create a directory under cgi-bin of that name.I am not able to do so.n help is required (12 Replies)
Discussion started by: raksha.s
12 Replies

4. Shell Programming and Scripting

How to create a directory inside root as different user

Hi All, I have directory under /opt/test. The ownership of the test directory is root:root. I have login to the server as test user. I need to have some script to create a directory inside /opt/test. This script will be called as test user. When I try to execute... (4 Replies)
Discussion started by: kalpeer
4 Replies

5. Solaris

create user with RWX access to a specific directory in Solaris 10

I need to create a user account for a developer that will allow him rwx access to all resources in a directory. How can I do that? Thanks (5 Replies)
Discussion started by: gsander
5 Replies

6. AIX

How to create new user and add group

Hello, I am new in AIX please tell how can i create user and add group in this user for example, i want to create user umair and want to add this user primanry group DBA and secondary group ORACLE,how can i do this please tell in detail Thanks, Umair (1 Reply)
Discussion started by: umair
1 Replies

7. Solaris

Unable to create or delete a directory in /usr with root user

Hi All, I am trying to uninstall jdk 1.5 from my Solaris 10 64 bit but some how was not successful.so tried to delete the folder of jdk from /usr but its throughing error as: Unable to remove directory jdk: Read-only file system Even I tried to create a dir in /usr but its not allowing me... (4 Replies)
Discussion started by: Pshah
4 Replies

8. Shell Programming and Scripting

Create a folder under different user directory

Hello All, I have to write a shell script and use it in informatica. The script has to perform below actions: The script gets executed from edw user. Through the script, a DT folder has to be created under edw_sca user. Is this scenario possible through a SHELL script or not. ... (2 Replies)
Discussion started by: bghosh
2 Replies

9. Shell Programming and Scripting

Shell script cannot create directory and move the file to that directory

I have a script, which is checking if file exists and move it to another directory if then mkdir -p ${LOCL_FILES_DIR}/cool_${Today}/monthly mv report_manual_alloc_rpt_A_I_ASSIGNMENT.${Today}*.csv ${LOCL_FILES_DIR}/cool_${Today}/monthly ... (9 Replies)
Discussion started by: digioleg54
9 Replies
pbuilder-user-mode-linux(1)					     pbuilder					       pbuilder-user-mode-linux(1)

NAME
pbuilder-user-mode-linux - personal package builder in UML SYNOPSIS
pbuilder-user-mode-linux create [options] pbuilder-user-mode-linux update [options] pbuilder-user-mode-linux build [options] .dsc-file pbuilder-user-mode-linux execute [options] script pbuilder-user-mode-linux login [options] DESCRIPTION
Front end program to the pbuilder suite of programs, used for creating and maintaining user-mode-linux environment and building Debian package within the user-mode-linux virtual machine environment. Unlike pbuilder , pbuilder-user-mode-linux does not require root privilege to run. It should be ran under a normal user. OPTIONS
create Creates a user-mode-linux root image for the specified distribution using rootstrap software update Updates the user-mode-linux root image for the specified distribution. Also, by specifying the --distribution option, it is possi- ble to switch the distribution. Specify a dummy distribution value even for custom apt config files. build Builds the package specified by .dsc-file within the user-mode-linux environment. login Invokes shell within UML. dumpconfig dumps configuration information about user-mode-linux, used for debugging. execute Invokes a command or script inside UML. execute will copy the specified file into the UML system, and run it. The remaining command-line arguments are passed on to the script. --uml-image [UML image] Specify the UML image to use. --eth0 [uml option for eth0] Specify this option as parameter to UML. Specify --eth0=slirp,12345,/usr/bin/slirp-fullbolt to use the slirp connection. --uml-ip [IP inside UML] Specify this to set the IP inside UML. This can be set to dhcp for obtaining IP address through DHCP. --uml-netmask [netmask] The netmask. --uml-network [network] The network address. --uml-broadcast [broadcast] The broadcast address. --uml-gateway [gateway] The gateway address. --mount-tmpfs [yes] Specify whether to mount tmpfs inside UML chroot. --uml-hostname [uml-host] The hostname inside uml. --distribution [sid] Specify the distribution. see pbuilder(8) --binary-arch Specify only to build binary-arch targets. see pbuilder(8) --timeout timeouttime Timeout build after specified time. see pbuilder(8) --configfile config file to read Makes pbuilder to read the config file inside UML. pbuilder-user-mode-linux itself would be affected by the contents of the config file. --hookdir location of hooks Makes pbuilder use the specified hookdir inside UML. --aptconfdir apt configuretion directory Makes pbuilder to use specified apt configuration directory instead of other settings. See pbuilder(8) --override-config Specify this option along with --distribution to switch distribution using pbuilder-user-mode-linux update --logfile logfilename Specify this option to make the output go to logfilename as well as standard output. --buildresult /dir/to/build/result The directory where build result is placed to --uml-debugmode Enable tracing of shell scripts used by pbuilder-user-mode-linux. --bindmounts /dir/to/bind-mount Bind-mount the directory inside the chroot inside the user-mode-linux. --buildplace place-to-put-COW-file Specify the directory to place the COW file. The user needs to be able to access that directory, and the directory must exist. --uml-login-nocow Do not use COW filesystem when using pbuilder-user-mode-linux login so that changes made in the log in session will persist. Effective in login and exec options. --mirror [mirror location] Specifies the URL of Debian mirror to be specified in sources.list inside the chroot. This option is only valid when distribution is being specified, for update and build targets. The format is something like: http://http.us.debian.org/debian which should point to your favourite mirror. This option can optionally be omitted, and left blank, in which case, this part is skipped. Note that these URLs specified to pbuilder will be used from within the chroot, and specifying file:/somewhere/ will most probably fail. --othermirror [deb http://xxx/xxx/ ./ | other deb lines... ] The lines which is added to the sources.list, delimited with | Like deb http://local/mirror stable main|deb file:/usr/local/mirror ./ The deb lines here are the ones that will appear at the top of the sources.list inside the chroot. Be sure to follow the syntax rules of sources.list(5). These lines appear at the beginning of the constructed sources file, so this is the place to list your local mirror sites; apt will then use them in preference to the ones listed in --mirror . These options are only valid when --override-config option is specified in update target, or when pbuilder create is being called. NOTES
For build and login targets, pbuilder-user-mode-linux will try to use COW devices. Inside user-mode-linux, pbuilder-user-mode-linux will mount tmpfs as /tmp to avoid temporary file race conditions with outside of UML. This may cause problems trying to use files in /tmp directory. FILES
/etc/pbuilderrc The system-wide configuration file for pbuilder. /usr/share/pbuilder/pbuilderrc The default settings for pbuilder, used as fallback for all values that is not specified in /etc/pbuilderrc. /etc/pbuilder/pbuilder-uml.conf System-wide configuration file for pbuilder-uml, it will take priority over pbuilder configurations. /usr/share/pbuilder/pbuilder-uml.conf Software-default configuration file for pbuilder-uml. ${HOME}/.pbuilderrc User-default configuration file. SEE ALSO
/usr/share/doc/pbuilder/pbuilder-doc.html, pdebuild(1), pbuilder(8), rootstrap(1), linux(1), pbuilderrc(5), pbuilder-uml.conf(5) Debian 2005 Jun 12 pbuilder-user-mode-linux(1)
All times are GMT -4. The time now is 02:08 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy