Connecting Tech Pros Worldwide Help | Site Map

pipe output to a perl script

  #1  
Old September 16th, 2008, 09:34 PM
Newbie
 
Join Date: Sep 2008
Posts: 2
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
  #2  
Old September 17th, 2008, 01:09 AM
KevinADC's Avatar
Expert
 
Join Date: Jan 2007
Location: Southern California USA
Posts: 4,097

re: pipe output to a perl script


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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Using subprocess module to launch a shell shell script that itselfforks a process Samuel A. Falvo II answers 7 October 9th, 2008 09:05 PM
proc_open on windows: can't get stdin to a perl script kimonp answers 2 August 13th, 2007 03:34 AM
how to detect broken pipe ? funtoosh answers 1 July 19th, 2005 05:51 AM
Best way to run a perl script from php on windows? Justin answers 2 July 17th, 2005 05:22 AM