Score:0

How to give display access to a non-interactive shell using .bashrc

jm flag

I have a worker that is running in a non-interactive shell. The worker is needing to open up a chrome browser to do scraping, but we are getting a chrome not reachable error due to the worker not having access to the display. (same scripts work when using interactive shell)

How would I give this non-interactive shell worker access to the display in the .bashrc file?

pa4080 avatar
cn flag
Does this answer your question? [How can I show notify-send messages triggered by crontab?](https://askubuntu.com/questions/978382/how-can-i-show-notify-send-messages-triggered-by-crontab)
xslibx avatar
jm flag
@pa4080 Just gave it a shot, but no luck.
cc flag
"non-interactive" has nothing to do with X access. DISPLAY is an environment variable, so gets inherited from everything you spawn. If this "worker" is from somewhere else, did you set the xhost permissions to allow access?
terdon avatar
cn flag
Why would you do this using chrome? Can't you use a text-based browser? This feels like an [XY problem](https://meta.stackexchange.com/q/66377/203101). It might make more sense to ask a question where you explain what you are trying to do, what the final objective is, because the idea of using something as resource-hungry and complex as chrome in a shell script really seems strange. And interactive vs non-interactive shouldn't make any difference. Are you sure both shells are bash? Isn't one actually `sh`? Does running `xhost +` help?
xslibx avatar
jm flag
@ubfan1 @terdon Sorry I'm quite new with ubuntu. I'm a php developer. We have a Laravel project hosted on an ubuntu server. There are daemon workers that are running jobs that are scrapping websites using a headful chrome browser (headless selenium has issues, so needs to be headful which is why we are using an ubuntu vm as our server). I can run the same job/scraper from my interactive terminal, but if I run it as a worker, which uses a non interactive shell, chrome does not start. I had to run `xhost +local:` to get the interactive terminal to work.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.