MSFN Forum: How to run perl command in the DOS box - MSFN Forum

Jump to content


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

How to run perl command in the DOS box Rate Topic: -----

#1 User is offline   DosCode 

  • Newbie
  • Group: Members
  • Posts: 47
  • Joined: 15-February 12
  • OS:none specified
  • Country: Country Flag

Posted 17 February 2012 - 04:37 PM

I installed wingnu32 and perl and I try to run such command that should get Title from tags <title>Title</title>

I am not sure, is it possible to run this program in cmd? Maybe I have wrong quoting? I tried few things

1.
for /f "delims=" %a in ('dir /b *.a') do (
pcretest.exe -nle 'print $& if /(?<=title>).*(?=<\/title)/' < %a
)

2.
for /f "delims=" %a in ('dir /b *.a') do (
pcretest.exe -ln0e '$,="\n";print /(?<=<title>).*?(?=<\/title)/sg' < %a
)

3.
for /f "delims=" %a in ('dir /b *.a') do (
%a | pcretest.exe -nle 'print $& if /(?<=title>).*(?=<\/title)/'
)



but I am getting error like: > not expected here...


#2 User is offline   5eraph 

  • Update Packrat
  • Group: Supreme Sponsor
  • Posts: 954
  • Joined: 04-July 05
  • OS:XP Pro x64
  • Country: Country Flag

Posted 17 February 2012 - 05:45 PM

For all instances in CMD scripts, use %%a in place of %a. ;)

#3 User is offline   DosCode 

  • Newbie
  • Group: Members
  • Posts: 47
  • Joined: 15-February 12
  • OS:none specified
  • Country: Country Flag

Posted 17 February 2012 - 06:32 PM

View Post5eraph, on 17 February 2012 - 05:45 PM, said:

For all instances in CMD scripts, use %%a in place of %a. ;)


Sure but this is not batch script, this is directy in CMD, so this %a is correct.

This post has been edited by DosCode: 17 February 2012 - 06:32 PM


#4 User is offline   allen2 

  • Not really Newbie
  • PipPipPipPipPipPipPip
  • Group: Members
  • Posts: 1,737
  • Joined: 13-January 06

Posted 18 February 2012 - 12:59 AM

I wouldn't use pcretest there but sed from the unixtools:
for /f "delims=" %a in ('dir /b *.a') do (type %a | sed.exe -n "s/<title>\(.*\)<\/title>/\1/Ip")



#5 User is offline   DosCode 

  • Newbie
  • Group: Members
  • Posts: 47
  • Joined: 15-February 12
  • OS:none specified
  • Country: Country Flag

Posted 18 February 2012 - 05:00 AM

View Postallen2, on 18 February 2012 - 12:59 AM, said:

I wouldn't use pcretest there but sed from the unixtools:
for /f "delims=" %a in ('dir /b *.a') do (type %a | sed.exe -n "s/<title>\(.*\)<\/title>/\1/Ip")




Thanks. I didn't like sed because it seemed too hard to understand it, but this example with regex looks really simple and understandable.

#6 User is offline   Yzöwl 

  • Wise Owl
  • Group: Super Moderator
  • Posts: 4,364
  • Joined: 13-October 04
  • OS:Windows 7 x64

Posted 18 February 2012 - 09:49 AM

Just make sure that you are searching for a title tag
  • <Title>Required Title Text</TITLE>
    or a title with attribute tag
  • <title="My Title">Required Title Text</TITLE>


Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

2 User(s) are reading this topic
0 members, 2 guests, 0 anonymous users



All trademarks mentioned on this page are the property of their respective owners
Copyright © 2001 - 2013 msfn.org
Privacy Policy