- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: ksh - problems with comment parameter in usera...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-04-2015 03:50 AM
06-04-2015 03:50 AM
ksh - problems with comment parameter in useradd
I am trying to user useradd in a ksh script...
PG_USERNAME=postgres PG_USER_ID=26 PG_GROUP_ID=26 PG_USER_SHELL='/bin/ksh' PG_USER_DIR='/home/postgres' PG_USER_COMMENT="\"Postgres administration account"\" : echo "useradd -u $PG_USER_ID -g $PG_GROUP_ID -d $PG_USER_DIR -m -s $PG_USER_SHELL -c $PG_USER_COMMENT $PG_USERNAME" useradd -u $PG_USER_ID -g $PG_GROUP_ID -d $PG_USER_DIR -m -s $PG_USER_SHELL -c $PG_USER_COMMENT $PG_USERNAME :
When I run the script, I get...
04-Jun-2015 12:37:19: Info: Creating Postgres user 'postgres' with UID '26'...
useradd -u 26 -g 26 -d /home/postgres -m -s /bin/ksh -c "Postgres administration account" postgres
Too Many Arguments specified
Usage: useradd [-u <uid> [-o]] [-g <group>] [-G <group>[,<group...>]] [-d <dir>] [-s <shell>] [-c <comment>] [-m [-k <skel dir>]] [-f <inactive>] [-e <expire>] [-r <yes|no>] [-p <encrypted-password>] [-t <template>] [-P -S <alternate password file>] <login>
Usage: useradd -D [-g <group>] [-b <base dir>] [-f <inactive>] [-e <expire>] [-r <yes|no>] [-M <yes/no>] [-k <skel dir>] [-O <yes/no>] [-s <shell>] [-c <comment>] [-t <template>]
04-Jun-2015 12:37:19: ERROR: Unable to create Postgres user postgres, error: 2
root@devp51:#
Any ideas?
Many thanks,
Gary
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-04-2015 05:14 AM
06-04-2015 05:14 AM
Re: ksh - problems with comment parameter in useradd
PG_USER_COMMENT=\"Blah\"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-04-2015 05:28 AM
06-04-2015 05:28 AM
Re: ksh - problems with comment parameter in useradd
PG_USER_COMMENT=\"Postgres administration account\"
Then when I run it...
root@devp51:# ./create_pg_user
./create_pg_user[74]: administration: not found
04-Jun-2015 14:25:51: Info: Creating Postgres user 'postgres' with UID '26'...
useradd -u 26 -g 26 -d /home/postgres -m -s /bin/ksh -c postgres
Either -D or user must be specified
Usage: useradd [-u <uid> [-o]] [-g <group>] [-G <group>[,<group...>]] [-d <dir>] [-s <shell>] [-c <comment>] [-m [-k <skel dir>]] [-f <inactive>] [-e <expire>] [-r <yes|no>] [-p <encrypted-password>] [-t <template>] [-P -S <alternate password file>] <login>
Usage: useradd -D [-g <group>] [-b <base dir>] [-f <inactive>] [-e <expire>] [-r <yes|no>] [-M <yes/no>] [-k <skel dir>] [-O <yes/no>] [-s <shell>] [-c <comment>] [-t <template>]
04-Jun-2015 14:25:51: ERROR: Unable to create Postgres user postgres, error: 2
root@devp51:#
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-04-2015 09:14 AM
06-04-2015 09:14 AM
Re: ksh - problems with comment parameter in useradd
Here is what I got to work, based on your script snippet:
#!/usr/bin/ksh -x PG_USERNAME=pwwtest1 PG_USER_ID=2600 PG_GROUP_ID=2600 PG_USER_SHELL='/bin/ksh' PG_USER_DIR='/home/pwwtest1' PG_USER_COMMENT="Postgres administration account" useradd -u $PG_USER_ID -g $PG_GROUP_ID -d $PG_USER_DIR -m -s $PG_USER_SHELL -c "$PG_USER_COMMENT" $PG_USERNAME
Notice that I just have one set of double-quotes around the PG_USER_COMMENT string and then I put double quotes around the variable $PG_USER_COMMENT in the command itself.
This worked and created the ID for me.
- Tags:
- quoting