I am trying to collect logs from a system in expert mode. Where I login to system and then change mode to expert mode and issue command to collect the log. I have a script which works but It waits for 30 mins even though log collection is complete before that. I have two issues with existing script.
1. Since log collection takes really long time (sometimes about 30 minutes). Expect script does not wait for the prompt and exits at timeout value. So I don't get complete O/P. Hence, I added timeout value of 1800 secs. But this one forces script to wait for 30 mins. I would like to exit as soon as I am back on prompt. I tried using expect exact but need some help on this.
2. How can I capture the current prompt itself as a variable and ask Expect to wait until it gets the prompt. or Make a prompt based on Username variable and hostname lie - USERNAME@SYSNAME##.
If it waits for the full 30 minutes, it means that expect does not see the string you are waiting for.
You are writing
which means that you are waiting for the string "(.*)## $" to appear somewhere. I don't think this is what you want to achieve.
You can use exact, if you know the exact sequence of characters. In your case, it seems to me more natural do do an anchored regular expression matching, to cope for variations in, say, whitespace, for example
Please see it only as a suggestion to start with. I don't know what's in your output in general, and you have to judge by yourself, how to write the regexp so that you don't accidentally catch a line in your logs which looks the same.
Well, that it doesn't timeout, I can understand: You are executing exp_continue in the case of timeout, which means that you cancel the timeout and continue waiting.
Now to the case why it doesn't match. You are using a globbing match here, so the pattern should match whenever a line contains the string "PA@" and later in the same line "## ". My guess is that for whatever reason, such a line is not delivered.
After fixing the timeout issue, have a look at the $expect_out(buffer) whether you can find there the line you are looking for.
Appreciate help for the below issue.
Im using below code.....I dont want to attach the logs when I ran the perl twice...I just want to take backup with today date and generate new logs...What I need to do for the below scirpt..............
1)if logs exist it should move the logs with extention... (1 Reply)
Hi Gurus
I need to collect the logs between two time stamp... The log files 12 hours format (ex- Nov 14, 2013 12:10:16 AM UTC) I tried the below commands but no luck.
awk '$0 >= "Nov 14, 2013 9:40:01" && $0 <= "Nov 14, 2013 9:55:01"' file
sed -n '/Nov 14, 2013 7:58:00 PM UTC/,/Nov 14, 2013... (5 Replies)
Hi,
I have two questions,first of all is where can I collect more error logs(the log under /var/log/messages), also give the corresponding explain is grateful.The second one is the log under various versions(such as red hat,suse,etc) is the same or not.
Thanks for answers. (1 Reply)
Hi All,
I am writing a script(Auto_Installation.sh) which is calling one another script (./update_manager /spare/install/HO7/PME_Response_file.txt)
Now the issue is result of (./update_manager /spare/install/HO7/PME_Response_file.txt) script is
##########################################... (6 Replies)
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)
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)