Perl match multiline string and replace -


i have file located in remote host.i want replace string cronexpression value="* 30 9 ? * mon-fri" cronexpression value="* $hour $min ? * mon-fri" in file.

input file is: test.properties

its contents like:

<bean id="disconnectcrontrigger" class="org.springframework.scheduling.quartz.cronfactorybean"> <property name="jobdetail" ref="delaydisconnectjobdetail" /> <property name="cronexpression" value="* 30 20 ? * mon-fri" /> </bean> <bean id="retryjobdetail" class="org.springframework.scheduling.quartz.methodinvokingjobdetailfactorybean"> <property name="targetobject" ref="retrymetercommandjob" /> <property name="targetmethod" value="executeall" /> </bean> <bean id="retrycrontrigger" class="org.springframework.scheduling.quartz.crontriggerfactorybean"> <property name="jobdetail" ref="retryjobdetail" /> <property name="cronexpression" value="* 30 9 ? * mon-fri" /> </bean> 

i tried below mentioned code failed replace

%opts =(user => 'xxxxx', password => '1234444'); $ssh = net::openssh->new("$host", %opts); $ssh->error , die "can't ssh $host: " . $ssh->error;  $pathfolder="perl -pi -e  'sm/\<property name=\"jobdetail\"    ref=\"delaydisconnectjobdetail\" \/\>.*?             \<property name=\"cronexpression\" value=\"\* 30 20 \? \* mon\-fri\" /\<property name=\"jobdetail\"    ref=\"delaydisconnectjobdetail\" \/\>.*?             \<property name=\"cronexpression\" value=\"\* **40 10** \? \* mon\-fri\"/gsm'     /test.properties"; $ssh->system("$pathfolder") or     die "remote command failed: " . $ssh->error;  <property name="targetmethod" value="executeall" /> </bean> <bean id="retrycrontrigger" class="org.springframework.scheduling.quartz.crontriggerfactorybean"> <property name="jobdetail" ref="retryjobdetail" /> <property name="cronexpression" value="* 30 9 ? * mon-fri" /> </bean> 

there no sm/// in perl. substitution operator s/// , match operator m//. gave syntax error. doing through command line when have perl bit strange.

you can savely use xml parser, if not installed in remote host. take @ object::remote, lets run perl code , use perl modules local machine on remote machine through ssh. the author mst talks in the __end__ of everything.


Comments

Popular posts from this blog

javascript - Google App Script ContentService downloadAsFile not working -

javascript - Function overwritting -

php - Find a regex to take part of Email -