Run VBScript on server from javascript/php - php

I have a Single Page Application written in JavaScript and PHP, I am trying to run an external .vbs file on my server?
I have tried using the php COM class as well as exec() to no avail. Has anyone successfully achieved this? Is it even possible?

Found this gem: http://technet.microsoft.com/en-us/library/ee156587.aspx
By that, you should try the similar in PHP:
exec('wscript "C:/path/to/script.vbs"');

Related

Github not running PHP

ve been trying to make a server side site recently on Github but the php code will not run, I have put in a .htaccess but it still wont work, I was wondering if I need to put some library into it to interpret it but other peoples php codes seem to be working without anything like that. Any Ideas?
From https://help.github.com/articles/what-is-github-pages/:
GitHub Pages is a static site hosting service and doesn't support server-side code such as, PHP, Ruby, or Python.

TTY ,SWIG and PHP

Need some help here. I have a c++ library for communicating with an embedded module (ArchLinux) via tty. This library was compiled/converted into php using swig.
The issue now is that a sample program written in php and run from the command line executes as expected but when this same code is used as part of a web page's functionality it fails to execute.
My assumption based on my limited linux knowledge is that tty requires a console in order to run which is why it fails to run as part of a webpage??
Does anyone have any ideas as to how I can get this to work? I have read something about using posix_ttyname but I cant seem to find any code samples that demonstrate its use.
I have attached the offending c++ files along with a test main.php which works for review.
Thanks everyone
http://www.mediafire.com/?ctblcvsy86mdg8p
$argv variable is available only when script is called from CLI. If you don't want to change the script so it could be called from web, you can try calling it from another script as
exec('main.php param');
Just like you do from command line.

How to access variable values of a php script from a python script?

How can I access my php script from a Python script?
I need my Python script to be able to access the variables within the php script. (By the way, I'm new to php and Python.)
Thanks in advance.
If I understand it correctly, you have a service in PHP, and want to communicate with another one in Python.
Now, this is not really related to PHP or Python: this is quite a classic issue of integration and there are several ways to accomplish it; without more details about your problem, it may be very difficult to be specific about a solution and what kind of approach could be the better for you, but below you can find some ideas.
You could for instance save the status from PHP service in an ad-hoc table in the database, and then query it from the Python service.
Another way could be to use a RESTful approach: the information is available as a resource, accessible via a GET query; in PHP you would have a small handler that would just return a small JSON (or XML, if you like that kind of stuff), and in Python you would have instead the client. Of course, there are security issues to consider, but I think you got the idea.
For more information, I recommend you having a look at an interesting series written some time ago by Paul Stovell about integration. It is very accessible, and shows several approaches - although not all of them apply to your current issue.
Elaborate. Is the PHP file local? On a webserver? Where's the python file?
If the php file is on a server with the python file, use an exec statement.
If the python file is local and the php file is on a server, then you need to use urllib.
If both are local, write an interpreter...

Is it possible to use Python with php

I have a VPS Linux webserver with PHP installed.
I want to code some search engine or data mining stuff in one application which I am thinking of building in python.
I want to know if it is possible to use python and php together like calling functions of python in php and vice versa.
As it is my VPS server, I can install anything on that.
Has anyone tried using python in php? Are there any performance issues in real time??
You can execute python scripts using the exec() function in your php script.
Also this seems to provide an answer or two to your question.
Calling Python in PHP
You could have a look at PiP
To that end, I've [site author] written a Python extension for PHP. In short, this extensions allows the Python interpretter to be embedded inside of PHP (think of PHP as the parent language with Python as its child). This allows native Python objects to be instantiated and manipulated from within PHP. There is also initial support for accessing PHP functions and data from within the embedded Python environment.
However, I cannot comment on its reliability. Might need to test it for yourself.
You're trying to do something like
def helloWorld():
print 'Hello, World'
<?php helloWorld(); ?>
I'd say that you most certainly can't.
Edit: Have a look at php's shell_exec though.
I think that should be
<?php
$try = exec("/var/htdocs/folder/test.py")
?>
Try and see if it works
Better you have to do, use api, different application like one application on python server having python application and one server having php application with api. Like you store or delete data by using api in android or ios.

Calling fcsh from PHP script

My question is whether or not Flex's fcsh can be called from within a PHP script. Here is the background:
I have been created a simple process that creates a simple quiz/tutorial by converting a text file into a .mxml file and compiling to a .swf file using the mxmlc compiler. This works well from the command line, but I wanted to make the process easier by creating a web-interface to do this. My initial attempts with PHP's exec() function have not worked. The Python scripts I use to create the .mxml file work fine (using exec()), but I have not been able to get the mxmlc compiler to work.
After searching on the Web and on this site, I believe that using fcsh (instead of mxmlc) may be the way to go. Using fcsh would certainly compile the .mxml file faster (after the first run), and I think that fcsh can be launched as a service that might be able to be called from PHP.
On the other hand, maybe I am approaching this the wrong way. Would it be better to write a Flex application that calls fcsh and avoid using PHP?
Edit: Using fcshctl as hasseg suggested in his answer below worked very well. Thanks Ali.
The problem with calling fcsh from within scripts is that it works as an interactive shell instead of taking command-line arguments, compiling, and returning an exit status. There are different ways to get around this, which I've listed in this blog post of mine, where I mainly talk about fcshctl (which is my own solution for this,) but at the bottom of the post I've also listed other similar solutions to get fcsh integrated into nonstandard build workflows.
There are a few other ways in php to execute an external script. They are exec(), passthru(), system(), and backticks i.e. the key to the left of the 1 key. Each one has a different purpose and return mechanism.
You may have to put the command that executes your executable into a script and call that script via one of these functions.
Is there a particular reason why you can't use mxmlc directly? It seems like it would be easier to call than fcsh. Just specify all your compiler options in a XML file run it like mxmlc -load-config path/to/config.xml. You can find an example of the XML configuration format in FLEX_HOME/frameworks/flex-config.xml.

Categories