Assistance with scripts for UNIX


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Assistance with scripts for UNIX
# 1  
Old 01-12-2009
Assistance with scripts for UNIX

Hello-
I am new to UNIX (about 1 month to be exact) and have been trying to construct a script to create users and passwords using expect. I have the basic script worked out, which includes creating the user and password, but would like for this to be automated a little more and have it read a list of users from a separate file along with the passwords and then create them based on that separate list.

Here is what I have worked out so far:

# cat testusercreate.sh
#!/usr/bin/expect
# Script for automating creation of user names

spawn ssh approd
expect "root@approd's password:"
send "password2\r"
expect "#"
send "mkgroup test\r"
expect "#"
send "useradd -g test alpha\r"
expect "#"
send "passwd alpha\r"
expect "alpha's New password:"
send "test1\r"
expect "Enter the password again:"
send "test1\r"
expect "#"
send "exit\r"
expect closed
exit 0

Any help would be greatly appreciated

Thanks,
Marty
# 2  
Old 01-12-2009
Create a ssh key-pair for easier login. Then you can use the more compact
Code:
ssh root@approd "mkgroup test ; useradd -g ${group} ${user} ; passwd -o ${passwd}"

To go through the list, read up on read and your shells control statements (for/while)
# 3  
Old 01-12-2009
Quote:
Originally Posted by pludi
Create a ssh key-pair for easier login. Then you can use the more compact
Code:
ssh root@approd "mkgroup test ; useradd -g ${group} ${user} ; passwd -o ${passwd}"

To go through the list, read up on read and your shells control statements (for/while)
Thanks so much for your assistance Pludi. That does help me shorten it. You said I should read up on "read and shells control statements". Do you have any helpful links?

again thanks for the assistance.

Marty
# 4  
Old 01-12-2009
Advanced Bash-Scripting Guide (Fundamentals apply to and POSIX compliant shell)
 
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Assistance understanding a UNIX script

Hello, If I could get some assistance breaking down this Unix script in order to better understand it. A co-worker wrote this script and is no longer with us. I believe this script converts documents into .txt files, but we are trying to edit it so that it converts documents to .pdf automatically... (1 Reply)
Discussion started by: B00GS
1 Replies

2. Shell Programming and Scripting

Unix scripts

hi everyone.Can anyone tell what books to study for unix shell scripting.ive planned to learn unix scripting but i dont kno what kind of books to refer so do help me..Thanks in advance. (1 Reply)
Discussion started by: madanmeer
1 Replies

3. Shell Programming and Scripting

Unix Scripts

Hi, I have to write 2 unix scripts: 1. Check whether the databases are up or down which are on different servers. 2. Check the file system space on different Unix servers. Please share your model scripts here. I have to submit this ASAP. Appreciate your reply...... Thanks (4 Replies)
Discussion started by: dreams5617
4 Replies

4. UNIX for Advanced & Expert Users

Unix Scripts

Hi, I have to write 2 unix scripts: 1. Check whether the databases are up or down which are on different servers. 2. Check the file system space on different Unix servers. Please share your model scripts here. I have to submit this ASAP. Appreciate your reply...... Thanks (1 Reply)
Discussion started by: dreams5617
1 Replies

5. Windows & DOS: Issues & Discussions

Urgent Need for Assistance: Triggering Windows bat files from UNIX

Hello, Is there a way to trigger a Windows bat file or program on a different machine from a different UNIX server using KSC file? I hope you can assist me with this. Thanks! (0 Replies)
Discussion started by: punyenye
0 Replies

6. UNIX for Advanced & Expert Users

Porting of Windows written unix scripts to unix platform

Can anybody help me in finding out a solution for the problem below? When we write .unix or .sh files in windows OS and port them to Unix platforms there is a character ^M inserted at the end of each line of the script file. During ftp porting I set the transfer mode as ASCII for the script... (7 Replies)
Discussion started by: tamilselvi
7 Replies

7. UNIX for Dummies Questions & Answers

unix scripts

Hi all Can sombody tell me how can i run a script as a regular user and then change in the middle of the script to root,perform a task that needs root permisions and get back to the regular user. (4 Replies)
Discussion started by: yelalouf
4 Replies

8. UNIX for Advanced & Expert Users

vi scripts on UNIX

Hi there I'm hoping one of the expert unix guys or gals can assist me in understanding the language within scripts e.g clear while true do tput cup 0 0 LIST=`grep cisco /etc/hosts|grep -v _int | awk '{print $2}'` for SITE in $LIST do IP=`grep "$SITE"... (4 Replies)
Discussion started by: nemex
4 Replies

9. UNIX for Dummies Questions & Answers

UNIX Scripts

I need to find a place or places on the Internet where I can find UNIX scripts to view and to modify to make life easy on the UNIX environment. Shell scripts to be used, ksh, sh, csh. Can someone help me on this. Thanks ;) (2 Replies)
Discussion started by: wolf
2 Replies
Login or Register to Ask a Question