Help with Shell Script opening and closing a program

REALLY new to this stuff, sorry.

So I want a shell script to open a program, wait 45 minutes, close it, and then do it all again. I want to do this because I am running an iMacros Script for a long period of time and if Firefox is not constantly restarted, memory leaks start to happen.

Anyway heres my script:

#!/bin/sh
while :
do
'/usr/lib64/iceweasel/iceweasel imacros://run/?m=macro.iim' &
sleep 5
'/usr/lib64/iceweasel/iceweasel imacros://run/?m=macro.iim' &
sleep 2700
killall firefox-bin
done

When I open it using "sh /root/whatever.sh" I get this error:
"line 12: syntax error near unexpected token 'done'"
"line 12: done"

Can anyone help? thanks!

edit: oh yeah, for anyone who isnt familiar to iMacros scripting, running the macro twice after 5 seconds is needed because firefox is not properly loaded during this time

If you're saying that it takes firefox 5 seconds to load before you can run your iMacros script; why not start firefox, sleep 5 seconds, and then launch your iMacros script instead of starting the script twice when you know the first one will fail and maybe leave firefox in an "unknown" state.

The error messages you're getting are from line 12 in some script that isn't identifying itself. Since there are only 9 lines in the shell script you're showing us, this script isn't producing the error. Could the error message be coming from the iMacros script that is failing to start properly?

Rather than killing firefox, it would be much better to debug your iMacros script to stop leaking memory.

What do you see if you run the command:

'/usr/lib64/iceweasel/iceweasel imacros://run/?m=macro.iim'

at a time when firefox is not running?

What do you see if you run the same command when firefox is running?

What does your iMacros script look like?

I could do that, it would be the same thing though.

Oh sorry, the script is actually 12 lines, I had 3 lines for comments and I just removed them when I posted it here.

The problem is Flash, as my script macros a Flash website, and therefore it must restart once in a while. I've coded a simple batch file on Windows that does this, however I want to do the same on Debian.

Firefox opens, but my script doesn't. Which is why I need to run the command twice, as explained here: iMacros_for_Firefox#Command_Line_Support

Thanks

Going to the web page you posted, there is absolutely nothing that looks like what you're doing. The following suggestions are there:

What operating system are you running? The comment I marked above in red seems to directly address your issue. The code I marked in blue is their suggestion for how to handle the issue on Windows (which looks exactly like what I suggested), and the code I marked in green is their suggestion for how to handle the issue on Mac OS X.

What operating system are you using? What is your "default" browser? What type of shell is /bin/sh on your system (an old Bourne shell as on Solaris 10 systems, a Korn shell as on many other UNIX systems, a bash shell as on many Linux systems, or something else)?

Do you have iMacros Enterprise Edition?

Note that showing us your MODIFIED script and the errors produced by your unmodified script makes it harder for you to get help. Having us look at error messages that don't match your code makes it impossible for us to diagnose your problem and makes us wonder if we can trust anything you show us.

I'm running Debian. And yes, I did what the website said to do on Windows. Those are commands for batch files. I'm running Debian, not Windows.
Don't know what /bin/sh is on the system.

I'm running Firefox. I'm not using the enterprise edition. The script isn't modified, I just removed some comments at the top

The syntax is different between UNIX and Linux shell scripts and Windows batch scripts, but the commands that need to be run to bring up your iMacros script in a Firefox window should be very similar.

The examples shown on the web page you referenced all invoke a browser and give it an operand that is a relative pathname to an iMacros script. Your shell script does not invoke a browser; it just invokes your iMacros script (with no operands or options) as if it were a standalone command. There is absolutely no indication on the web page you referred to that the command line you're using should work. It may well do what you want, but there is nothing on the web page you referenced that would explain why it should.

I'm sorry that you don't realize that deleting three lines from a shell script is modifying that script. There is nothing obviously wrong in the 9 lines you showed us, but the syntax error on line 12 clearly tells us that something in the 3 lines you didn't show us are causing a syntax error in the 9 lines you showed us (or you changed something else in the 9 lines you showed us).

Since you refuse to show us the code that seems to be causing your problem, I don't see how we can help.

Fixed it, I just had to remove the & symbol...