Chromium browser headless for PDF production not working - google-chrome-headless

I'm trying to generate PDFs from HTML. I have this working on my Ubuntu 18.04 laptop.
A minimal example is;
chromium-browser --headless --disable-gpu --print-to-pdf='/var/www/test/test.pdf' 'https://www.google.com'
When I try to execute this on an Ubuntu 20.04 server, I'm getting;
[1102/161822.295586:ERROR:headless_shell.cc(628)] Writing to file /var/www/test/test.pdf was unsuccessful, could not open file: FILE_ERROR_NOT_FOUND
If I change the --print-to-pdf path to the home directory of the user, it works. A directory outside of the users home even if owned by the user and with 777 permissions fails.
I'm at a loss as to how to troubleshoot this. I've tried adding the --enable-logging flag, but this doesn't seem to do anything. I've checked the logs; nothing.

Instead of using chromium-browser, directly call the chrome executable like this.
/snap/chromium/current/usr/lib/chromium-browser/chrome --headless --disable-gpu --print-to-pdf='/var/www/test/test.pdf' 'https://www.google.com'
OR
Remove or rename /usr/bin/chromium-browser and create symbolic link like this
ln -s /snap/chromium/current/usr/lib/chromium-browser/chrome /usr/bin/chromium-browser
Then you can run it as you did
chromium-browser --headless --disable-gpu --print-to-pdf='/var/www/test/test.pdf' 'https://www.google.com'
I don't know what was the cause of the issue, for some reason it can't write inside /var, but this fixed it for me.

Related

zsh: permission denied: webstorm - On Attempting to Create Shell Script That Launches WebStorm

I am following the documentation on creating a Shell script that launches the WebStorm application for a given file folder as described on WebStorm Help page. I am currently using an M1 Pro Macbook (2022) that I just got today and has little else installed beyond Homebrew, VSCode, WebStorm, and PyCharm.
Following the example in the docs, I created a file called webstorm (without any extension) in usr/local/bin and added the following code to it:
#!/bin/sh
open -na "WebStorm.app" --args "$#"
After starting up a new terminal, and running webstorm ., I get the following error in my terminal:
zsh: permission denied: webstorm
I have:
Changed sh to zsh as my default shell is zsh, and that made no difference.
Checked my permissions for both usr/local/bin and usr/local/bin/webstorm to ensure that I have the correct permissions to execute files from here. When right clicking on the webstorm file and clicking "Get Info", I can see that I currently have read and write permissions.
Restarted my computer
To add to my confusion, I have used the same script in the same location on my work Macbook, and it has worked without issues.
Any help on this would be hugely appreciated.
Checked my permissions for both usr/local/bin and usr/local/bin/webstorm to ensure that I have the correct permissions to execute files from here. When right clicking on the webstorm file and clicking "Get Info", I can see that I currently have read and write permissions.
Do you have the "execute" permission?
Try:
$ chmod +x /usr/local/bin/webstorm

Running wp-cli from bash script results in path error

I have successfully installed wp-cli on my remote server and created the "wp" alias. I use Putty to connect via SSH, and everything works just fine. First, I used a .user_bashrc file to set the alias with:
alias wp='/www/htdocs/w019d58a/wp-cli.phar'
The path is set in .user_bashrc using:
export PATH=/www/htdocs/w019d58a/:$PATH
However, when I tried to run wp-cli from a bash script, I got a "wp command not found" error. I contacted the support, and they recommended a symlink. So, I created a symlink using:
ln -s /www/htdocs/w019d58a/wp-cli.phar wp
Everything works but the installation process. I can, for example, install a plugin using:
#!/bin/bash
wp plugin install akismet
Unfortunately, I can't download WordPress via the bash script using:
wp core download --locale=de_DE_formal
I always get the error:
Error: Too many positional arguments:
Error: This does not seem to be a WordPress installation.
Pass --path=path/to/wordpress or run wp core download.
I tried to add the path using:
wp core download --locale=de_DE_formal --path="/www/htdocs/w019d58a"
No luck. I stil get the same error.
I can download and install WordPress directly from the console and do further operations using a script. But I can't download and install it from the script due to the path error.
Any ideas how to fix that?
I've just found out, that the download is working fine:
#!/bin/bash
wp core download --locale=de_DE_formal
It's the config create part that causes trouble:
wp config create --dbname=d123456 --dbuser=d123456 --dbpass=123456 --dbhost=localhost --dbprefix=wplcli_

Tor console output issue: running tor --hash-password gives no result

