Results 1 to 1 of 1

Thread: Automating IMacros from shell script

Threaded View

  1. #1
    Senior Member
    Join Date
    May 2010
    Posts
    198

    Default Calling IMacros from shell script

    I have been playing around with IMacros and wanted to call macros from a shell script (as I wanted to automate port forwarding). I have been able to make this work and would like to improve it.

    Hopefully others would feel the same way and would like to help me with this idea.

    Its very ugly at this point but...
    Here is the script that forwards ports on one of my test routers...(router code removed of course)
    Code:
       
    #!/bin/bash
    
    imacro_code="Paste_IMacros_Code_Here"
    
    echo "$imacro_code" | openssl enc -base64 > /tmp/tmp
    
       sed '$!N;s/\n/ /' /tmp/tmp > /tmp/tmp1                    # Yeah I know - I don't Know how to use SED properly
       sed '$!N;s/\n/ /' /tmp/tmp1 > /tmp/tmp                    # But it works
       sed '$!N;s/\n/ /' /tmp/tmp > /tmp/tmp1
       sed '$!N;s/\n/ /' /tmp/tmp1 > /tmp/tmp
       sed '$!N;s/\n/ /' /tmp/tmp > /tmp/tmp1
       sed '$!N;s/\n/ /' /tmp/tmp1 > /tmp/tmp
       sed 's/ //g' tmp > tmp1                         # Removes blank spaces
    
    
       code="$(cat tmp1)"
    rm -rf /tmp/tmp1
    rm -rf /tmp/tmp
       firefox &                                           # Firefox needs to be open already for this to work
       sleep 3
       firefox http://run.imacros.net/?code=$code &        # Runs the IMacro code
    exit 0
    # If you want to try this to automate port forwarding
    #
    # 1. install Imacros addon (search firefox addons - its the first thing that comes up)
    # 2. Go to your router login page
    # 3. click record tab
    # 4. click record
    enter password
    change port number (don't leave it the same)
    click save settings
    # 5. click stop recording
    # 6. click the edit tab
    # 7. click edit macro
    # 8. copy and paste text into the quotes after $imacro_code
    # 9. add variable where the IP address and ports are (optional at this point)

    If someone has a method of
    - only killing the Firefox windows that were opened by this script. I don't want to use killall firefox-bin and the PID for it is elusive.
    - cleaning up the SED garbage or making openssl put the entire code in one line
    - a better way of doing this
    That would be fantastic
    Last edited by Scamentology; 03-12-2011 at 09:23 PM.
    "Never do anything against conscience -- even if the state demands it."
    -- Albert Einstein

Similar Threads

  1. msf: small webaudit shell script
    By m-1-k-3 in forum Experts Forum
    Replies: 4
    Last Post: 04-21-2010, 05:48 PM
  2. Shell script
    By bbakker in forum Beginners Forum
    Replies: 1
    Last Post: 01-24-2010, 01:02 AM
  3. shell script to change MAC address
    By thims in forum OLD Programming
    Replies: 0
    Last Post: 11-14-2009, 01:57 PM
  4. please help i cant find out what a script shell is
    By trent1163 in forum OLD Newbie Area
    Replies: 1
    Last Post: 01-13-2009, 08:53 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •