Sponsored Content
Top Forums Shell Programming and Scripting How to create multiple users using expect.? Post 302878156 by alhazerd on Wednesday 4th of December 2013 05:27:51 PM
Old 12-04-2013
How to create multiple users using expect.?

Hi, guys. I need help on some expect problem.

Code:
#!/usr/bin/expect
set user [lindex $argv 0]
set password [lindex $argv 1]
set newuser [lindex $argv 2]
spawn telnet x.x.x.x
expect login*
send “root\r”
expect Password*
send “123546\r”
send "useradd $newuser\r"
send "exit\r"
interact

I can add 1 user using expect script, but how do I add 300 with names like Tom1,Tom2,Tom3.....,Thank you all very much.

Last edited by bartus11; 12-04-2013 at 06:29 PM.. Reason: Please use code tags
 

8 More Discussions You Might Find Interesting

1. UNIX Desktop Questions & Answers

How to create users on HP UX????

I new to unix and I'm using a HP UX and I'm logging in as user: root. I wish to create new users by using the 'useradd' command. When I keyed in' useradd -u 101 -g group john', the reply was 'Group group specified with -g does not exist'. I've read the man page on useradd and I still don't... (8 Replies)
Discussion started by: mascotlee
8 Replies

2. Solaris

How to create users in NIS

How to create users in NIS server in solaris Thanks in Advance (6 Replies)
Discussion started by: durgaprasadr13
6 Replies

3. Shell Programming and Scripting

Create new users

Hi , i would like to create a new user over unix ,which are these commands to used and which are the directories to handler? Thank you (3 Replies)
Discussion started by: dimitris
3 Replies

4. Solaris

Can we create multiple users with same UID?

* Can we create multiple users with same UID? * Can we give root permissions to normal user like admin.s ? If YES give me full details (syntax of sudo/RBAC) (14 Replies)
Discussion started by: Navkreddy
14 Replies

5. Shell Programming and Scripting

using expect to switch users in a script

hi, I need to switch users in a script I'm newbee to expect I wrote two files 1 sudo.exp, since su4098 is used as root in my laptop #!/usr/bin/expect spawn su su4098 expect *Password:* send mypsw\n interact 2 test.sh ls ./sudo.exp tcpdump -i wlan0 su esolve ls however, in... (1 Reply)
Discussion started by: esolve
1 Replies

6. Shell Programming and Scripting

Create multiple users with individual passwords to users

hi, i am new to shell scripts i write a shell script to create multiple users but i need to give passwords to that users while creating users, command to write this script (1 Reply)
Discussion started by: DONFOX
1 Replies

7. Shell Programming and Scripting

Create Multiple UNIX Files for Multiple SQL Rows output

Dear All, I am trying to write a Unix Script which fires a sql query. The output of the sql query gives multiple rows. Each row should be saved in a separate Unix File. The number of rows of sql output can be variable. I am able save all the rows in one file but in separate files. Any... (14 Replies)
Discussion started by: Rahul_Bhasin
14 Replies

8. Ubuntu

Expect /bash, 2 ssh login users

HI all i need to connect to about 900 cisco routers and switch to do some configs changes. the issue i am having is that half the devices have one set of username and password and the other half have another username and password. From expect or bash script i can ssh into a device and make... (1 Reply)
Discussion started by: quintin
1 Replies
lindex(n)						       Tcl Built-In Commands							 lindex(n)

__________________________________________________________________________________________________________________________________________________

NAME
lindex - Retrieve an element from a list SYNOPSIS
lindex list ?index...? _________________________________________________________________ DESCRIPTION
The lindex command accepts a parameter, list, which it treats as a Tcl list. It also accepts zero or more indices into the list. The | indices may be presented either consecutively on the command line, or grouped in a Tcl list and presented as a single argument. | If no indices are presented, the command takes the form: | lindex list | or | lindex list {} | In this case, the return value of lindex is simply the value of the list parameter. | When presented with a single index, the lindex command treats list as a Tcl list and returns the index'th element from it (0 refers to the first element of the list). In extracting the element, lindex observes the same rules concerning braces and quotes and backslashes as the Tcl command interpreter; however, variable substitution and command substitution do not occur. If index is negative or greater than or equal to the number of elements in value, then an empty string is returned. If index has the value end, it refers to the last element in the list, and end-integer refers to the last element in the list minus the specified integer offset. If additional index arguments are supplied, then each argument is used in turn to select an element from the previous indexing operation, | allowing the script to select elements from sublists. The command, | lindex $a 1 2 3 | or | lindex $a {1 2 3} | is synonymous with | lindex [lindex [lindex $a 1] 2] 3 | EXAMPLES
| lindex {a b c} => a b c | lindex {a b c} {} => a b c | lindex {a b c} 0 => a | lindex {a b c} 2 => c | lindex {a b c} end => c | lindex {a b c} end-1 => b | lindex {{a b c} {d e f} {g h i}} 2 1 => h | lindex {{a b c} {d e f} {g h i}} {2 1} => h | lindex {{{a b} {c d}} {{e f} {g h}}} 1 1 0 => g | lindex {{{a b} {c d}} {{e f} {g h}}} {1 1 0} => g | SEE ALSO
list(n), lappend(n), linsert(n), llength(n), lsearch(n), lset(n), lsort(n), lrange(n), lreplace(n) | KEYWORDS
element, index, list Tcl 8.4 lindex(n)
All times are GMT -4. The time now is 04:30 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy