Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-12-2013, 02:33 AM   PM User | #1
sorlaker
Regular Coder

 
Join Date: Dec 2009
Posts: 166
Thanks: 23
Thanked 1 Time in 1 Post
sorlaker has a little shameless behaviour in the past
Just exec and don't output.

How to use php exec() function to open in my OS not in the browser.

I'm using this code :

PHP Code:
<?php
   exec
('"C:\Program Files (x86)\The KMPlayer\KMPlayer.exe" "C:\Wildlife.wmv"');
?>
what i'm trying is to make kmplayer open this video. but seems like it wants to output it at the browser. how can i make it open kmplayer at my screen?

Last edited by sorlaker; 01-12-2013 at 09:50 PM..
sorlaker is offline   Reply With Quote
Old 01-12-2013, 03:55 AM   PM User | #2
sorlaker
Regular Coder

 
Join Date: Dec 2009
Posts: 166
Thanks: 23
Thanked 1 Time in 1 Post
sorlaker has a little shameless behaviour in the past
Answer here -> http://www.php.net/manual/en/book.exec.php#87943
sorlaker is offline   Reply With Quote
Old 01-12-2013, 03:55 AM   PM User | #3
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,659
Thanks: 4
Thanked 2,452 Times in 2,421 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
Does running that code on your command line open the executable? Also, I assume that you are attempting to run this on your local machine web server right? It's useless to even attempt that on a remote server which likely wouldn't have that KMPlayer installed (and has a higher probability of being a linux machine anyway).
Fou-Lu is offline   Reply With Quote
Old 01-12-2013, 03:58 AM   PM User | #4
sorlaker
Regular Coder

 
Join Date: Dec 2009
Posts: 166
Thanks: 23
Thanked 1 Time in 1 Post
sorlaker has a little shameless behaviour in the past
Hm.. I want to control my laptop using my computer. Another thing is that my laptop is far and connected into a tv so i wanted to watch some videos there while i use the pc.

Do you have any solution?
sorlaker is offline   Reply With Quote
Old 01-12-2013, 04:10 AM   PM User | #5
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,659
Thanks: 4
Thanked 2,452 Times in 2,421 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
Not using PHP as a web environment I don't. Running exec in a PHP script executes a command on the server, not on the client using it. That would be a tremendous security hole if it were possible to do.
For that I'd suggest writing something in either Java or C#/VB.NET. Both should be fairly easy to set up, and on the same network you can set up the user as administrator on both machines.
Also, as for the exec not working properly, this has to do with piping the output. Effectively trying to call a command is waiting for the command to return the output, and since some commands don't (such as trying to launch notepad), than it will just sit there running infinitely in the browser. Windows in particular is an absolute pain for exec.
Fou-Lu is offline   Reply With Quote
Users who have thanked Fou-Lu for this post:
sorlaker (01-12-2013)
Old 01-12-2013, 04:20 AM   PM User | #6
sorlaker
Regular Coder

 
Join Date: Dec 2009
Posts: 166
Thanks: 23
Thanked 1 Time in 1 Post
sorlaker has a little shameless behaviour in the past
I was actually thinking about that but i got an issue. I thought about accessing my laptop's cmd and open the file from there but i couldn't maximize it. How can i send data to kmplayer (like keyboard keys)? Can it be done from cmd or i have to use Java?
sorlaker is offline   Reply With Quote
Old 01-12-2013, 04:29 AM   PM User | #7
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,659
Thanks: 4
Thanked 2,452 Times in 2,421 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
You'd need to check your documentation. Typically if you are launching an application from command line, you'll need to provide it with all of the arguments it requires. PHP would be limited to trying to interact with the process itself (using proc family may be able to help with that). If there is a way for it to be done from the command line calls, than sure you can do that. Maximum and fullscreen options for video players can *likely* be performed at the command line call. If they have it in, you can try launching the executable with the /? on it which typically brings up the help menu in windows to show you what arguments it will accept.

Java can make use of the Robot class which allows you to click on the screen. I've never tried to set up a client / server application which uses the robot before, but I'd presume you can issue commands remotely that would interact with the Robot. Positioning is where the pain will be.

Is there any reason why you don't simply use remote desktop to control it instead? Sounds like it would be a lot easier than writing something to do it.
Fou-Lu is offline   Reply With Quote
Old 01-12-2013, 11:40 AM   PM User | #8
sorlaker
Regular Coder

 
Join Date: Dec 2009
Posts: 166
Thanks: 23
Thanked 1 Time in 1 Post
sorlaker has a little shameless behaviour in the past
Actually i could send just an "Enter" key to KMPlayer to maximize it. I'm aware of those remote desktops but it takes a lot of time by typing computer's id and pwd (team viewer). So i'd like to use something fast that could not take a lot of the core's processor.
sorlaker is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 09:34 PM.


Advertisement
Log in to turn off these ads.