Noob - add/del/list users from a file

Discussion in 'Programming/Scripts' started by samdrewalex, Feb 18, 2019.

  1. samdrewalex

    samdrewalex New Member

    i'm a total bash4 noob (i'd prefer if it were spelled 'newb'), never done any scripting/coding in my life. i've been messing with scripting for about 3 weeks now as part of a class i'm taking so please keep that in mind when replying.

    i'm trying to build a command 'buser' that will add/delete/list users from a file (i created an 'addusers' and a 'delusers' file, both stored in /Users in my home directory).
    BuserScript.png attachment shows what i've written so far.
    Buser+x.png attachment shows the error it's returning when i attempt to invoke it.

    some guidance would be much appreciated. i don't want to wait til class on Wednesday. this stuff is fun and i want to make progress.

    thanks in advance, Samuel

    Attached Files:

  2. samdrewalex

    samdrewalex New Member

    UPDATE - i altered the script at the beginning to:

    read COMMAND
    if (( "$COMMAND" -eq "buser" )); then

    the rest of the script remains the same.

    when i attempt to execute the command, it returns the error in the attached file - blankness. i have to ctrl+c to exit.

    Attached Files:

  3. Taleman

    Taleman Well-Known Member HowtoForge Supporter

    Show your code in code tags. Like this.
          1 #!/bin/bash
          3 echo "Hello world"
    Include line numbers, so the error messages are useful. For example get line numbers with
    less -N
    Or use pastebin, some of them allow syntax highlighting.

    You have error in line 4, but since I do not know which line is number 4 not much I can do.

Share This Page