Sponsored Content
Top Forums Shell Programming and Scripting Trying to parse expect_out(buffer) Post 302923491 by imatinkerer on Monday 3rd of November 2014 10:24:15 AM
Old 11-03-2014
EXCELLENT!! WORKS GREAT!!
Thank you, Chubler XL!!SmilieSmilieSmilie
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help with expect expect_out

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)
Discussion started by: expect_user
5 Replies

2. Shell Programming and Scripting

expect_out(buffer) empty

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)
Discussion started by: ugobale
1 Replies

3. Shell Programming and Scripting

expect_out buffer no such variable running script background

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)
Discussion started by: shellscripter
0 Replies

4. Shell Programming and Scripting

Problems with expect_out command

expect "#" send "terminal-length 0\r" expect "#" send "show mp cpu\r" expect "#" send "show mp memory\r" expect "#" while {1} { expect "#" send "clear counters\r" sleep 30 ... (0 Replies)
Discussion started by: roh_20022002
0 Replies

5. Programming

[SOLVED] Flushing expect_out(buffer) inside a loop

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)
Discussion started by: SuperSix4
0 Replies

6. Shell Programming and Scripting

Parsing expect_out using regex in expect script

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)
Discussion started by: ashy_g
5 Replies

7. Shell Programming and Scripting

Expect_out(buffer) works but it doesn't get all lines

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)
Discussion started by: capacho6666
6 Replies

8. Shell Programming and Scripting

Expect_out help!!!

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)
Discussion started by: cityprince143
2 Replies

9. Programming

Flushing expect_out(buffer)

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)
Discussion started by: cityprince143
0 Replies

10. Shell Programming and Scripting

Jumbled output in expect_out(buffer)

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
Math::Trig(3pm) 					 Perl Programmers Reference Guide					   Math::Trig(3pm)

