Expect scripting - How to match a double quotes " "


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Expect scripting - How to match a double quotes " "
# 1  
Old 06-13-2012
Expect scripting - How to match a double quotes " "

I am trying to match a text which contains the " ", from the log file. But it doesn't match. I understand that " " has got a special meaning to TCL/Expect.
hence I tried the following, but no luck.
expect -ex {
"lp -c -demail -ot\\\"firstname_surname@gmail.com\\\" /usr/local/spool/pf"
{
incr logged
send_user "\r\n LOGGED #4, $logged \r\n"
}
timeout
I tried using \ , \\ and \\\ but no luck yet.
Can anyone help, Please..
My log file contains the following line,
exec [lp -c -demail -ot"firstname_surname@gmail.com" /usr/loc
al/spool/pf/context/ABC001-1209236.mime]
and I need to match that line.
# 2  
Old 06-14-2012
I'm not positive but try this:
Code:
set string "lp -c -demail -ot\"firstname_surname@gmail.com\" /usr/local/spool/pf"

expect -re $string { incr logged
                     send_user "\r\n LOGGED #4, $logged \r\n"
                   }
           timeout

# 3  
Old 06-14-2012
That was my first try.. But no luck.
I even tried \\" and \\\"... But no luck...Smilie
# 4  
Old 06-16-2012
Ok, this is some info I found:
Code:
Match a "quoted string"
proc quoted-string {str} {
    regexp {^"(?:[^\\"]|\\.)*"$} $str
}

This recognizes strings starting and ending with double quote characters.
Any character can be embedded in the string, even double quotes, when preceded by an odd number of backslashes.

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Search file containing ps results for a match "my.cnf" and then for a second match . "ok:" and

I need to find two matches in the output from ps. I am searching with ps -ef |grep mysql for: my.cnf /bin/sh /usr/bin/mysqld_safe --defaults-file=/data/mysql/master/agis_core/etc/my.cnf after this match I want to search back and match the hostname which is x number of lines back, above the... (2 Replies)
Discussion started by: bash_in_my_head
2 Replies

2. Shell Programming and Scripting

Bash script - Print an ascii file using specific font "Latin Modern Mono 12" "regular" "9"

Hello. System : opensuse leap 42.3 I have a bash script that build a text file. I would like the last command doing : print_cmd -o page-left=43 -o page-right=22 -o page-top=28 -o page-bottom=43 -o font=LatinModernMono12:regular:9 some_file.txt where : print_cmd ::= some printing... (1 Reply)
Discussion started by: jcdole
1 Replies

3. Shell Programming and Scripting

Expect: spawn id exp5 not open while executing "expect "$" { send "sudo su -\r" }"

Hi All, i am trying to ssh to a remote machine and execute certain command to remote machine through script. i am able to ssh but after its getting hung at the promt and after pressing ctrl +d i am gettin the out put as expect: spawn id exp5 not open while executing "expect "$" {... (3 Replies)
Discussion started by: Siddharth shivh
3 Replies

4. UNIX for Advanced & Expert Users

AIX - io info get from "libperfstat" not match "iostat"

Hi, everyone. I need to write a program to get io info based on libperfstat. But the "write time" of a disk is just half of the value get from iostat. I'm confused and can't explain. Help please. How I calculate "write service time per sec": In iostat: write service... (0 Replies)
Discussion started by: jackliang
0 Replies

5. Shell Programming and Scripting

Replacing double quotes with the unicodes "urgent!"

Hi, I have the following text in a file <div class="snippet abstract"> We present a new "model" for multiple-input-multiple-output (MIMO) 'outdoor' has many things "what" ever </div></a href=sdfkkf"> </div> <div class="snippet context"> I have to replace the string between the <div... (1 Reply)
Discussion started by: vms
1 Replies

6. Shell Programming and Scripting

Expect Scripting - Using the "interact" command?

Hello All, I am writing an Expect Script to execute some commands over ssh then exit the script. The script works just fine if I automate everything and assuming the correct password was entered. So this Expect Script gets executed from a Bash script... From the Bash script I pass along an... (0 Replies)
Discussion started by: mrm5102
0 Replies

7. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

8. Shell Programming and Scripting

How can expect match the pattern "$", instead of take it as a wild card

I am writing a expect script. during the expect, i need check the out to see whether i logged in: set password "1234" spawn telnet host1 expect "login:" send "guest\n" expect "password:" send $password expect -re "#|$" puts "Logged in" But it seems that expect takes "$" as a wild... (3 Replies)
Discussion started by: sleepy_11
3 Replies

9. Shell Programming and Scripting

Removal of comma(,) present inbetween double quotes(" ")

Hi Experts, I have a file with some of the records contain double quotes. If I found a double quote(") in any particular record , I need to look for the next double quote in that particular record and in between these quotes, if any comma(,) is there I need to replace with Tilde (~) in the same... (12 Replies)
Discussion started by: vsairam
12 Replies

10. Shell Programming and Scripting

comparing scalars contaning "DOUBLE QUOTES" as data

Hello to all, Does anyone know the solution ? Two strings A and B are present. I want to check whether B is a Substring of A. 1. The value of A is - 29 * * * /bin/ls "test" "tmp*" "log*" (Note: Pl note that A contains DOUBLEQUOTES, ASTERISK & FRONTSLASH) 2. The value of B is -... (5 Replies)
Discussion started by: rssrik
5 Replies
Login or Register to Ask a Question