expect script with special characters?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting expect script with special characters?
# 1  
Old 01-24-2012
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 like the $ symbol.

So

expect "OK"
send "a01 login lupin VFR$5tgb\r"

Does not work, expect thinks the $ is denoting a variable.

Also, I need to send the following IMAP command:

a02 list "" "*"

however it contains quotation marks. So I cannot wrap the whole thing in quotation marks or Expect does not interpret it properly.

expect "a01 OK"
send "a02 list "" "*"\r"

does not work as Expect doesn't parse the quotation marks properly.

I've tried google search but can't find any relevant results.

Any Expect gurus that can point me in the right direction? Thank you

Last edited by lupin..the..3rd; 01-24-2012 at 11:04 PM..
# 2  
Old 01-25-2012
since no other replies yet..

it's been a long time since i've wrote in tcl, but the easiest solution would be to put a backslash before these special characters.
example:

Code:
send "a01 login lupin VFR\$5tgb\r"

send "a02 list \"\" \"*\""

This User Gave Thanks to neutronscott For This Post:
# 3  
Old 01-25-2012
Quote:
Originally Posted by neutronscott
since no other replies yet..

it's been a long time since i've wrote in tcl, but the easiest solution would be to put a backslash before these special characters.
example:

Code:
send "a01 login lupin VFR\$5tgb\r"

send "a02 list \"\" \"*\""

perfect, that did the trick! thanks. Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Tcsh script - sed command for special characters

Hi, I am using sed command to replace following line in gz file- sed -n 's/""COS_12_TM_1" ( 1101110101001001010011110100000010110100010010000000100000000010XX010000000 )"/""COS_12_TM_1" ( 110111010100100101001111MM00000010110100010010000000100000000010XX010000000 )"/g' filename.gz $x=... (4 Replies)
Discussion started by: Preeti Chandra
4 Replies

2. 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

3. Shell Programming and Scripting

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... (0 Replies)
Discussion started by: ob2s
0 Replies

4. 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

5. Shell Programming and Scripting

script to tail file; problem with awk and special characters

Trying to use code that I found to send only new lines out of a log file by doing: while :; do temp=$(tail -1 logfile.out) awk "/$last/{p=1}p" logfile.out #pipe this to log analyzer program last="$temp" sleep 10 done Script works fine when logfile is basic text, but when it contains... (2 Replies)
Discussion started by: moo72moo
2 Replies

6. 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

7. Shell Programming and Scripting

Single/Multiple Line with Special characters - Find & Replace in Unix Script

Hi, I am creating a script to do a find and replace single/multiple lines in a file with any number of lines. I have written a logic in a script that reads a reference file say "findrep" and populates two variables $FIND and $REPLACE print $FIND gives Hi How r $u Rahul() Note:... (0 Replies)
Discussion started by: r_sarnayak
0 Replies

8. Shell Programming and Scripting

SED script to backslash special characters

I have a shell script that I have written to be a kind of to-do/notepad that's quickly executable from the command line. However, special characters tend to break it pretty well. Ie: "notes -a This is an entry." works fine. "notes -a This is (my) entry." will toss back a bash syntax error on... (5 Replies)
Discussion started by: skylersee
5 Replies

9. UNIX for Dummies Questions & Answers

Need help to escape special characters in Korn shell script

Hi, I would like to display the following message from my shell (Korn) script Copy "old_file.txt" to "new_file.txt" My code looks as follows print "Copy "old_file.txt" to "new_file.txt"" However, when I execute the script, I get the following output Copy old_file.txt to... (6 Replies)
Discussion started by: rogers42
6 Replies

10. Shell Programming and Scripting

Check for special characters in a script

Hi All, In my shell script, i'm checking the date input against few constraints. It should be of YYYYMMDD format and the script should prompt the user with error message, if less than 8 digits are present or input contains special characters (*,&,%,^,$ ...etc). The script i'm using is given... (7 Replies)
Discussion started by: sumesh.abraham
7 Replies
Login or Register to Ask a Question