I'm following the blog post here.
I'm using a Windows machine, so I can't follow the exact steps. This is what I've done:
Installed the Tor Browser for Windows
Installed pytorctl
pip install git+https://github.com/aaronsw/pytorctl
Installed Privoxy
Attempted to use the Tor command line. I'm assuming it is the exe file in the directory "Tor Browser\Browser\TorBrowser\Tor"
tor --hash-password *mypassword*
Unfortunately, this command runs but there is no response.
If anyone has any suggestions, much would be appreciated. Do you think this could be a firewall issue?
Apparently this is a known bug that when your run tor.exe from the command line it is running but opens in a hidden window. To get around this, run the following: tor --hash-password *your_password* | more. Hopefully this works. See more about the issue here.

wkhtmltopdf opens an application on OSX and doesn't finish its job till I focus this application

As far as I read wkhtmltopdf is using a patched version of Qt so that it can be executed WITHOUT using a graphical server such as Xorg, etc but when I run it in my OSX, it opens an application, it's visible in dock and when I press Command-Tab it's visible in list of applications shown, the icon of this app is a text "exec" in a black background. As soon as I focus this app it gets closed and wkhtmltopdf finishes its job but if I don't focus it, it doesn't finish its job at all.
Any ideas what can I do? I want it to run in background and respond automatically, I can't sit behind the system and Command-Tab each time a request is sent.
Update:
I tried it with an Ubuntu Server and it raises this error:
wkhtmltopdf: cannot connect to X server localhost:10.0
when I try to run wkhtmltopdf directly in command line. Isn't it against to whole purpose of patching Qt so that it doesn't need an X server?
It got solved after I faced the problem in Ubuntu, by searching the error raised in Ubuntu I could find this post wkhtmltopdf: cannot connect to X server which seems led me to install the package from sourceforge (both in OSX and Ubuntu) and it solved my problem (both in OSX and Ubuntu)
You must copy it into directory : /usr/local/bin, make sur it's executable and add symlink of wkhtmltopdf.sh like :
1- the command :
brew cask install wkhtmltopdf
2 - insert the binary in directory /usr/bin so the browser can't have permission to execute in this directory.
You must copy the wkhtmltopdf.sh to directory /usr/local/bin cause the browser have permission in this directory like:
sudo cp /usr/bin/wkhtmltopdf.sh /usr/local/bin/wkhtmltopdf.sh
3 - After make sur the binary have permission of execution like :
sudo chmod a+x /usr/local/bin/wkhtmltopdf.sh
4 - so now you can test, it's work like:
/usr/local/bin/wkhtmltopdf.sh http://www.google.com google.pdf
it make download the pdf in the current directory in your terminal
5 - Optional
now you can add symlink in your directory /usr/local/bin like
ln -s /usr/local/bin/wkhtmltopdf.sh /usr/local/bin/wkhtmltopdf
6 - copy to the /usr/bin/wkhtmltoimage into /usr/local/bin/wkhtmltoimage like:
sudo cp usr/local/wkhtmltoimage usr/local/bin/wkhtmltoimage
8- make sur this is executable too:
sudo chmod a+x /usr/local/bin/wkhtmltoimage
I Hope it's help you

Got "filename.settings cannot be locked because it is read-only" error running iReport 4.0.2 at Ubuntu

I just installed iReport yesterday and it was working fine. But when I try to run it today it is not working properly.
Here is what I have done;
Downloaded iReport-4.0.2
Extracted it in my downloads folder
Try running though terminal
adm#linux:~/Downloads/iReport-4.0.2/bin$ sudo ./ireport
this gives the No protocol specified error in terminal.
adm#linux:~/Downloads/iReport-4.0.2/bin$ ./ireport
without sudo, this show many error messages in terminal and starts iReport. But again shows popup several errors. Still I cannot create or edit reports.
Here are the errors. I can post the output in terminal if needed. But its quite lengthy.
I also tried moving the iReport-4.0.2 to the /opt/ folder. Even that resulted the same thing.
Also my JasperServer is up and running. But when I run a report it returns the following error;
com.jaspersoft.jasperserver.api.JSException: java.lang.NoClassDefFoundError: Could not initialize class net.sf.jasperreports.engine.util.JRStyledTextParser
Do not know whether there is any connection between these two issues.
$ sudo chmod 775 -R iReport-4.0.2/
if don't work you should use "sudo" to open iReport
$ sudo ./ireport
Regards
Yusuf Firdaus
you must login with root user in terminal means
$ sudo su
Enter password
After that run the ireport

Resources