Sponsored Content
Full Discussion: Expect/Tcl help
Top Forums UNIX for Dummies Questions & Answers Expect/Tcl help Post 302355170 by varontron on Monday 21st of September 2009 10:26:44 PM
Old 09-21-2009
not sure if it will work but you could try setting the entire expect call to a variable

VAR1="expect ..."

and then calling it:

VAR2=`$VAR1`

then it's output would be in $VAR2. Perhaps.

hth,
dv
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

TCL/Expect project questions

I am rewriting the first big script project I ever coded to clean up some issues, mainly my really clumsy bash code, and to migrate to TCL/Expect. I have a couple of questions that I could use some help with. 1.) The script needs to know where it is located. I realize that I could use "find /... (1 Reply)
Discussion started by: thumper
1 Replies

2. Shell Programming and Scripting

Expect with tcl/tk

hai all, i have an tcl script in which i have been reading the DUT Command prompt of an cisco switch as DUT Command Prompt : cisco* and running the test case of stp now the problem is if i have given any blank space in between the cisco or at the startup then the Expect is not identifying the... (0 Replies)
Discussion started by: sanjustudy
0 Replies

3. UNIX for Dummies Questions & Answers

Expect/Tcl help?

Does anyone know of an expect/tcl forum that is as helpful as this one is for shell scripting? Or if anyone has any expect knowledge, can you please provide some guidance on how to write to a local error log based on output from a ssh session? I have something like this: foreach host... (2 Replies)
Discussion started by: earnstaf
2 Replies

4. Shell Programming and Scripting

Tcl expect HELP

In the following "for" loop I assume the the script will expect "anyway", "first" NOT in any paticular order and send "yes" when there found, breaking out of the loop when "$prompt" is found. The way it is working is like 3 individual expect lines, and they MUST be in cronological order. ANY help... (0 Replies)
Discussion started by: dave_m
0 Replies

5. Shell Programming and Scripting

tcl/expect

Can someone identify what is the problem here?. no children while executing "exp_wait -nowait -i -1" (procedure "logOptions" line 45) invoked from within "logOptions" (procedure "doExecute" line 98) invoked from within "doExecute" (procedure "main" line 32) ... (7 Replies)
Discussion started by: calsum
7 Replies

6. Shell Programming and Scripting

Help with TCL/Expect in Solaris 5.3

I'm having this problem with a very simple tcl expect script that is running on Solaris 5.3 with TCL version 8.4.7 and expect version 5.0. below is the simplified version of the code snippet, which I think has everything to illustrate the problem, the full version is at the very bottom in... (0 Replies)
Discussion started by: pinchharmonic
0 Replies

7. Shell Programming and Scripting

TCL/Expect not working as expected

I am having an issue with TCL\Expect; I am passing arguments via the commandline that are read in via "lrange $argv". One of those var's is a password with characters that need to be escapaed, after escaping them an hitting enter expect is placing curly braces around my password... why?! ... (4 Replies)
Discussion started by: RiSk
4 Replies

8. Shell Programming and Scripting

expect TCL script

Hello, I write a TCL script for Expect/ Telnet. I want to send command to the telnet server. But I want to close after the command is sent. Anybody know which command can flush the expect so I can sure the command is sent to the telnet server??? EX: send "./command1\r" close... (0 Replies)
Discussion started by: linboco
0 Replies

9. Shell Programming and Scripting

Convert my shell script into expect/tcl

hi experts, how will i convert the first part of my script into expect or tcl since shell script cannot be embedded into expect script ? i have 100+ servers in my serverlist. how will i call or declare it in expect or tcl ? #!/usr/sbin/expect -f serverlist=`cat $1` for i in serverlist... (2 Replies)
Discussion started by: linuxgeek
2 Replies

10. Red Hat

Issue in installing expect and Tcl

Hi I need to install expect in redhat. through net I came to know that I must install tcl too in order to make expect work. I have downloaded both packages but not able to install # ls -lrt total 3720 18:33 tcl8.4.20-src.tar.gz 18:33 expect5.45.3.tar.gz 18:40 expect5.45.3... (7 Replies)
Discussion started by: scriptor
7 Replies
General::Extended(3pm)					User Contributed Perl Documentation				    General::Extended(3pm)

