itcl - tcl need a way to get Job Id from the huge string no regexp to use as case can fail -
need fetch job id huge string(1618252) , no regexp operation may fail when job id not found----------
% set invoc [[$this cget -testrun] cget -invocation] tcl profilemgr -confignetwork {} -startbefore -releaseunusedequip 0 \ -profile ptse1-bsd2 -noreserve 0 -noreplace 0 \ -comment {<a href="/testrunscheduler/schedulerjob.rvt?job_id=1618252">profile push: 1618252</a>} \ -attr {} -dur 300minutes -controlassert 0 -rolesubst {} -offline false -nodb 0 \ -image {} -layer2mode mapping -checkleaks 0 -config {} -trace 0 -debug 0 -desc 0 \ -notify 0 -forceprofileip false -clusterhashingmode simple -doconfig true \ -reservation 0 -projects pts_7_20-latest -flavor {} -platformmix {} \ -releasereservation 0 -pkgext {} -emails {} -loadbalancingmode none -enableiom false \ -checkconn 1 -platform ptsvpl-esxi-lnx -pkgview {} -offlinefailedconn 1 -noall 0 \ -ipmode ipv4 -runtype pmgr-run -enableudpprioritization false \ -params {profilemgr:profiletopush "ptse1-bsd2" profilemgr:platform "ptsvpl-esxi-lnx"} \ -swtc_view /m/vmurshilly_lab \ {<br>invocation defaults removed => tcl profilemgr -profile "ptse1-bsd2" -comment "<a href="/testrunscheduler/schedulerjob.rvt?job_id=1618252">profile push: 1618252</a>" -dur "300minutes" -projects "pts_7_20-latest" -platform "ptsvpl-esxi-lnx" -offlinefailedconn "1"}
i tried using regexp failed :
~$tcl % regexp -all .*job_id=(.*)\"> "supercalafrajilistic" match jobid 0 % puts $jobid can't read "jobid": no such variable while evaluating {puts $jobid}
well, aren't running regular expression against string fetched rather dummy “supercalafrajilistic
” data; matters quite bit. need run regular expression in non-greedy mode, doing can simplify things quite bit. finally, should check result of regexp
; in mode you're using, returns number of times regular expression matched, boolean test if found.
set invoc [[$this cget -testrun] cget -invocation] if {[regexp -all {job_id=(.*?)\"} $invoc -> jobid]} { puts "the job id $jobid; yippee" } else { # how recover failure case... puts "warning: no job id found" }
apart that, it's usual things res in tcl (put regular expressions in braces unless know shouldn't, use ->
instead of match
if don't care overall match string readability, etc.)
Comments
Post a Comment