Connecting Tech Pros Worldwide Help | Site Map

pipe output to a perl script

Newbie
 
Join Date: Sep 2008
Posts: 2
#1: Sep 16 '08
Hello,

I currently have an application in perl that starts a text based torrent client, once I give the necessary parameters to the torrent.exe it will start printing out the following information and of course downloading the files.

Quote:
saving: Images (12680.2 MB)
percent done: 4.8
time left: checking existing data download
to: q:\Image
download rate:
upload rate:
share rating:
seed status:
peer status:
I have no problem starting the process and piping its output to a log file to read it (currently what I do). However the file is getting very big to loop around it. I do have to say I have idea how to read just the last part of the file and since I cant kill the torrent.exe the output just gets appended to the bottom of the log file and can not modify the log file since it is still open by the exe.

I want to create a perl (or maybe use something else) to pipe the output of the exe so that I can query the last values. Say for example my file is call run_torrent.pl, I want to send a command to this file like "run_torrent.pl --percent" and get back the value that was last printed by torrent.exe (the exe does not have these option)

My current limitation is that Im running this from Windows and I can not execute the torrent.exe program again, because it will kill the last download I started.

I am not sure what I am looking for, or how to make my query of the process simpler. I know its a bit confusing but I could really use some help. Some one suggested using StreamReader, but I dont get how I would start the program from the streamreader and how to query it. Running Active perl 5

Thanks for any suggestion,
Afelotreyu
KevinADC's Avatar
Expert
 
Join Date: Jan 2007
Location: Southern California USA
Posts: 4,091
#2: Sep 17 '08

re: pipe output to a perl script


Look into IPC::Open2 or IPC::Open3 both come with perl
Reply