Visit Our UNIX and Linux User Community

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

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How can expect match the pattern "$", instead of take it as a wild card
# 1  
Old 11-09-2009
Data 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 card and match it to everything.

Is there a way to tell expect take the "$" literally?

Thanks in adv
# 2  
Old 11-09-2009
something like this '$'.
# 3  
Old 11-09-2009
Not quite get your point.

I enabled the exp_internal and updated the line with:

expect -re "#|'$'"

The output is:
Last login: Mon Nov 9 13:21:06 from host1
Sun Microsystems Inc. SunOS 5.10 Generic January 2005

expect: does " \r\nLast login: Mon Nov 9 13:21:06 from host1\r\nSun Microsystems Inc. SunOS 5.10 Generic January 2005\r\n" (spawn_id exp7) match regular expression "#|'$'"? no
expect: does " \r\nLast login: Mon Nov 9 13:21:06 from zcyds232.asiapa\r\nSun Microsystems Inc. SunOS 5.10 Generic January 2005\r\n$ " (spawn_id exp7) match regular expression "#|'$'"? no
expect: timed out
faxstat: Timed out after 5 seconds.

Although the "$" is shown in the telnet output....but the script doesn't match it...

also tried:

expect -re '$'

doesn't work either
# 4  
Old 11-09-2009
I never used "expect" , let me check if i found any i will let u know.

Previous Thread | Next Thread
Test Your Knowledge in Computers #85
Difficulty: Easy
Windows 7, Windows 8, Windows RT, Windows Phone 8, Windows Server, and the Xbox One's operating system all used the Windows NT kernel.
True or False?

9 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. UNIX for Dummies Questions & Answers

Egrep confusion with "I" and "-I" pattern

I am executing following command egrep -w I filename.txt the filename.txt has following data .... -I 07-18 08:31:19.924 9880 6 SessionManager ConnectConfig: ConfigurationWebService LoginResults=SuccessfulLogin I am so hungry that I need to eat I expect egrep to print only the second... (1 Reply)
Discussion started by: VBG
1 Replies

6. Shell Programming and Scripting

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\\\"\\\"... (3 Replies)
Discussion started by: prakasuj
3 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

BASH find filenames in list that match certain "pattern."

I guess by "pattern," I mean something different from how that word is defined in the Linux world. If you take $ to mean a letter (a-z) and # to mean a number (0-9), then the pattern I'm trying to match is as follows: $$$##-####-###-###.jpg I'd like to write a script that reads in a list of files... (4 Replies)
Discussion started by: SilversleevesX
4 Replies

9. UNIX for Dummies Questions & Answers

Explain the line "mn_code=`env|grep ""|awk -F"=" '{print $2}'`"

Hi Friends, Can any of you explain me about the below line of code? mn_code=`env|grep ""|awk -F"=" '{print $2}'` Im not able to understand, what exactly it is doing :confused: Any help would be useful for me. Lokesha (4 Replies)
Discussion started by: Lokesha
4 Replies

Featured Tech Videos