expect -re causes error


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting expect -re causes error
# 1  
Old 03-14-2012
expect -re causes error

Hi there. Following part of my code causes script to abort. Why?
Code:
expect -re 'Netroup[^a-zA-Z]permissions[^a-zA-Z]list' {send "$ntgr\r"}

Code:
invalid command name "^a-zA-Z"
    while executing
"^a-zA-Z"
    ("foreach" body line 2)
    invoked from within
"foreach ntgr $netgroup {
expect -re 'Netgroup[^a-zA-Z]permissions[^a-zA-Z]list' {send "$ntgr\r"}
sleep 1
}"
    (file "./useradd.exp" line 23)

---------- Post updated 03-14-12 at 01:40 AM ---------- Previous update was 03-13-12 at 12:31 PM ----------

post up
# 2  
Old 03-19-2012
Java

try this

Code:
expect -re 'Netroup\[^a-zA-Z]permissions\[^a-zA-Z]list' {send "$ntgr\r"}

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Getting error while using date as a variable in expect

Hi getting error when i am saving date command output in a variable and then using the same variable in expect #!/usr/bin/expect set DATE spawn sftp AUT#XX.XX.XX.XX spawn echo $DATE expect "password:" send "AT123\n" expect "sftp>" send "cd /home/ \r" expect "sftp>" send... (12 Replies)
Discussion started by: scriptor
12 Replies

2. Programming

Expect script returning string following a found expect.

I'm fairly new to scripting so this might not be possible. I am using Expect with Cisco switches and need to capture the string after finding the expect request. For example, when I issue "show version" on a Nexus switch, I'm looking to capture the current firmware version: #show version ... (0 Replies)
Discussion started by: IBGaryA
0 Replies

3. Shell Programming and Scripting

Error in spawn and expect for password

Code Broken!! "cod generator ip=$loja" expect -c " # set timeout -1 set timeout 18 spawn scp -C /etc/samba/arkivo.sh root@$loja:/etc/samba/ expect { -re "*yes/no*"{ send "yes\r" exp_continue } -re "*password:*" { send "senha\r" expect \"*#*\"}} ssh root@$loja expect \"*password:*\"... (4 Replies)
Discussion started by: hrenechen
4 Replies

4. Shell Programming and Scripting

Using spawn and expect getting error

#!/bin/sh # # set -x stty -echo; read -p "Input password:" A; stty echo; echo; for HOST in `cat elc.hosts.list` do # echo "Connecting to $HOST" expect -c "set timeout -1;\ spawn sshr $HOST -l root \"mkdir /perfstat;\";\ match_max 100000;\ expect *'/root/.ssh/id_dsa':*;\ send --... (1 Reply)
Discussion started by: madlot
1 Replies

5. Shell Programming and Scripting

Expect Script Error Handling

Good Day Everyone, I was hoping to get a little insight into an expect script that I've written. Basically we have this expect script to perform an sftp upload, key authentication is not an option, and sftp is the only method supported by our vendor, thus the need for this. I want to be... (3 Replies)
Discussion started by: thaller
3 Replies

6. Shell Programming and Scripting

expect 'missing close-brace' error

my expect script fails when it tries to send a password that I have that uses {}'s. Hoping I can correct that. It doesn't complain about the %, #, *, /, ? or ~ characters only the {}'s. #!/usr/bin/expect spawn ssh root@ca199 expect dsa {send... (1 Reply)
Discussion started by: phpfreak
1 Replies

7. Shell Programming and Scripting

Expect Script Error invalid spawn id (6)

Hi everybody, We are trying to connect to a server and to a router using an .expect script that automatically authenticate the username and password needed. The error is that we cannot connect to the server using ssh AND we cannot connect to the router using either telnet or go commands from the... (1 Reply)
Discussion started by: omoyne
1 Replies

8. Shell Programming and Scripting

Need help with Expect script for Cisco IPS Sensors, Expect sleep and quoting

This Expect script provides expect with a list of IP addresses to Cisco IPS sensors and commands to configure Cisco IPS sensors. The user, password, IP addresses, prompt regex, etc. have been anonymized. In general this script will log into the sensors and send commands successfully but there are... (1 Reply)
Discussion started by: genewolfe
1 Replies

9. Shell Programming and Scripting

strange expect script behavior, or am i misunderstanding expect scripting?

Hello to all...this is my first post (so please go easy). :) I feel pretty solid at expect scripting, but I'm running into an issue that I'm not able to wrap my head around. I wrote a script that is a little advanced for logging into a remote Linux machine and changing text in a file using sed.... (2 Replies)
Discussion started by: v1k0d3n
2 Replies

10. Shell Programming and Scripting

Expect Script - error using sed -

Guys, I'm testing a simple script that connects to a server, does a few checks and sends the results to a file. code: #!/bin/ksh expect <<-EOF | sed 's/^M//' >> file spawn ssh user@server expect "password:" { send "password \n" } expect "$" send "df -k /dev/md/dsk/d10 |... (4 Replies)
Discussion started by: tony3101
4 Replies
Login or Register to Ask a Question