Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

launch a DOS program from a Perl script?

Status
Not open for further replies.

mailint1

Technical User
Nov 10, 2007
13
IT
Can I launch a DOS program from within a Perl script?

____


This is what I need to do:


I have many files like this:
c:\dir\pippo-red.html
c:\dir\paperino-yellow.html
c:\dir\pluto-red.html
c:\dir\gastone-green.html


I have a HTML2TXT.EXE program that converts files from html to txt
(removing the tags etc...).


The syntax of this program is: "HTML2TXT htmlfilename.htm >
txtfilename.txt"


I want to convert all and only the file which path-name match "c:\dir
\*-red.html". The output files must have the suffix "-text" in the
filename and ".txt" as extension.


In a few words the Perl script in this example must execute the
command two times like this:
HTML2TXT c:\dir\pippo-red.html > c:\dir\pippo-red-text.txt
HTML2TXT c:\dir\pluto-red.html > c:\dir\pluto-red-text.txt


Do you know how can I do this?


Thanks in advance for any help
 
This seems to be the solution:
system "HTML2TXT $_ > ".(/(.*)html/)[0]."txt" for <c:/dir/*-red.html>;

but how can I launch it from command-line?
I tried PERL 'system "HTML2TXT $_ > ".(/(.*)html/)[0]."txt" for <c:/dir/*-red.html>;' without success...
sorry for my incompetence..
 
you can use back ticks or qx to run command line programs. So if you wanted to do a dos ping you can do `ping 127.0.0.1`;

You need to provide FULL paths anything you run in a cystem call and you have to escape out any @,$'s, and such

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[noevil]
Travis - Those who say it cannot be done are usually interrupted by someone else doing it; Give the wrong symptoms, get the wrong solutions;
 
The solution was:
perl -e "system qq'HTML2TXT $_ > '.(/(.*)html/)[0].'txt' for <c:/dir/*-red.html>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top