Shell script won't recognize heredoc delimiter

前端 未结 1 1794
半阙折子戏
半阙折子戏 2021-01-25 07:05

I am trying to write a very simple shell script in Linux. The Scenario I am trying to achieve is:

Creating an user account and giving it a password internally (No inter

相关标签:
1条回答
  • 2021-01-25 07:46

    When using HEREDOC notation, you must write the closing word (EOF in your case) in a line by itself, without any leading or trailing whitespace.

    But in this case I would use another approach:

    You can use chpasswd. This command is shipped in all linux distros (that I know of) and I think in UNIX variants too.

    The usage is pretty simple, you just pass via the STDIN a username:password combination and that's all, one combo per line. To change the password for a single user, just do a simple echo:

    echo "demo:myPasswd" | chpasswd
    
    0 讨论(0)
提交回复
热议问题