im trying to parse pdf to text via PHP and XPDF (pdftotext.exe). On my localhost everythings works well, but when im trying to move everything on server, im getting into troubles.
First of all i checked some settings on server and safe_mode is off, exec is not disabled and permissions are rwxrwxrwx.
Then im trying this
$command = "\\\\149.223.22.11\\cae\\04_Knowledge-base\\tools\\pdftotext.exe -enc UTF-8 ". $fileName . " \\\\149.223.22.11\\cae\\04_Knowledge-base\\output.txt";
$result = exec($command,$output,$args);
echo shell_exec($command);
which isnt working. When i look into $result, $output, are empty, but $args returns 1 which coresponds to Incorrect function by this document windows system error codes
Whole command looks like \\149.223.22.11\cae\04_Knowledge-base\tools\pdftotext.exe -enc UTF-8 \\149.223.22.11\cae\04_Knowledge-base\testpdf\04_egerland_final_paper.pdf \\149.223.22.11\cae\04_Knowledge-base\output.txt and when is dirrectly inputed into commandline, its working.
So im a bit out of ideas. Have someone any hint?
edit 20160201 - aditional trying
So i made aditional tests and when im trying to run similar command with exec from localhost (target .exe file, input and output file is in same location, only im using localhost not server) its working. Im now checking differences in server settings. So can here be problem, that localhosts Server Api is Apache 2.0 Handler and server is CGI/FASTCGI?
So it was all mistake on my side. I badly checked IIS permissions and forgot to assign user to virtual directory which i wana to access. So my only advice and more wisdom from this is to double (maybe triple) check if you have all permissions set correctly.
Related
I hope you can help me with my problem.
I have a local site that reads data from DBF files on a terminal within the network. So what I did, I shared the DBF files on a PC running Windows XP, with full read/write permission.
When the PHP script is run on the Ubuntu server, it will first ping the PC on the network. After confirming that it is connected, it will mount the shared files within the server. Please note that the directory /mnt has 777 permissions and it is set to subdirectories as well. The owner is also www-data which is the user for PHP.
The script is able to read the data from the DBF files using this setup. I use the below script to read the data from the dbf file:
$db1 = dbase_open("/mnt/test.dbf", 0) or die(mysql_error());
for($counter=1;$counter<=dbase_numrecords($db1);$counter++){
$dbf_data = dbase_get_record_with_names($db1, $counter) or die(mysql_error());
// insert data to MYSQL database
}
The script above works, but only for reading the data. When I change to:
dbase_open("/mnt/test.dbf", 2)
it should have read and write access, However it does not let me remove the rows that were already read. I use:
for($count=1;$count<=dbase_numrecords($db1);$count++){
dbase_delete_record($db1, $count);
}
dbase_pack($db1);
but it doesnt work. I also tried to put dbase_pack inside the loop, but still the same. Here is a screenshot of the error:
Hope you can help. Thanks in advance!
I installed the Couchbase Server and its PHP SDK through brew install libcouchbase on Mac. The server admin console is running/working fine on http://127.0.0.1:8091/. I added a hello.php file with the below code in /Library/WebServer/Documents/hello.php.
<?php
$cb = #new Couchbase("http://127.0.0.1:8091/",'username','password');
if($cb->getResultCode() != COUCHBASE_SUCCESS){
throw Exception('Cannot connect to couchbase!');
} else {
echo "Hello World!";
}
When I go to http://127.0.0.1:8091/hello.php, I get an error saying Not found.. What is the problem?
When I go to http://127.0.0.1:8091/hello.php, I get the below error
Not found.. What is the problem?
You are going to the wrong port. Port 8091 is the Couchbase Server Console interface. It looks like you are trying to deploy your hello.php script using the Apache server shipped with OS X which uses the default http port (80). The script is also located in the wrong folder. I believe /Library/WebServer/Documents/ is for static content only.
Given the problem you have ran into it make me suspect that you are trying to learn too many new things at once. You should try running the script outside of a Apache first and get it working there.
php hello.php
It is also worth pointing out that you are using the older 1.X version of the Couchbase PHP SDK, you will want to use the new 2.X version.
I assume you've anonymized the code above, but be sure in place of where you have 'username' you have the bucket name and similarly for the bucket password or empty string if no password. Also, check the docs as the connect string you're using is not necessarily the preferred..
Note for debugging these kinds of things you can set LCB_LOGLEVEL to a higher level as mentioned in the documentation. The way you set an envvar varies based on how you're deploying PHP, but you can easily just test it at the command line.
I am using ZendFramwork1, my local sever php 5.4. and with MongoDB .I have use function Zend_Pdf to draw PDF in my project. it's run well in my local server. but when i put code to sever that have same version PHP. Everything module is okay but for function print data to pdf is errors . I got message like PDF error: Can not open 'data/reports/myfile.pdf' file for writing. . Any one can help me . what's different between my local server and real sever ?
I am looking to see your reply soon.
thank
First off, chmod 777 is a hack and shouldn't really be used. If you're using apache, you are better off chown'ing the folder to the correct user.
I want to run .exe (c++) file by php script. I tried very different combinations of exec command, but still my programs returned -2 (argv<6) or array (?), now I tried to use shell_exec
<?php
$params = array ('nnn.jpg', 'fff.jp2', '300', '300', '50');
$params_string = implode(" ", $params);
shell_exec('demo.exe '.$params_string);
echo 'demo.exe '.$params_string
?>
but it is not working too... I echoed the string I used, and it's just okay
I got it to send parameters properly, but program exits with error caused by write problem. I've changed all perms in target folder to "full control". Maybe there is something with php settings? (xampp on win7 x64)
demo.exe nnn.jpg fff.jp2 300 300 50
any ideas?
I got it to send parameters properly, but program exits with error caused by write problem. I've changed all perms in target folder to "full control". Maybe there is something with php settings? (xampp on win7 x64)
ERROR: Exception: demo.exe: no decode delegate for this image format `kush.jpg' # error/constitute.c/ReadImage/532-5
but as I said before, all goes well through cmd...
Problem was more server issue, dar7yl was almost correct, problem was apache haven't access to imagemagick lib, located in program files... I had to change apache user to my account, and now all works fine ;)
I am unable to print a page to a network printrer using php.
But this works if it is a local printer.
I have installed php_printer.dll and enabled in php.ini
The following is the code:
//$handle = printer_open("Send To OneNote 2007"); ///This Works
$handle = printer_open('\\\\192.168.0.8\\Canon MF4320-4350');
printer_set_option($handle, PRINTER_MODE, "RAW");
printer_write($handle, "TEXT To print");
printer_close($handle);
It shows the error
Warning: printer_write() [function.printer-write]: couldn't allocate the
printerjob [5] in E:\Server\xampp\htdocs\Kiosk\Admin\print.php on line 16
If you used the command line PHP (CLI) the printing to network printers would work. Your $addr is correct by the way.
The issue lies with PHP when you combine it with Apache. In windows, your php scripts would run under the user SYSTEM. Because of security concerns, all network resources are not visible to SYSTEM.
To resolve this problem, create a new user with admin privileges (or at least with Network Resource visibility). In Windows, if you run Apache as a service, click on the SERVICE button in the Apache Service Monitor. Under Apache 2.2, right click on properties. Under the LOGIN tab, change the user from SYSTEM to your newly created user account. Restart Apache. You should be able to run your PHP script to print to network printers now.
Try using either "s with 4\ or 's with 3. eg:
$handle = printer_open("\\\\192.168.0.8\\Canon MF4320-4350");
// or
$handle = printer_open('\\\192.168.0.8\Canon MF4320-4350');
Also, try using a domain name rather than IP (eg. computer-name or full.address.example.com).
Just looking at that string, it feels very much as if it's likely to be caused by back-slash escaping going wrong.
Debugging tip: Set your network address in a variable rather than directly in printer_open(). Then use print() or similar to display the value.
<?php
$addr = '\\\\192.168.0.8\\Canon MF4320-4350';
print $addr;
printer_open($addr);
...
?>
This will allow you to see the value of the string that you're using, which might help you see what's going wrong, and more importantly, help you see how to fix it.
Hope that helps.