Writing Perl output to a file and the terminal window

I’m not a Perl programmer by any means, but I needed to work with iMapSync. One of the requirements was to create a log file of everything that is written to the terminal window while still updating the output in the terminal window.

My buddy Ryan S. figured it out for me:

perl [script] [args] 2>&1 | tee -a [file to write output to]

He even gave me an example based on what I’d sent him:

perl imapsync -host1 host1.example.com -user1 ltest100@example.com -authuser1 user1 -password1 pwd1 -host2 host2.anotherserver.com -user2 ltest100@anotherserver.com -password2 pwd2 -authmech2 PLAIN -ssl2 –fast –reconnectretry2 1 –useheader ‘Message-Id’ –useheader ‘Message-ID’ –skipsize –delete2 –uidexpunge2 –expunge2 -debug 2>&1 | tee -a IMapSyncLog.txt

Many thanks to Ryan! 🙂


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s