<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
The Perl thread tutorial has lots of example code and is online. <a
href="http://perldoc.perl.org/perlthrtut.html">http://perldoc.perl.org/perlthrtut.html</a>
It has sections on locking and semaphores that you can use to
control access to the log file.<br>
<br>
Ben<br>
<br>
On 3/10/2011 5:07 PM, Greg Brown wrote:
<blockquote
cite="mid:AANLkTikTq21vW_RRbxLvM26y3eSoJ9HAHOhjTgGeJtFv@mail.gmail.com"
type="cite">Ok, I've GOT to get my scripts using threads. Here's
what I've got and what I'd like to do:
<div><br>
</div>
<div>source: a 3000 line file with hostnames, IP addrs, etc.</div>
<div><br>
</div>
<div>what script does: logs into each device using
Net::SSH::Expect that makes configuration changes to IOS devices
(uses Net::SSH::Expect rather than <a moz-do-not-send="true"
href="http://expect.pm">expect.pm</a> because one of our NMS
servers is a windows box and the scripts have to run across all
NMS servers.. sigh)</div>
<div><br>
</div>
<div>how script does it: the guts of the script, the real work, is
all done in a subscript. The main portion of the script opens
the file and creates a foreach loop to process each line (and
device) one at at time. As you might imagine this script takes
a long time to complete. The subscript returns a message to the
main script that is written to a log file ("login failed",
"change implemented", etc).</div>
<div><br>
</div>
<div>what I'd like to do: take a group of devices, say five at at
time, and launch the subscript as a thread so I can process more
than one device at a time. I would imagine this would involve
some kind of flock on the log file so two threads couldn't
return at the same time. John B. sent me some instructions how
to thread a perl script a while back but now I can't find it. </div>
<div><br>
</div>
<div>Does anyone know of a perl book with good and clear examples
that use threads?</div>
<div><br>
</div>
<div>Greg</div>
<pre wrap=""><fieldset class="mimeAttachmentHeader"></fieldset>
_______________________________________________
Trilug-ontopic mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Trilug-ontopic@trilug.org">Trilug-ontopic@trilug.org</a>
<a class="moz-txt-link-freetext" href="http://www.trilug.org/mailman/listinfo/trilug-ontopic">http://www.trilug.org/mailman/listinfo/trilug-ontopic</a>
</pre>
</blockquote>
<br>
</body>
</html>