I'm not sure how to articulate this question other then describing the problem and putting out hope that someone will point me in the right direction. I have written a bash script that calls a macro from iMacros. The macro looks like below:
VERSION BUILD=8920312 RECORDER=FX
TAB T=1
URL GOTO=http://www.event.com/schedual
SET !EXTRACT_TEST_POPUP NO
SET !ERRORIGNORE YES
TAG POS={{!LOOP}} TYPE=A ATTR=TXT:02 EXTRACT=HTM
SAVEAS TYPE=EXTRACT FOLDER=/root/Desktop FILE=TodaysEvents.csv
TAB CLOSE
The macro works when its ran from the browser using the play loop button. However, when I attempt to run the macro inside a bash script, it only extracts the first instance in the loop and exits. The command I ran looks like this:
iceweasel "imacros://run/?m=TodaysEvents.iim"
Is there a special syntactics to run imacros from the terminal that involves loops? I'm running off of Debian and using the iMacros Firefox extention if that helps.
As Shugar pointed out, the only solution is to use javascript. The scripting interface the comes with iMacros Browser is different from the built in JavaScript interpreter in Firefox iMacros. The iMacros Browser only works on windows, so its a bummer for linux users, yet the Firefox add-on is universal. The steps below will help anybody coming accross the problem in this posting of the "!LOOP" failing from the command line.
`Step 1) Record your macro as you would normally. You can look at the above for an example.`
`Step 2) Write a JavaScript file like below and save in the same folder as the rest of your imacros scripts (~/iMacros/Macros), with the .js extention.`
const L = "\n";
iimPlayCode("TAB T=1" + L + "URL GOTO=http://www.event.com/schedual" + L);
for (i = 1; i < 130; i++) {
iimSet("loop", i);
iimPlayCode("SET !ERRORIGNORE YES" + L + "TAG POS={{loop}} TYPE=A ATTR=TXT:02 EXTRACT=HTM" + L + "SAVEAS TYPE=EXTRACT FOLDER=/root/Desktop FILE=TodaysEvents.csv" + L);
}
The trick is you have to go back to your TodaysEvents.iim (original example) script and put all the code into the iimPlayCode declaration like above and change the "{{!LOOP}} into "{{loop}}". Also, in case your wondering the "i < 130" in the JavaScript means that you would like the script to loop up to 130 times and the "URL GOTO" has to be declared outside the for loop. You can then run the loop from the command line by using:
firefox "imacros://run/?m=TodaysEvents.js"