- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Script help
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
Forums
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
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
12-05-2005 11:03 PM
12-05-2005 11:03 PM
Script help
I want to write a shell script to automate the useradd and assigning password to that user [ only through shell script ]. I tried with using "EOF" but still the script prompts for passowrd.
The script that I wrote was
!/usr/bin/sh -x
useradd prasad
echo "vnc" 2>&1
# Here prasad is username and test is password.
passwd prasad << EOF
test
test
EOF
Can anyone help me to automate this......
Thanks,
Prabu.S
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2005 11:07 PM
12-05-2005 11:07 PM
Re: Script help
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-06-2005 12:07 AM
12-06-2005 12:07 AM
Re: Script help
#!/bin/bash
for i in `seq 1 10`
do useradd user$i
echo password$i |passwd --stdin user$i
done
exit
it adds 10 users user1, user2,etc
and gives each the password same as username.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-06-2005 12:41 AM
12-06-2005 12:41 AM
Re: Script help
The error is
Try `passwd --help' or `passwd --usage' for more information.
passwd: unrecognized option `--stdin'
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-06-2005 12:50 AM
12-06-2005 12:50 AM
Re: Script help
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-06-2005 12:54 AM
12-06-2005 12:54 AM
Re: Script help
cat /etc/SuSE-release
SUSE LINUX Enterprise Server 9 (i586)
VERSION = 9
PATCHLEVEL = 2
Any inputs......
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-06-2005 01:42 AM
12-06-2005 01:42 AM
Re: Script help
I googled but no use.
My passwd utility doesnot support --stdin option.
Is this possible to do in a shell script?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-06-2005 02:52 AM
12-06-2005 02:52 AM
Re: Script help
try:
useradd test -p password for example.
Where password is the crypted password.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-06-2005 03:53 PM
12-06-2005 03:53 PM
Re: Script help
My problem is that I wanted to create a user account and also assign password to that user, to be done in a shell script. Any another script uses this user to do some operations.
So, useradd -p will never going to help me.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-06-2005 05:31 PM
12-06-2005 05:31 PM
Re: Script help
You can not achive this with back scripting with EOF format as like ftp.
Few ways to accomplish as,
1) expect scripting to accomplish job
2) telnet piping script as,
(
sleep 1
echo "root"
sleep 1
echo "
sleep 1
echo "passwd
sleep 1
echo "password"
sleep 1
echo "password"
sleep 1
echo "exit"
) | telnet localhost
Change the sleep timings based on your system speed. Revert back if this is not working.
-Muthu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-06-2005 07:57 PM
12-06-2005 07:57 PM
Re: Script help
:-), nice to hear from you.I modified ur script as below;
#!/bin/bash
useradd test
(
sleep 1
echo "test"
sleep 1
echo "test"
sleep 1
echo "passwd test"
sleep 1
echo "test"
sleep 1
echo "test"
sleep 1
echo "exit"
) | telnet localhost
When I execute it,
kassel1:/home/rtp40/prabu # ./2.sh
Trying 127.0.0.1...
telnet: connect to address 127.0.0.1: Connection refused
entry in /etc/passwd
test:x:5002:100::/home/test:/bin/bash
entry in /etc/shadow
test:x:5002:100::/home/test:/bin/bash
Can you throw some more lights on this......
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-06-2005 08:21 PM
12-06-2005 08:21 PM
Re: Script help
-Muthu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-06-2005 08:36 PM
12-06-2005 08:36 PM
Re: Script help
Output:
bash-3.00# ./2.sh
+ useradd test
+ sleep 1
+ telnet localhost
Trying ::1...
Connected to localhost.
Escape character is '^]'.
+ echo test
+ sleep 1
+ echo test
+ sleep 1
login: Password: + echo 'passwd test'
+ sleep 1
+ echo test1
test1
+ sleep 1
+ echo test1
test1
+ sleep 1
+ echo exit
exit
Connection to localhost closed by foreign host.
bash-3.00#
But I couldnot login as test using passeord,
"test1". It fails.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-06-2005 08:40 PM
12-06-2005 08:40 PM
Re: Script help
-Muthu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-07-2005 01:36 AM
12-07-2005 01:36 AM
Re: Script help
#!/bin/bash
for i in `seq 1 10`
do
useradd -m -p user${i} user${i}
done
exit
The -p option sets the encrypted password.
JL
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-07-2005 04:37 AM
12-07-2005 04:37 AM