-1

Is there any way to perform remote click, from let's say Android device, to current linux session with simple HTTP request?

So far I've managed to get Apache working with PHP7, and xdotool to perform left click by calling a shell script on Ubuntu 16.04 VM. The problem is that script will only work if it's called from current session, but not if it's called from php script.

My guessing would be that Apache server is run by different user in different session?

The goal of my project is to create an Android application that would send HTTP request to Linux server on which PHP will process the request and trigger shell script which performs left mouse click. In addition to that I'd love to get simple response from server which would tell me if click was successful or not.

/var/www/html folder

click.php
file permissions: -rw-r--r-- 1 root root 69 (date) click.php

<?php shell_exec('./scripts/click.sh'); ?>

./scripts/click.sh
file permissions: -rwxrwxr-x 1 root root 28 (date) click.php
#!/bin/bash xdotool click 1

Denis Črnič
  • 117
  • 2
  • 9
  • Can you show the relevant part of that PHP script? Also `ls -l phpscript.php`. User, group, permissions, etc of Apache – M. Becerra Jan 09 '18 at 13:06
  • You can change it to `&1 >> log_file.txt'); ?>` Then you will see what does it complain about – M. Becerra Jan 09 '18 at 13:59
  • tried it, and got error `sh: 1: cannot create log_file.txt: Permission denied`, but after changing directory owner to www-data I got: `Error: Can't open display: (null) Failed creating new xdo instance` – Denis Črnič Jan 09 '18 at 14:25
  • Try running the script as the user that owns the X11 session – M. Becerra Jan 09 '18 at 15:38
  • I changed Apache user to "user" (which is owner of the X11 session), I also changed /var/www/html directory owner to "user" and I'm still getting the same error `Error: Can't open display: (null) Failed creating new xdo instance` – Denis Črnič Jan 09 '18 at 19:53

1 Answers1

0

I have done built something that can answer your question, using xdotool web based interface - xdotool

I used it to remote my Raspberry pi (Ubuntu Mate installed) with my smartphone.

Mochamad Arifin
  • 418
  • 5
  • 9