NAME
Config::General::Extended - Extended access to Config files SYNOPSIS
use Config::General; $conf = new Config::General( -ConfigFile => 'configfile', -ExtendedAccess => 1 ); DESCRIPTION
This is an internal module which makes it possible to use object oriented methods to access parts of your config file. Normally you don't call it directly. METHODS
configfile('filename') Set the filename to be used by save to "filename". It returns the current configured filename if called without arguments. obj('key') Returns a new object (of Config::General::Extended Class) from the given key. Short example: Assume you have the following config: <individual> <martin> age 23 </martin> <joseph> age 56 </joseph> </individual> <other> blah blubber blah gobble leer </other> and already read it in using Config::General::Extended::new(), then you can get a new object from the "individual" block this way: $individual = $conf->obj("individual"); Now if you call getall on $individual (just for reference) you would get: $VAR1 = ( martin => { age => 13 } ); Or, here is another use: my $individual = $conf->obj("individual"); foreach my $person ($conf->keys("individual")) { $man = $individual->obj($person); print "$person is " . $man->value("age") . " years old "; } See the discussion on hash() and value() below. If the key from which you want to create a new object is empty, an empty object will be returned. If you run the following on the above config: $obj = $conf->obj("other")->obj("leer"); Then $obj will be empty, just like if you have had run this: $obj = new Config::General::Extended( () ); Read operations on this empty object will return nothing or even fail. But you can use an empty object for creating a new config using write operations, i.e.: $obj->someoption("value"); See the discussion on AUTOLOAD METHODS below. If the key points to a list of hashes, a list of objects will be returned. Given the following example config: <option> name = max </option> <option> name = bea </option> you could write code like this to access the list the OOP way: my $objlist = $conf->obj("option"); foreach my $option (@{$objlist}) { print $option->name; } Please note that the list will be returned as a reference to an array. Empty elements or non-hash elements of the list, if any, will be skipped. hash('key') This method returns a hash(if it is one!) from the config which is referenced by "key". Given the sample config above you would get: my %sub_hash = $conf->hash("individual"); print Dumper(\%sub_hash); $VAR1 = { martin => { age => 13 } }; array('key') This the equivalent of hash() mentioned above, except that it returns an array. Again, we use the sample config mentioned above: $other = $conf->obj("other"); my @blahs = $other->array("blah"); print Dumper(@blahs); $VAR1 = [ "blubber", "gobble" ]; value('key') This method returns the scalar value of a given key. Given the following sample config: name = arthur age = 23 you could do something like that: print $conf->value("name") . " is " . $conf->value("age") . " years old "; You can use this method also to set the value of "key" to something if you give over a hash reference, array reference or a scalar in addition to the key. An example: $conf->value("key", \%somehash); # or $conf->value("key", @somearray); # or $conf->value("key", $somescalar); Please note, that this method does not complain about existing values within "key"! is_hash('key') is_array('key') is_scalar('key') As seen above, you can access parts of your current config using hash, array or scalar methods. But you are right if you guess, that this might become problematic, if for example you call hash() on a key which is in real not a hash but a scalar. Under normal circumstances perl would refuse this and die. To avoid such behavior you can use one of the methods is_hash() is_array() is_scalar() to check if the value of "key" is really what you expect it to be. An example(based on the config example from above): if($conf->is_hash("individual") { $individual = $conf->obj("individual"); } else { die "You need to configure a "individual" block! "; } exists('key') This method returns just true if the given key exists in the config. keys('key') Returns an array of the keys under the specified "key". If you use the example config above you yould do that: print Dumper($conf->keys("individual"); $VAR1 = [ "martin", "joseph" ]; If no key name was supplied, then the keys of the object itself will be returned. You can use this method in foreach loops as seen in an example above(obj() ). delete ('key') This method removes the given key and all associated data from the internal hash structure. If 'key' contained data, then this data will be returned, otherwise undef will be returned. AUTOLOAD METHODS
Another usefull feature is implemented in this class using the AUTOLOAD feature of perl. If you know the keynames of a block within your config, you can access to the values of each individual key using the method notation. See the following example and you will get it: We assume the following config: <person> name = Moser prename = Peter birth = 12.10.1972 </person> Now we read it in and process it: my $conf = new Config::General::Extended("configfile"); my $person = $conf->obj("person"); print $person->prename . " " . $person->name . " is " . $person->age . " years old "; This notation supports only scalar values! You need to make sure, that the block <person> does not contain any subblock or multiple identical options(which will become an array after parsing)! If you access a non-existent key this way, Config::General will croak an error. You can turn this behavior off by setting -StrictObjects to 0 or "no". In this case undef will be returned. Of course you can use this kind of methods for writing data too: $person->name("Neustein"); This changes the value of the "name" key to "Neustein". This feature behaves exactly like value(), which means you can assign hash or array references as well and that existing values under the given key will be overwritten. COPYRIGHT
Copyright (c) 2000-2010 Thomas Linden This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. BUGS
none known yet. AUTHOR
Thomas Linden <tlinden |AT| cpan.org> VERSION
2.05 perl v5.10.1 2010-12-01 General::Extended(3pm)
All times are GMT -4. The time now is 07:01 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy