View unanswered posts | View active topics It is currently 28 Jul 2014 06:19



Post new topic Reply to topic  [ 27 posts ]  Go to page Previous  1, 2
ErrorLevel Command Required? 
Author Message

Joined: 10 Feb 2012 02:20
Posts: 4022
Post Re: ErrorLevel Command Required?
Try this:

Code:
set "mFinURL=%mURL1%%%G%mURL2%%%G%mURL3%"

for /f "delims=" %%G in (id.txt) do (
wget --http-user=%IMSUSER% --http-password=%IMSPASS% --tries=10 -O - >> C:\Users\MatthewM.MEDICAGROUP\Desktop\UnreportorAssignBatch\%ims% %mFinURL%
)

CLS

set "mFinSPS=%mURL1%%%b%mURL2%%%b%mURL4%%%b%mURL5%%%c"
rem This opens the IMS and logs in
::start OpenIMS.exe
ping localhost -n 10 > nul

rem This reads the accession numbers in acc.txt searches ims.txt and outputs the id to variable %%a and spsid to variable %%c
for /f "delims=" %%a in ('type "acc.txt"') do (
for %%z in ('sed -n "s/.*&sps_id=[0-9][0-9][0-9][0-9][0-9][0-9][0-9]');.><td>%%a.*<td>\(.*\)<\/td>.*<\/td>.*/\1/p" "ims.txt"') do (
for /f "tokens=1,2" %%b in ('sed -n "s/.*=\(.*\)&sps_id=\([0-9][0-9][0-9][0-9][0-9][0-9][0-9]\)');.><td>%%a.*/\1 \2/p" "ims.txt"') do (

echo the reference "%%a" returns ID="%%b" and number "%%c"
if "%%z"=="Unreported" echo and Unreported was found

start chrome.exe %mFinSPS%
ping localhost -n 6 > nul
rem This runs a AHK script which unreports the exams on the IMS
if not "%%z"=="Unreported" start ChangeToKT.exe
ping localhost -n 6 > nul
)
)
)


18 May 2012 21:28
Profile

Joined: 02 May 2012 14:42
Posts: 54
Post Re: ErrorLevel Command Required?
foxidrive wrote:
Try this:

Code:
set "mFinURL=%mURL1%%%G%mURL2%%%G%mURL3%"

for /f "delims=" %%G in (id.txt) do (
wget --http-user=%IMSUSER% --http-password=%IMSPASS% --tries=10 -O - >> C:\Users\MatthewM.MEDICAGROUP\Desktop\UnreportorAssignBatch\%ims% %mFinURL%
)

CLS

set "mFinSPS=%mURL1%%%b%mURL2%%%b%mURL4%%%b%mURL5%%%c"
rem This opens the IMS and logs in
::start OpenIMS.exe
ping localhost -n 10 > nul

rem This reads the accession numbers in acc.txt searches ims.txt and outputs the id to variable %%a and spsid to variable %%c
for /f "delims=" %%a in ('type "acc.txt"') do (
for %%z in ('sed -n "s/.*&sps_id=[0-9][0-9][0-9][0-9][0-9][0-9][0-9]');.><td>%%a.*<td>\(.*\)<\/td>.*<\/td>.*/\1/p" "ims.txt"') do (
for /f "tokens=1,2" %%b in ('sed -n "s/.*=\(.*\)&sps_id=\([0-9][0-9][0-9][0-9][0-9][0-9][0-9]\)');.><td>%%a.*/\1 \2/p" "ims.txt"') do (

echo the reference "%%a" returns ID="%%b" and number "%%c"
if "%%z"=="Unreported" echo and Unreported was found

start chrome.exe %mFinSPS%
ping localhost -n 6 > nul
rem This runs a AHK script which unreports the exams on the IMS
if not "%%z"=="Unreported" start ChangeToKT.exe
ping localhost -n 6 > nul
)
)
)



Hello,

This does not appear to be working, it is not finding the word "Unreported" and carrying on running the exe.

Thanks,
Matt


21 May 2012 05:24
Profile

Joined: 10 Feb 2012 02:20
Posts: 4022
Post Re: ErrorLevel Command Required?
edited by mistake


Last edited by foxidrive on 21 May 2012 06:55, edited 2 times in total.



21 May 2012 05:32
Profile

Joined: 02 May 2012 14:42
Posts: 54
Post Re: ErrorLevel Command Required?
Hell foxi,

It echos:

the extra line reports "'sed"

Just incase you miss it from the above, it is " 'sed"

Thanks,
Matt


21 May 2012 06:17
Profile

Joined: 10 Feb 2012 02:20
Posts: 4022
Post Re: ErrorLevel Command Required?
Thanks. That tells me where the error is - I left /f off the for command. Try this

Code:
set "mFinURL=%mURL1%%%G%mURL2%%%G%mURL3%"

for /f "delims=" %%G in (id.txt) do (
wget --http-user=%IMSUSER% --http-password=%IMSPASS% --tries=10 -O - >> C:\Users\MatthewM.MEDICAGROUP\Desktop\UnreportorAssignBatch\%ims% %mFinURL%
)

CLS

set "mFinSPS=%mURL1%%%b%mURL2%%%b%mURL4%%%b%mURL5%%%c"
rem This opens the IMS and logs in
::start OpenIMS.exe
ping localhost -n 10 > nul

rem This reads the accession numbers in acc.txt searches ims.txt and outputs the id to variable %%a and spsid to variable %%c
for /f "delims=" %%a in ('type "acc.txt"') do (
for /f "delims=" %%z in ('sed -n "s/.*&sps_id=[0-9][0-9][0-9][0-9][0-9][0-9][0-9]');.><td>%%a.*<td>\(.*\)<\/td>.*<\/td>.*/\1/p" "ims.txt"') do (
for /f "tokens=1,2" %%b in ('sed -n "s/.*=\(.*\)&sps_id=\([0-9][0-9][0-9][0-9][0-9][0-9][0-9]\)');.><td>%%a.*/\1 \2/p" "ims.txt"') do (

echo the reference "%%a" returns ID="%%b" and number "%%c"

if "%%z"=="Unreported" echo and Unreported was found

start chrome.exe %mFinSPS%
ping localhost -n 6 > nul
rem This runs a AHK script which unreports the exams on the IMS
if not "%%z"=="Unreported" start ChangeToKT.exe
ping localhost -n 6 > nul
)
)
)


21 May 2012 06:55
Profile

Joined: 02 May 2012 14:42
Posts: 54
Post Re: ErrorLevel Command Required?
Hello Foxi,

Works well on the first ID, when it moves onto the next it doesnt work. Here is the text it will be referring to when looking for %%z.

</script><h2>Booking Management</h2><b>Procedures for </b><br><b>%%b</b><p><table class="infotab" cellpadding="4" cellspacing="1"><tr><th>Procedure ID</th><th>Scheduled Date</th><th>Procedure Code</th><th>Procedure Room</th><th>Modality</th><th>Consultant</th><th>Requester</th><th>Referrer</th><th>Report State</th><th>Images</th></tr><tr class="c1" onClick="ii0('op=editexam&patient_id=%%b&sps_id=1234567');"><td>ABC1234</td><td>Jan 10 2012 12:00AM</td><td>R FEMUR</td><td></td><td>CR</td><td>KT</td><td> </td><td></td><td>Unreported</td><td>1</td></tr><tr class="c2" onClick="ii0('op=editexam&patient_id=%%b&sps_id=2345678');"><td>BCD1234</td><td>Mar 30 2012 1:54PM</td><td>CT CT Sinuses</td><td></td><td>CT</td><td>DNR</td><td> </td><td></td><td>Do not report</td><td>335</td></tr></table><p>Click on a row to select that procedure.<p><input type="button" value="Make New Booking" onClick="location.href='/booking.php?op=newexam&patient_id=%%b';"><p><input type="button" value="Back To Patient" onClick="location.href='/booking.php?op=querypatid&patient_id=%%b';"> <input type="button" value="New Query" onClick="location.href='/booking.php';"></center></body></html>

Is it a problem with the search criteria? There are many <td> and </td> so do you think it is getting confused?

Thanks,
Matt


21 May 2012 07:58
Profile

Joined: 10 Feb 2012 02:20
Posts: 4022
Post Re: ErrorLevel Command Required?
Yes, it is confused Matt. There needs to be a common entry that sed can use to limit the search. Regular expressions using SED are classed as 'greedy' and it will search to the LAST match in the string and not the NEXT match, unless there is some text that can anchor sed to an entry.

I think it is also time to consider that whenever someone changes the web page then this type of parsing of HTML using SED is going to break, and be difficult for you to fix.

You can still use batch files but I think the way to go is to download the web page as you are doing and then run it through a HTML to TEXT converter, and then use batch files to parse the text information. The text would be similar to what you would have when you use the SAVE AS text option in a web browser, or a text converter can add delimiters also.

HTMstrip by Bruce Guthrie is a rather dated free MSDOS command line tool but is limited to short filenames. There may be better modern tools.

Try this on the web page and see if it gives you the information you need - the format can be changed.

Code:
htmstrip /border=t page.htm


21 May 2012 17:11
Profile

Joined: 10 Feb 2012 02:20
Posts: 4022
Post Re: ErrorLevel Command Required?
So a way around this problem with "Unreported" might be in the following (untested):

It uses HTMSTRIP and converts the IMS.TXT before the loop starts, then before ChangeToKT.exe runs it checks for the current %%a entry line and sees if "Unreported" is in the line and it will launch ChangeToKT.exe if it is not found.

Code:
set "mFinURL=%mURL1%%%G%mURL2%%%G%mURL3%"

for /f "delims=" %%G in (id.txt) do (
wget --http-user=%IMSUSER% --http-password=%IMSPASS% --tries=10 -O - >> C:\Users\MatthewM.MEDICAGROUP\Desktop\UnreportorAssignBatch\%ims% %mFinURL%
)

CLS

set "mFinSPS=%mURL1%%%b%mURL2%%%b%mURL4%%%b%mURL5%%%c"
rem This opens the IMS and logs in
::start OpenIMS.exe
ping localhost -n 10 > nul

htmstrip /border=t ims.txt

rem This reads the accession numbers in acc.txt searches ims.txt and outputs the id to variable %%a and spsid to variable %%c
for /f "delims=" %%a in ('type "acc.txt"') do (
for /f "tokens=1,2" %%b in ('sed -n "s/.*=\(.*\)&sps_id=\([0-9][0-9][0-9][0-9][0-9][0-9][0-9]\)');.><td>%%a.*/\1 \2/p" "ims.txt"') do (

echo the reference "%%a" returns ID="%%b" and number "%%c"

start chrome.exe %mFinSPS%
ping localhost -n 6 > nul
rem This runs a AHK script which unreports the exams on the IMS
find "| %%a " <ims.out |find "Unreported">nul || start ChangeToKT.exe
ping localhost -n 6 > nul
)
)
del ims.out


21 May 2012 23:02
Profile

Joined: 02 May 2012 14:42
Posts: 54
Post Re: ErrorLevel Command Required?
Hello Foxi,

Bit of a pain, it seems HTMSTRIP only works on 32 bit. I cannot seem to find a 64 bit version anywhere, are you aware of any 64 versions?

Thanks,
Matt


22 May 2012 00:33
Profile

Joined: 10 Feb 2012 02:20
Posts: 4022
Post Re: ErrorLevel Command Required?
Download this tool and try the following.

http://www.nirsoft.net/utils/htmlastext.html


Code:
set "mFinURL=%mURL1%%%G%mURL2%%%G%mURL3%"

for /f "delims=" %%G in (id.txt) do (
wget --http-user=%IMSUSER% --http-password=%IMSPASS% --tries=10 -O - >> C:\Users\MatthewM.MEDICAGROUP\Desktop\UnreportorAssignBatch\%ims% %mFinURL%
)

CLS

set "mFinSPS=%mURL1%%%b%mURL2%%%b%mURL4%%%b%mURL5%%%c"
rem This opens the IMS and logs in
::start OpenIMS.exe
ping localhost -n 10 > nul

(
echo [Config]
echo OpenInNotepad=0
echo CharsPerLine=75
echo Source=ims.txt
echo Dest=ims.out
echo SkipTitleText=0
echo AddLineUnderHeader=0
echo SkipTableHeaderText=0
echo TableCellDelimit=2
echo HeadingLineChars=======
echo HorRuleChar==
echo ListChars=*o-@#
echo ConvertMode=1
echo AllowCenterText=0
echo AllowRightText=0
echo DLSpc=8
echo LinksDisplayFormat=%T
echo EncloseBoldCharsStart=^<^<
echo EncloseBoldCharsEnd=^>^>
echo EncloseBold=0
echo SubFolders=0
) >ims.cfg

