views:

61

answers:

2

I need to run a javascript code on server side using IE8 (the javascript works with activeX objects) But I need to run it from command line, from PHP.

So in short, I will install apache + php on 2003 Windows server, and php will use system() to execute iexplore running a page of javascript.

I would like to know if this is logically possible, as i can see a number of pitfalls:

  1. PHP might not be able to execute iexplore without a user logged in.
  2. iexplore might not run the javascript correctly to interact with ActiveX objects
  3. iexplore might not quit when JS finished running.

I will attepmt to make a little test case as soon as i can, but any pointers about this aproach will be apreciated.

Edit:

Now, I realise that this is a round about way of doing things (read, wrong), The goal was to make a Dymo Label printer print from a central location rather than client machines (this is where the JS is from). Dymo SDK provide several ways of interacting with their printers, but Im still looking for a way to use pure PHP. I think it might be possible to use one of their example cli binaries.

A: 

Make sure to update your Service Packs and AntiVirus definitions. I can foresee many many many potential security issues here.

Keep in mind that JavaScript in IE runs with a webpage context. When you refresh/navigate pages, the old JavaScript execution state is wiped and a new one begins.

Was there a specific question here?

Oxyrubber
Running IE in the context of a service account that *should* have limited rights is a vulnerability out-of-the-box, if it will even work at all. Don't do it.
spender
Not really an issue as everything is generated locally and controlled, there is absolutely nothing interacting with public.
Yarek T
A: 

Does the Dymo have a way of interacting with it from Command Line? If so you can easily send commands to it via shell_exec(). http://www.php.net/manual/en/function.shell-exec.php

This is generally the easiest option when you are able to control something via command-line. Sometimes you need a bit more control, however (interactive command-line programs, for instance) and sometimes the program you want to run isn't even command-line based. In these cases you may need proc_open() (http://www.php.net/manual/en/function.proc-open.php) or exec() (http://www.php.net/manual/en/function.exec.php)

Just make sure that if you use exec() you redirect the output!!. Failure to do this can cause the program to hang indefinitely.

From the PHP manual:

Note:

If a program is started with this function, in order for it to continue running in the background, the output of the program must be redirected to a file or another output stream. Failing to do so will cause PHP to hang until the execution of the program ends.

steven_desu