NAME
Math::Trig - trigonometric functions SYNOPSIS
use Math::Trig; $x = tan(0.9); $y = acos(3.7); $z = asin(2.4); $halfpi = pi/2; $rad = deg2rad(120); DESCRIPTION
"Math::Trig" defines many trigonometric functions not defined by the core Perl which defines only the "sin()" and "cos()". The constant pi is also defined as are a few convenience functions for angle conversions. TRIGONOMETRIC FUNCTIONS
The tangent tan The cofunctions of the sine, cosine, and tangent (cosec/csc and cotan/cot are aliases) csc, cosec, sec, sec, cot, cotan The arcus (also known as the inverse) functions of the sine, cosine, and tangent asin, acos, atan The principal value of the arc tangent of y/x atan2(y, x) The arcus cofunctions of the sine, cosine, and tangent (acosec/acsc and acotan/acot are aliases) acsc, acosec, asec, acot, acotan The hyperbolic sine, cosine, and tangent sinh, cosh, tanh The cofunctions of the hyperbolic sine, cosine, and tangent (cosech/csch and cotanh/coth are aliases) csch, cosech, sech, coth, cotanh The arcus (also known as the inverse) functions of the hyperbolic sine, cosine, and tangent asinh, acosh, atanh The arcus cofunctions of the hyperbolic sine, cosine, and tangent (acsch/acosech and acoth/acotanh are aliases) acsch, acosech, asech, acoth, acotanh The trigonometric constant pi is also defined. $pi2 = 2 * pi; ERRORS DUE TO DIVISION BY ZERO The following functions acoth acsc acsch asec asech atanh cot coth csc csch sec sech tan tanh cannot be computed for all arguments because that would mean dividing by zero or taking logarithm of zero. These situations cause fatal runtime errors looking like this cot(0): Division by zero. (Because in the definition of cot(0), the divisor sin(0) is 0) Died at ... or atanh(-1): Logarithm of zero. Died at... For the "csc", "cot", "asec", "acsc", "acot", "csch", "coth", "asech", "acsch", the argument cannot be 0 (zero). For the "atanh", "acoth", the argument cannot be 1 (one). For the "atanh", "acoth", the argument cannot be "-1" (minus one). For the "tan", "sec", "tanh", "sech", the argument cannot be pi/2 + k * pi, where k is any integer. SIMPLE (REAL) ARGUMENTS, COMPLEX RESULTS Please note that some of the trigonometric functions can break out from the real axis into the complex plane. For example asin(2) has no definition for plain real numbers but it has definition for complex numbers. In Perl terms this means that supplying the usual Perl numbers (also known as scalars, please see perldata) as input for the trigonometric functions might produce as output results that no more are simple real numbers: instead they are complex numbers. The "Math::Trig" handles this by using the "Math::Complex" package which knows how to handle complex numbers, please see Math::Complex for more information. In practice you need not to worry about getting complex numbers as results because the "Math::Complex" takes care of details like for example how to display complex numbers. For example: print asin(2), " "; should produce something like this (take or leave few last decimals): 1.5707963267949-1.31695789692482i That is, a complex number with the real part of approximately 1.571 and the imaginary part of approximately "-1.317". PLANE ANGLE CONVERSIONS
(Plane, 2-dimensional) angles may be converted with the following functions. $radians = deg2rad($degrees); $radians = grad2rad($gradians); $degrees = rad2deg($radians); $degrees = grad2deg($gradians); $gradians = deg2grad($degrees); $gradians = rad2grad($radians); The full circle is 2 pi radians or 360 degrees or 400 gradians. The result is by default wrapped to be inside the [0, {2pi,360,400}[ cir- cle. If you don't want this, supply a true second argument: $zillions_of_radians = deg2rad($zillions_of_degrees, 1); $negative_degrees = rad2deg($negative_radians, 1); You can also do the wrapping explicitly by rad2rad(), deg2deg(), and grad2grad(). RADIAL COORDINATE CONVERSIONS
Radial coordinate systems are the spherical and the cylindrical systems, explained shortly in more detail. You can import radial coordinate conversion functions by using the ":radial" tag: use Math::Trig ':radial'; ($rho, $theta, $z) = cartesian_to_cylindrical($x, $y, $z); ($rho, $theta, $phi) = cartesian_to_spherical($x, $y, $z); ($x, $y, $z) = cylindrical_to_cartesian($rho, $theta, $z); ($rho_s, $theta, $phi) = cylindrical_to_spherical($rho_c, $theta, $z); ($x, $y, $z) = spherical_to_cartesian($rho, $theta, $phi); ($rho_c, $theta, $z) = spherical_to_cylindrical($rho_s, $theta, $phi); All angles are in radians. COORDINATE SYSTEMS Cartesian coordinates are the usual rectangular (x, y, z)-coordinates. Spherical coordinates, (rho, theta, pi), are three-dimensional coordinates which define a point in three-dimensional space. They are based on a sphere surface. The radius of the sphere is rho, also known as the radial coordinate. The angle in the xy-plane (around the z-axis) is theta, also known as the azimuthal coordinate. The angle from the z-axis is phi, also known as the polar coordinate. The `North Pole' is therefore 0, 0, rho, and the `Bay of Guinea' (think of the missing big chunk of Africa) 0, pi/2, rho. In geographical terms phi is lat- itude (northward positive, southward negative) and theta is longitude (eastward positive, westward negative). BEWARE: some texts define theta and phi the other way round, some texts define the phi to start from the horizontal plane, some texts use r in place of rho. Cylindrical coordinates, (rho, theta, z), are three-dimensional coordinates which define a point in three-dimensional space. They are based on a cylinder surface. The radius of the cylinder is rho, also known as the radial coordinate. The angle in the xy-plane (around the z-axis) is theta, also known as the azimuthal coordinate. The third coordinate is the z, pointing up from the theta-plane. 3-D ANGLE CONVERSIONS Conversions to and from spherical and cylindrical coordinates are available. Please notice that the conversions are not necessarily reversible because of the equalities like pi angles being equal to -pi angles. cartesian_to_cylindrical ($rho, $theta, $z) = cartesian_to_cylindrical($x, $y, $z); cartesian_to_spherical ($rho, $theta, $phi) = cartesian_to_spherical($x, $y, $z); cylindrical_to_cartesian ($x, $y, $z) = cylindrical_to_cartesian($rho, $theta, $z); cylindrical_to_spherical ($rho_s, $theta, $phi) = cylindrical_to_spherical($rho_c, $theta, $z); Notice that when $z is not 0 $rho_s is not equal to $rho_c. spherical_to_cartesian ($x, $y, $z) = spherical_to_cartesian($rho, $theta, $phi); spherical_to_cylindrical ($rho_c, $theta, $z) = spherical_to_cylindrical($rho_s, $theta, $phi); Notice that when $z is not 0 $rho_c is not equal to $rho_s. GREAT CIRCLE DISTANCES AND DIRECTIONS
You can compute spherical distances, called great circle distances, by importing the great_circle_distance() function: use Math::Trig 'great_circle_distance'; $distance = great_circle_distance($theta0, $phi0, $theta1, $phi1, [, $rho]); The great circle distance is the shortest distance between two points on a sphere. The distance is in $rho units. The $rho is optional, it defaults to 1 (the unit sphere), therefore the distance defaults to radians. If you think geographically the theta are longitudes: zero at the Greenwhich meridian, eastward positive, westward negative--and the phi are latitudes: zero at the North Pole, northward positive, southward negative. NOTE: this formula thinks in mathematics, not geographi- cally: the phi zero is at the North Pole, not at the Equator on the west coast of Africa (Bay of Guinea). You need to subtract your geo- graphical coordinates from pi/2 (also known as 90 degrees). $distance = great_circle_distance($lon0, pi/2 - $lat0, $lon1, pi/2 - $lat1, $rho); The direction you must follow the great circle can be computed by the great_circle_direction() function: use Math::Trig 'great_circle_direction'; $direction = great_circle_direction($theta0, $phi0, $theta1, $phi1); The result is in radians, zero indicating straight north, pi or -pi straight south, pi/2 straight west, and -pi/2 straight east. Notice that the resulting directions might be somewhat surprising if you are looking at a flat worldmap: in such map projections the great circles quite often do not look like the shortest routes-- but for example the shortest possible routes from Europe or North America to Asia do often cross the polar regions. EXAMPLES
To calculate the distance between London (51.3N 0.5W) and Tokyo (35.7N 139.8E) in kilometers: use Math::Trig qw(great_circle_distance deg2rad); # Notice the 90 - latitude: phi zero is at the North Pole. @L = (deg2rad(-0.5), deg2rad(90 - 51.3)); @T = (deg2rad(139.8),deg2rad(90 - 35.7)); $km = great_circle_distance(@L, @T, 6378); The direction you would have to go from London to Tokyo use Math::Trig qw(great_circle_direction); $rad = great_circle_direction(@L, @T); CAVEAT FOR GREAT CIRCLE FORMULAS The answers may be off by few percentages because of the irregular (slightly aspherical) form of the Earth. The formula used for grear circle distances lat0 = 90 degrees - phi0 lat1 = 90 degrees - phi1 d = R * arccos(cos(lat0) * cos(lat1) * cos(lon1 - lon01) + sin(lat0) * sin(lat1)) is also somewhat unreliable for small distances (for locations separated less than about five degrees) because it uses arc cosine which is rather ill-conditioned for values close to zero. BUGS
Saying "use Math::Trig;" exports many mathematical routines in the caller environment and even overrides some ("sin", "cos"). This is con- strued as a feature by the Authors, actually... ;-) The code is not optimized for speed, especially because we use "Math::Complex" and thus go quite near complex numbers while doing the com- putations even when the arguments are not. This, however, cannot be completely avoided if we want things like asin(2) to give an answer instead of giving a fatal runtime error. AUTHORS
Jarkko Hietaniemi <jhi@iki.fi> and Raphael Manfredi <Raphael_Manfredi@pobox.com>. perl v5.8.0 2002-06-01 Math::Trig(3pm)
All times are GMT -4. The time now is 01:44 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy