Using asterisk as a regular symbol in expect script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Using asterisk as a regular symbol in expect script
# 1  
Old 02-27-2012
Using asterisk as a regular symbol in expect script

Hi there.
I wrote an expect script to restart nimbus service on multiple solaris 10 boxes, but following code part is not working for me
Code:
send "svcadm restart nimbus && sleep 1\r"
        send "svcs nimbus |awk '/nimbus/ {print \$1}'\r"
        expect {
                "online*"       {sleep 2; send "svcs nimbus |awk '/nimbus/ {print \$1}'\r"; exp_continue}
                "maintenance"   {send "svcadm clear nimbus\rexit\r"}
                "online"        {exit}
                }

The asterisk there is being treated as wildcard, but i need it to be treated as regular symbol. I tried to backslash it, and tried to use single quotes instead of double ones, but both ways brought me no luck. Pls suggest
# 2  
Old 02-27-2012
How regular, just a char with no meta? Multiple backslash? [*]? Expect is tk/tcl, whose rules are still mostly a mystery to me.

I have written many expect scripts by just logging all output directly to a file, and having the input generator script read the output file to decide what input to generate.

Back door solution: be in a dir with no such entry name, perhaps an empty dir you create and change to. Unexpandable * is just *.
# 3  
Old 02-27-2012
Thanks! I tried two backslashes instead of one and it worked
# 4  
Old 02-27-2012
Only two! I have been up to 16 in FrEd, the friendly editor from Waterloo.

BTW, there is a tool called autoexpect that, by following a session, writes too-explicit example expect scripts.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

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

2. Programming

Calling another expect script inside an expect script

I have an expect script called remote that I want to call from inside my expect script called sudoers.push, here is the code that is causing me issues: set REMOTE "/root/scripts/remote" ... log_user 1 send_user "Executing remote script as $user...\n" send_user "Command to execute is: $REMOTE... (1 Reply)
Discussion started by: brettski
1 Replies

3. Programming

Calling expect script inside another expect

Hi, Am very new to expect scripting.. Can You please suggest me how to call an expect script inside another expect script.. I tried with spawn /usr/bin/ksh send "expect main.exp\r" expect $root_prompt and spawn /usr/bin/ksh send "main.exp\r" expect $root_prompt Both... (1 Reply)
Discussion started by: Priya Amaresh
1 Replies

4. Solaris

/usr/lib/passwdutil.so.1: symbol __nsl_fgetspent_r: referenced symbol not found

deleteing post (0 Replies)
Discussion started by: dshakey
0 Replies

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

6. Shell Programming and Scripting

Use asterisk in shell script bash

Hello, I am trying to save in a file a single "*" but its not working... look what i am doing... FILE="/home/teste/a.txt" ...BEGIN... ASTERISK="*" echo "STRING $ASTERISK STRING" >> $FILE ...END... when i do it, the result is a list of all files of the current... (4 Replies)
Discussion started by: diogooute
4 Replies

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

8. Shell Programming and Scripting

how to pass variables from Asterisk to a C-script

Hi!I'm trying to write a script in C that Asterisk must call: I would to pass to the script a number digited by the user, make some elaboration with it and then pass the result to Asterisk. I don't understand the mechanism used by Asterisk to pass variable to/from a script: I know that variables... (1 Reply)
Discussion started by: lucio82
1 Replies

9. Shell Programming and Scripting

passing asterisk to a script as variable

I'm writing a script that will ssh to a number of hosts and run commands. I'm a bit stumped at the moment as some of the commands that I need to run contain wildcards (i.e. *), and so far I have not figured out how to escape the * character so the script doesn't expand it. More specifically, here's... (9 Replies)
Discussion started by: GKnight
9 Replies
Login or Register to Ask a Question