HtmlAsText.exe /run "%cd%\ims.cfg"


rem This reads the accession numbers in acc.txt searches ims.txt and outputs the id to variable %%a and spsid to variable %%c
for /f "delims=" %%a in ('type "acc.txt"') do (
for /f "tokens=1,2" %%b in ('sed -n "s/.*=\(.*\)&sps_id=\([0-9][0-9][0-9][0-9][0-9][0-9][0-9]\)');.><td>%%a.*/\1 \2/p" "ims.txt"') do (

echo the reference "%%a" returns ID="%%b" and number "%%c"

start chrome.exe %mFinSPS%
ping localhost -n 6 > nul
rem This runs a AHK script which unreports the exams on the IMS
findstr "^%%a," ims.out |find "Unreported">nul || start ChangeToKT.exe
ping localhost -n 6 > nul
)
)
del ims.out
del ims.cfg


22 May 2012 02:41
Profile

Joined: 02 May 2012 14:42
Posts: 54
Post Re: ErrorLevel Command Required?
foxidrive wrote:
Download this tool and try the following.

http://www.nirsoft.net/utils/htmlastext.html


Code:
set "mFinURL=%mURL1%%%G%mURL2%%%G%mURL3%"

for /f "delims=" %%G in (id.txt) do (
wget --http-user=%IMSUSER% --http-password=%IMSPASS% --tries=10 -O - >> C:\Users\MatthewM.MEDICAGROUP\Desktop\UnreportorAssignBatch\%ims% %mFinURL%
)

CLS

set "mFinSPS=%mURL1%%%b%mURL2%%%b%mURL4%%%b%mURL5%%%c"
rem This opens the IMS and logs in
::start OpenIMS.exe
ping localhost -n 10 > nul

(
echo [Config]
echo OpenInNotepad=0
echo CharsPerLine=75
echo Source=ims.txt
echo Dest=ims.out
echo SkipTitleText=0
echo AddLineUnderHeader=0
echo SkipTableHeaderText=0
echo TableCellDelimit=2
echo HeadingLineChars=======
echo HorRuleChar==
echo ListChars=*o-@#
echo ConvertMode=1
echo AllowCenterText=0
echo AllowRightText=0
echo DLSpc=8
echo LinksDisplayFormat=%T
echo EncloseBoldCharsStart=^<^<
echo EncloseBoldCharsEnd=^>^>
echo EncloseBold=0
echo SubFolders=0
) >ims.cfg

HtmlAsText.exe /run "%cd%\ims.cfg"


rem This reads the accession numbers in acc.txt searches ims.txt and outputs the id to variable %%a and spsid to variable %%c
for /f "delims=" %%a in ('type "acc.txt"') do (
for /f "tokens=1,2" %%b in ('sed -n "s/.*=\(.*\)&sps_id=\([0-9][0-9][0-9][0-9][0-9][0-9][0-9]\)');.><td>%%a.*/\1 \2/p" "ims.txt"') do (

echo the reference "%%a" returns ID="%%b" and number "%%c"

start chrome.exe %mFinSPS%
ping localhost -n 6 > nul
rem This runs a AHK script which unreports the exams on the IMS
findstr "^%%a," ims.out |find "Unreported">nul || start ChangeToKT.exe
ping localhost -n 6 > nul
)
)
del ims.out
del ims.cfg


Works perfectly, thanks :) Little question, how is it you have so much knowledge on all of this??

Do you know much about Auto Hot Key?


22 May 2012 05:14
Profile

Joined: 10 Feb 2012 02:20
Posts: 4022
Post Re: ErrorLevel Command Required?
Glad it works. I've never used auto hot key...


22 May 2012 05:47
Profile
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 27 posts ]  Go to page Previous  1, 2


Who is online

Users browsing this forum: Bing [Bot], Google [Bot], ShadowThief and 28 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Forum style by Vjacheslav Trushkin for Free Forums/DivisionCore.