This is a proprietary front-end user interface riding on (what I believe to be) a Linux shell and, as such, the UI prevents access to the Linux command set.
The eventual command that I want to "send" is
Code:
send "delete file config $configfile"
There can be anywhere from one to ten files stored in the directory, so I need to parse the expect_out(buffer) for each file name, load that name into the variable configfile and then execute the above command, the repeat for as many files that are listed (I imagine using something like a foreach statement).
This is my simple expect scritpt:
#!/usr/bin/expect -f
match_max 100000
set timeout -1
spawn telnet $IP
expect "#"
send -- "shell\r"
expect "*Ready*"
send -- "init\r"
expect "*Ready*"
send -- "readsensor \r"
expect -- "*" <<< Output of this is a 2 digit number
set val... (5 Replies)
I have only some info into my buffer, but after a rssi command I see the folowing lines expected into buffer but not present :
rssi=-106
rssi=-109
I see in my buffer only the first part of the output, here you are a part of script :
#!/usr/bin/expect -f
#global expect_out
match_max 10000000... (1 Reply)
I am trying to use send and receive using expect. the expect_out(buffer) is working fine while it is running it as foreground. But the same script when it is ran as background, the expect_out(buffer) errored out.
Is there any factor influence when we run script in foreground and in background? ... (0 Replies)
Greetings,
Having an issue with the expect_out(buffer). in a foreach loop through some switches I am grabbing some arp table information and writing it out to output files (1 each for each switch looped through).
The first iteration works fine. the second iteration of the loop writes the... (0 Replies)
Hi,
I am trying to write an expect script. Being a newbie in expect, maybee this is a silly doubt but i am stuck here.
So essentially , i want the o/p of one router command to be captured . Its something like this
Stats
Input Rx : 1234
Input Bytes : 3456
My expect script looks ... (5 Replies)
Hello "expect" experts
I am new at Expect. I have searched for a little while how to capture multiple lines with Expect and I am almost succeeded on that but I don't get all the lines of a command's output that the script executes on a server.
Here is how my script works in a nutshell -
... (6 Replies)
I am trying to read a file via SSH connect and store it to expect_out(buffer). I am a virgin to expect. Help is really appreciated. Wasted almost a day :-(
Code is as follows
expect "system32>"
send "type output.csv";
send "\r";
expect "system32>"
set outcome $expect_out(buffer)... (2 Replies)
Can some one tell me how to flush expect_out(buffer)?
below is my code
expect -re {.*} {}
expect "swpackages>*"
send -i $con "trial.bat \r"
set outcome $expect_out(buffer)
expect "*continue*"
set prevreport $expect_out(buffer)
send "\r \r";
problem is :- I am getting "pre" stuffs... (0 Replies)
I have a code like this :
set ipv6_acl_max_chars test_acl_max_chars123456a789%s%d2345678ww134rt789qa23456789012345%c89012%a56789012x4r67890test_acl_max_chars1234567890.01234aabcdob34567aBC0
spawn telnet $myip
expect "Login:" { send "admin\r" }
expect "Password:" {send "admin\r" }... (0 Replies)
Discussion started by: ylucki
0 Replies
LEARN ABOUT DEBIAN
moosex::configfromfile
MooseX::ConfigFromFile(3pm) User Contributed Perl Documentation MooseX::ConfigFromFile(3pm)NAME
MooseX::ConfigFromFile - An abstract Moose role for setting attributes from a configfile
SYNOPSIS
########
## A real role based on this abstract role:
########
package MooseX::SomeSpecificConfigRole;
use Moose::Role;
with 'MooseX::ConfigFromFile';
use Some::ConfigFile::Loader ();
sub get_config_from_file {
my ($class, $file) = @_;
my $options_hashref = Some::ConfigFile::Loader->load($file);
return $options_hashref;
}
########
## A class that uses it:
########
package Foo;
use Moose;
with 'MooseX::SomeSpecificConfigRole';
# optionally, default the configfile:
sub configfile { '/tmp/foo.yaml' }
# ... insert your stuff here ...
########
## A script that uses the class with a configfile
########
my $obj = Foo->new_with_config(configfile => '/etc/foo.yaml', other_opt => 'foo');
DESCRIPTION
This is an abstract role which provides an alternate constructor for creating objects using parameters passed in from a configuration file.
The actual implementation of reading the configuration file is left to concrete subroles.
It declares an attribute "configfile" and a class method "new_with_config", and requires that concrete roles derived from it implement the
class method "get_config_from_file".
Attributes specified directly as arguments to "new_with_config" supercede those in the configfile.
MooseX::Getopt knows about this abstract role, and will use it if available to load attributes from the file specified by the commandline
flag "--configfile" during its normal "new_with_options".
Attributes
configfile
This is a Path::Class::File object which can be coerced from a regular pathname string. This is the file your attributes are loaded from.
You can add a default configfile in the class using the role and it will be honored at the appropriate time:
has +configfile ( default => '/etc/myapp.yaml' );
Note that you can alternately just provide a "configfile" method which returns the config file when called - this will be used in
preference to the default of the attribute.
Class Methods
new_with_config
This is an alternate constructor, which knows to look for the "configfile" option in its arguments and use that to set attributes. It is
much like MooseX::Getopts's "new_with_options". Example:
my $foo = SomeClass->new_with_config(configfile => '/etc/foo.yaml');
Explicit arguments will overide anything set by the configfile.
get_config_from_file
This class method is not implemented in this role, but it is required of all subroles. Its two arguments are the classname and the
configfile, and it is expected to return a hashref of arguments to pass to "new()" which are sourced from the configfile.
COPYRIGHT
Copyright (c) 2007 - 2009 the MooseX::ConfigFromFile "AUTHOR" and "CONTRIBUTORS" as listed below.
AUTHOR
Brandon L. Black, <blblack@gmail.com>
CONTRIBUTORS
Tomas Doran "<bobtfish@bobtfish.net>" (current maintainer).
Karen Etheridge
Chris Prather
Zbigniew Lukasiak
LICENSE
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
perl v5.14.2 2011-12-17 MooseX::ConfigFromFile(3pm)