Linux

From iMacros
Jump to: navigation, search

Note: As of 2013/1/1 we no longer support or update the Linux version of the Scripting Interface

iMacros Scripting Interface for Linux

The Linux version of the Scripting Interface is free for all users of the iMacros Unlimited Player License (US$ 399.00). Note that the Player (and thus iMacros for Linux) is included at no extra costs in all iMacros Enterprise Bundles. So for most use cases, we highly recommend our Enterprise Bundles. They contain all licenses you need at a great discount.

iMacros works fine on 32-bit and 64-bit systems. Just note that the iMacros Scripting Interface needs 32bit Python, also on a x64 system. The reason is, Firefox and Chrome itself are 32bit applications.

Important: iMacros for Firefox 7.4.* contains bigger interface changes and is not yet supported with the Linux Scripting Interface. Please use iMacros for Firefox 7.3.x along with Firefox 6 or lower. This combination is tested and supported.

Download

This download is a free trial. It shows a small registration reminder at start.

  • Vice versa, if you already own an iMacros Player License for Windows then the Linux version is available at no extra cost for you.
Imacros linux.png

How to Set Up

  1. Unzip the zipped archive, cd to extracted directory
  2. Install iMacros for Firefox add-on (imacros.xpi) V7.1.1.2 or later Available only here, not yet on Mozilla Addons page
  3. Make sure that Python 2.6 is installed on your system
  4. Either run python scripts from the extracted directory or modify your LD_LIBRARY_PATH environment variable

How to Test

Run minimal example

#!/usr/bin/python
import imacros
iret = imacros.iimInit("-fx", True)
iret = imacros.iimPlay("CODE:URL GOTO=http://www.iopus.com")
iret = imacros.iimExit()

Remember to use the "-fxProfile" option if you want to run a lot of instances at once. This way cookies are not shared between instances.

Comprehensive Code Sample

Have a look at example.py (note: this needs demo macros Demo-*.iim installed in the iMacros macro directory; default location is $HOME/iMacros/Macros/)

Bindings to other languages

The package includes TCPClient.h file which defines scripting interface library API. See imacros.py for example.

For example, Ruby support: We found two Ruby libraries which can be used to call functions from shared libraries (i.e. dll).

First is dl - quite familiar naming and plain interface.

Second is ffi - this looks more modern and preferred way.

If you create samples for Ruby, PHP or any other language, please email them to support AT iopus.com and we will publish them there. You can also post it in our forum.

License Key

The license is free for all users of the iMacros Unlimited Player License (US$ 399.00). Note that the Player is included at no extra costs in all iMacros Enterprise Bundles. Please email sales AT iopus.com with your Player license key (it starts with "KD....."), and we send you a special key for the Linux version (your Windows license key will not work).

Scheduling iMacros Using Cron

The main difficulty when trying to schedule scripts (that use iMacros) is that the Scripting Interface won't find your license key, even if you have already entered it before. In order to solve that issue, we will create a "wrapper" for starting the script which feeds the license key to the Scripting Interface every time the wrapper is called. Additionally, the wrapper can be used to keep the cron entry short.

Prerequisites

In the following we assume that you have

  1. installed the iMacros for Firefox plugin
  2. downloaded and extracted the iMacros for Linux Scripting Interface to some folder we'll call /home/name/iMacrosLinux, here
  3. created a minimal sample script /home/name/iMacrosLinux/minimal.py:
#!/usr/bin/python
import imacros
iret = imacros.iimInit("-fx", True)
iret = imacros.iimPlay("CODE:URL GOTO=http://www.iopus.com")
iret = imacros.iimExit()

Make sure the sample script works when called from the command line:

/home/name/iMacrosLinux/minimal.py

Preparing cron

Add an entry to your crontab with

crontab -e

that looks like this

# m h  dom mon dow   command
# * * * * * /home/name/iMacrosLinux/cron.sh >> /home/name/iMacrosLinux/cron.log 2>&1

This way, cron will call a helper script cron.sh every minute (adjust if necessary) and redirect standard output as well as standard error to a file cron.log. As we do not yet have the wrapper in place, the task is disabled/commented out.

Watch the logs

In order to "see what happens" (especially in case of error), you may want to open two terminals. One that watches /var/log/syslog for information about cron and another that watches our script's log:

tail -f /var/log/syslog
tail -f /home/name/iMacrosLinux/cron.log

Create the wrapper

Create a wrapper file /home/name/iMacrosLinux/cron.sh with the following content (explanation inside):

#!/bin/bash

# The macro will run in Firefox, so we need to determine
# what screen to use
export DISPLAY=:0

# The iMacros Scripting Interface binaries reside in
# /home/name/iMacrosLinux, so we chage to that directory 
# before running the script
cd /home/name/iMacrosLinux

# If you want to skip entering the license key, uncomment the 
# following line that enters "c" when asked for the license key.
# The comment out everything below.
#/home/name/iMacrosLinux/minimal.py <<<'c'

# Call the script and enter the license key when the 
# Scripting Interface asks for it
#
# IMPORTANT: Note the 'r' in front of the key. It tells the
# Scripting Interface that we want to enter the license. So if
# the license were '1234', that line would read 'r1234'.
/home/name/iMacrosLinux/minimal.py << EOF
rHERE_COMES_THE_KEY
EOF

Activate the cron entry

  1. Remove the leading '#' from the cron entry
  2. Wait for cron to trigger the wrapper
  3. Have an eye on the consoles that watch syslog and the script's cron.log

Known limitations

Distro-Specific Info

Ubuntu 10.10

  • Works "out-of-the-box".
  • No extra packages needed.
  • Just perform the setup as described above.

Debian 6.0 "Squeeze"

  • No extra libraries needed.
  • In case of a minimal setup, add "iceweasel", "unzip", "xorg" and "fluxbox" (or the like)
  • Perform setup as described above.

Fedora 14

  • Works "out-of-the-box"
  • No extra packages needed.
  • Just perform the setup as described above.

openSUSE 11.3 (Gnome)

  • Works "out-of-the-box"
  • No extra packages needed.
  • Just perform the setup as described above.

Sabayon 5.4 (Gnome)

  • Works "out-of-the-box"
  • No extra packages needed.
  • Just perform the setup as described above.

See Also

iMacros for Firefox, iMacros for Chrome, Mac