Expect Special Characters


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Expect Special Characters
# 1  
Old 01-08-2014
Expect Special Characters

Hi,
I am familiar with using a backslash to escape a $ in a send command, but this device I am using expect to talk to has a regex expression that I need to input and it is a bear. Is there a list of all the characters that require escaping in an expect send statement ? Here is what I need to 'send'.. Pretty gross huh ?

Code:
issue message "((-config was changed)|(from USER EXEC mode)|(logout from src IP))|(UI CMD_EXECUTED.*Command (add|alias|apply|batch|bind|clear|convert|create|reboot|renumber|set|unalias|unbind|unset))|(AAA-5-AAA_AUTH_ADMIN_USER: aaa.(.*)[\\t ]for[\\t ]admin[\\t ]user[\\t ])|(AUDIT - user \\S+)|(Begin configuration)|(Login permitted from)|(MANAGER Mode)|(OSAPI-5-CLEAN_TASK:\\s*osapi_task.c:(?:.*)cleaning\\s*up\\s*exited\\s*task)|(PIX-5-11100[5,7,8])|(PIX-5-199001)|(PIX-5-611103)|(Reloaded at)|(SME TELNET from)|(SYS-5-CONFIG_I)|(SYS-5-RELOAD)|(SYS-5-RESTART)|(SYS-6-CFG)|(SYS-6-CFG_CHG.*?/(\\S+)/)|(SYSLOG_CONFIG)|(SYSTEM_RESET)|(User .* executed the .*(write mem|copy run|copy start|erase).*command)|(cli: +.*: config)" regex

Thanks

---------- Post updated at 10:44 AM ---------- Previous update was at 10:43 AM ----------

Welcome to the forum ob2s. If you run autoexpect and at the command prompt type a pound sign so the OS doesn't do anything with your junky string and then paste it. Type exit and you will see the send command it created out of your junky string. Take that line and paste it into vi and then paste the original string under and do stare and compare to see what it escaped since autoexpect has escaping coded into it.
You will want to run the script.exp it produced and write the output to a file to make sure it is exact the same.
Good luck.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Special Character issue in Expect Utility (Tcl)

Hi, I have written a unix expect utility "ssh-login.exp" which connects (ssh) to remote host and execute some shell script. I am calling this "ssh-login.exp" utility from another shell script. "ssh-login.exp" takes username, password, host and shell script path to execute on remote host. All... (1 Reply)
Discussion started by: Mahesh Desai
1 Replies

2. Shell Programming and Scripting

How to escape Special Characters in Expect programming?

Hi, I have written a unix expect utility "ssh-login.exp" which connects (ssh) to remote host and execute some shell script. I am calling this "ssh-login.exp" utility from another shell script. "ssh-login.exp" takes username, password, host and shell script path to execute on remote host. All... (1 Reply)
Discussion started by: Mahesh Desai
1 Replies

3. Shell Programming and Scripting

expect script with special characters?

Hello all, I'm writing an expect script that will connect to an IMAP server and issue IMAP commands. The problem is that some of the text I need to send includes "quotes" and also !@#$%^&* special characters. For example, my password is VFR$5tgb but I cannot "send" this because Expect doesn't... (2 Replies)
Discussion started by: lupin..the..3rd
2 Replies

4. Shell Programming and Scripting

Replace special characters with Escape characters?

i need to replace the any special characters with escape characters like below. test!=123-> test\!\=123 !@#$%^&*()-= to be replaced by \!\@\#\$\%\^\&\*\(\)\-\= (8 Replies)
Discussion started by: laknar
8 Replies

5. Shell Programming and Scripting

special characters

Hey guys, I'm trying to replace "]Facebook" from the text but sed 's/]Facebook/Johan/g' is not working could you please help me with that? (6 Replies)
Discussion started by: Johanni
6 Replies

6. UNIX for Dummies Questions & Answers

How to see special characters?

Hi all, I was wondering how can i see the special characters like \t, \n or anything else in a file by using Nano or any other linux command like less, more etc (6 Replies)
Discussion started by: gvj
6 Replies

7. Shell Programming and Scripting

Special characters

When I open a file in vi, I see the following characters: \302\240 Can someone explain what these characters mean. Is it ASCII format? I need to trim those characters from a file. I am doing the following: tr -d '\302\240' ---------- Post updated at 08:35 PM ---------- Previous... (1 Reply)
Discussion started by: sid1982
1 Replies

8. UNIX Desktop Questions & Answers

grep with special characters

Hi there I need to grep for a detail from a file. The pattern to search for involves escape sequences in it. This causes for the problem. grep "P\_SOME\_STRING\_SEARCH" filename Note, I have line like below in the file and expect it to grep. select * from my_system_param ... (3 Replies)
Discussion started by: guruparan18
3 Replies

9. Shell Programming and Scripting

unescaping special characters

how do i unescape special characters in Unix. Suppose i've a file named -xyz.txt, how do I remove the file. Ofcourse Icant give rm -xyz.txt thats not gonna work. We can go in regular expression like this ls | grep -e '-'xyz.txt | rm; but I'd like to know any simpler way than this. Thanks... (3 Replies)
Discussion started by: sriram_r
3 Replies

10. UNIX for Dummies Questions & Answers

special characters

I have one file which is named ^? ( the DEL character ) I'd like to know how to rename or copy the file by using its i-node number TYIA (2 Replies)
Discussion started by: nawnaw
2 Replies
Login or Register to Ask a Question