Find the answer to your Linux question:
Results 1 to 6 of 6
Hi, I am a bit of a newbie to linux and can do some things. I have managed to get everything up and running correctly. But I dont know how ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Aug 2003
    Posts
    18

    User script


    Hi, I am a bit of a newbie to linux and can do some things. I have managed to get everything up and running correctly.

    But I dont know how to do any shell scripting. And I want to write one that will do the following.

    [root@localhost /]# ./webuser <username> <password> <quota>

    Would create a user on the system. With a disk quota based on MB specified in the command line, and add a folder called 'www' with in the user's home dir. Oh yea and it would also create a mySQL user and a db called bn_USERNAME.
    Can anyone take some time to help me do this? Maybe teach me some basics about how this would be done.

  2. #2
    Linux Engineer
    Join Date
    Nov 2002
    Location
    Queens, NY
    Posts
    1,319
    Well, I don't have MySQL so I can't help you out in those parts but I'll get you started.
    Code:
    #!/bin/sh
    
    # The first line above MUST be exactly as you see it. executes a subshell and runs the following commands
    
    # In scripting &#40;Bourne&#41;, $1 - $9 represent the command line arguments
    # $0 is the name of the script. You can also make variables using '$'
    echo "First field&#58; $1"
    echo "Second field&#58; $2"
    echo "Third field&#58; $3"
    Save this file as "webuser" and set the executable permissions for it (chmod +a webuser or chmod 755 webuser). Once that's done, try running it like the way you have it.
    Code:
    $ ./webuser brock mypasswd 1500
    It should print out the values you gave in. So this the most basic thing I can teach you. You'll now have to use builtin commands (i.e: useradd) to help you along the way but it shouldn't be hard at all. Let me know if you run into trouble.
    The best things in life are free.

  3. #3
    Just Joined!
    Join Date
    Aug 2003
    Posts
    18
    Excelent! I got it to add a user I dont know how to set a quota tho... Any ideas there?

  4. #4
    Linux Engineer
    Join Date
    Nov 2002
    Location
    Queens, NY
    Posts
    1,319
    Setting quota is a lot more work than you think. First, you need the option enabled in the kernel to do so. As most distributions have this enabled, I don' t think you'll need to worry about this part. Then you'll need to turn quota on with /usr/sbin/quotaon. From here, you'll have to manage userquota, groupquota and the quota database. I'd suggest www.google.com to try to find a nice tutorial on this since I think they'll be able to explain it better.
    The best things in life are free.

  5. #5
    Just Joined!
    Join Date
    Aug 2003
    Posts
    18
    LOL ok ill look around. Thanks

  6. #6
    Linux Guru
    Join Date
    Oct 2001
    Location
    Täby, Sweden
    Posts
    7,578
    Here's the documentation that comes with the source distribution of the quota userspace tools (in PostScript format):
    http://www.dolda2000.com/~fredrik/lf/quotas.ps

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •