[ale] perl and environment stuff

James P. Kinney III jkinney at localnetsolutions.com
Wed Dec 27 08:09:01 EST 2006


On Tue, 2006-12-26 at 23:39 -0500, Mike Fletcher wrote:

> > Suggestions on where to look?
> >   
> Something else is wrong then; append mode (">>") is append mode and 
> nothing in the environment should change that.
> 
That's been my thinking all along. But I ran it yesterday from the
console (all printer configs happy) and again from a remote shell (which
dumped the previous configs for only the last one). It's the same script
on the same machine each time. The changing factor is where I'm logged
in from. 
> 
> I'd look at anything else that may be manipulating the file (maybe 
> something's calling lpadmin that you're not aware of, and the two of you 
> are bumping heads).  Also consider adding in extra debugging prints, 
> such as dumping the size of $filetowrite from a stat() call before and 
> after your opens.  If all else fails, use strace (possibly with -f to 
> follow forks) to record what sequence of system calls are being made in 
> the two different environments and see what's different between the two.
> 
I'm 99.99% sure there's no other lpadmin action happening (the glitch is
very consistent - not a one-time thing). lpoptions get a call when a
login occurs to set the default printer but that doesn't  (_shouldn't_)
affect the file in question AND there's no login activity at this time.
These servers are not currently in use by anyone so it's either me doing
the setups or another of the team. But we use radio's so we don't try to
run the script at the same time (Bad Things will happen with other parts
of it - tinkering with logins, etc).

Looks like strace is going to get a workout on this.
> 
> (And stylistic aside: the three argument form of open is preferred these 
> days, presuming you're using a recent enough Perl that it works.  So 
> you'd want:
> 
> open( FILEOUT, ">>", $filetowrite ) or die "Append to '$filewrite' 
> failed: $!\n";

v. 5.8.8 should handle it OK. Thanks for the tips. (So I learned some
old stuff on v. 4.x that I haven't given up yet... :)
> 
> instead of the two argument form.  Also another minor nit, it's slightly 
> more efficient to call
> 
> print FILEOUT $stuff, "\n";
> 
> with two arguments, as that'll avoid creating a temporary copy of $stuff 
> and the newline and passing that to print.)

Very good to know as my work around will be to simply append in perl and
rewrite the entire file.
> 
> 
> 
> 
> _______________________________________________
> Ale mailing list
> Ale at ale.org
> http://www.ale.org/mailman/listinfo/ale
-- 
James P. Kinney III          
CEO & Director of Engineering 
Local Net Solutions,LLC        
770-493-8244                    
http://www.localnetsolutions.com

GPG ID: 829C6CA7 James P. Kinney III (M.S. Physics)
<jkinney at localnetsolutions.com>
Fingerprint = 3C9E 6366 54FC A3FE BA4D 0659 6190 ADC3 829C 6CA7
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part




More information about the Ale mailing list