I have a Python file, 'print.py', which exists on an IIS server and can print documents successfully from a network printer using PyWin32.
I have a PHP file, 'print.php', which exists in the same folder on the IIS server and can successfully execute 'print.py' when ran from the command line.
However, when I access 'print.php' from a browser on a separate computer, which has access to the server, nothing happens.
If I modify 'print.py' to simply output text, this works and the text appears in the browser. Only the printing is not happening.
What could be the reason for this?
Related
I'm brand new today to using PHP but I can't get anything showing on the page. I've installed XAMPP, started the server, mounted the volume and created a new file, index.php, which I've moved into a new folder called scripts inside htdocs. Based on the articles I've been following this should give me output at localhost/scripts/index.php but it is only giving me the 'requested URL not found on this server' response (I'm just running a basic echo 'hello world' line). Thanks for any help.
Going to just http://localhost shows the 'It works!' message but nothing else.
Check if there are any processes running on port 80, if you have skype or torrent client please close them and try restarting xampp.
Also check if it running on your IP Address. open command prompt and type ipconfig for windows and ifconfig for mac.
once you get your ip address type it in the browser and see if you can find the server running.
Try to save the file with correct extension i.e. .php just typing .php at the end sometimes doesn't work.
Try to do this,
1. Add double inverted commas ""
2. File Save as Type - All Files
3. add .php at the end of your filename
I am trying to send keypresses to a Raspberry Pi running Raspdbian from from a web page hosted on an Apache server at /var/www.
I'm using xdotool, which can send keypresses using commands like this:
xdotool key C
I made a python script xdotool.py that sends a few keypresses like that:
#!/usr/bin/env python
import os
print 'sending HI'
os.system("export DISPLAY=:0")
os.system("xdotool key H")
os.system("xdotool key I")
I am SSH'd into the Raspberry as user Pi, and running this script from terminal works fine and sends the keystrokes "HI" to the Raspberry.
However, I want to be able to do this through a web page. I've made a php-script that runs python scripts and displays the terminal output in the browser, but it does not work with the xdotool.py script. I have given the script permission to be viewed/changed/executed by all users.
I've also changed the Apache settings in /etc/apache2/envvars and changed the user from www-data to pi. The user pi should have all necessary permissions.
The script does run, and "sending HI" is displayed in the browser. But it doesn't send the keystrokes. The error I get from error.log is this:
Error: Can't open display: (null)
Failed creating new xdo instance
Any ideas how I can accomplish this? If there's a way to give everyone permission to do everything, that wouldn't be a problem seeing that this server will only run on a local network with no internet access.
I'm running a web server frontend that has numerous php console scripts (run via shell_exec) embedded throughout the backend.
These are triggered from shell_exec(php $scripthere);
These scripts have useful information output from them, such as echo "You should read this"; and die("You should read this too"); but as they are never echo'd to the frontend, they are never displayed.
Running my Ubuntu server, where can I read the outputs from shell_exec? Yes I know I could go through every line of code and fputs it somewhere, but as this is run via the shell_exec command is there not some STDOUT file or something I could read all outputs from?
So PHPstorm is running the php code fine in its console when I click run, that's great but I want to see it in the browser.
So I created a new PHP web application inside PHPstorm, set up the server to "localhost:8000".
Now when I click RUN it opens the browser but I get an error message: "Oops! Google Chrome could not connect to localhost:8000"
What am I doing wrong??
Thanks!
You have to configure a run configuration for your project first.
Go to Run -> Edit Configurations, click on "PHP Built-in Web Server" and then press "+". You should see something like this:
After saving the settings you can run the web server via Run -> Run '<project-name>'. It should now serve up the pages to your browser.
I have been trying unsuccessfully so far to write a php script that will run when a page is opened and that will launch metasploit!
I ve tried shell_exec and exec and all the other alternatives but although I can get it to do simple things (i.e. ls, cds etc) if I try msfconsole it doesnt do anything!
I have also tried a different script that launches firefox and again nothing happens!
Now i know that php runs on the server and I m not expecting to see a console or firefox opening in the clients machine! Instead in order to check if it works I am trying to echo out the output of the shell_exec!But anyway since im hosting the files on my machine (i.e. this is the server and a VM is the client) if it could actually launch firefox i should be able to see the app opening here in the same way as by just doing this from the command line!
What am I missing?
Is there any other way to do this?(i.e. Launch metasploit everytime a user opens up my page)
NOTE: I've tried specifying the full path for msfconsole but that didnt work either!
Heres what I have so far:
$output = shell_exec('/opt/local/libexec/metasploit3/msfconsole;show');
echo "<pre>$output</pre>";
The ";show" bit was used in order to actually make it run something and print some stuff but didnt make any difference!
When you run a gui application from the command prompt in a X window system, it will use the default display. When you run it using php which is embedded in apache webserver, the program may not know where to display the gui application.
there are 2 things to make this work.
The program that executes the gui application must have permission to use display
you need to tell the program which display to use.
I used the following in my php script
<?php
$cmd = `export DISPLAY=:0; gedit`;
shell_exec($cmd);
?>
and ran the script from terminal using php -f test.php
I got the gedit up and running.
You can test the same with the script in apache too.
Please add apache user with privileges to access display server
update: I just added the following in /etc/apache2/apache2.conf (I am using ubuntu)
User poomalai
Group poomalai
and restarted the web server
sudo service apache2 restart
now I accessed localhost/test.php
and Presto!! I got the gedit :)
Hope this helps