Seeking assistance with the shell() function

I am trying to use the shell() function in a macro to feed a command line parameter into a bash script I have written. The script works fine if I run it interactively from a terminal window. I have harvested some knowledge regarding shell() from this and other forums, so I have managed to do some debugging, but am currently “stuck”.

At this point, I have got the macro to run the bash script and it is accepting the string that I am testing with as the input parameter. However, it seems that the bash script is running in some weird user context because I can make it write to debugging logs in my home directory, but it does not appear to have permission to execute some of the executeables that it needs to run. I tried redirecting the whoami command to my debug log so I can see what user the bash script is being executed as, but the debug log shows “/usr/bin/whoami: Permission denied”.

Is there a way to make the shell() function execute under a specific user context?

Have not much experience in this area but take a look at this post → Run a shell script from a click on an image in a presentation - #13 by Ratslinger
Does deal with parameter passing and just re-tested with Ubuntu 20.04 using:

Version: / LibreOffice Community
Build ID: 382eef1f22670f7f4118c8c2dd222ec7ad009daf
CPU threads: 8; OS: Linux 5.4; UI render: default; VCL: gtk3
Locale: en-US (en_US.UTF-8); UI: en-US
Calc: threaded

Not certain I can provide much more on this.

While it is obvious you are on an Unix-like OS (Linux, FreeBSD, maybe even MacOS) you didn’t tell anything on the environment - OS, desktop, LO-version and how it is installed.
Interesting points to check first: Snap/Flatpack use containers, so they don’t access all of your system, same for docker etc.
A hardened OS may restrict access to commands (AppArmor etc.)

1 Like

Thanks for the reply @Ratslinger. I should’ve mentioned that I’m using Ubuntu 22.04 and LibreOffice I had a look at the link you posted and the example there is pretty much what I’m doing. Shell() is “working” but I’m baffled as to what user context the script is running under. Thanks for your help - I’ll keep slogging away at it and hopefully have some success.

For Ubuntu 22.04 my first guess is you have a installation from the snap-store like in this guide (gui-version):

A typical restriction would be to allow only access to your home-directory. Pretty fine for usual office. But you want generall access. So you’d have to decide between a real install in ubuntu, or widening the interface. As I don’t use snap myself, I can only link to the basics here, but maybe start with a command to check wich snaps you have.

snap list

Not a Calc question, but common BASIC instead. Question re-tagged accordingly.

Bingo!! @Wanderer is spot on about it being the snap version of LibreOffice. I removed the snap and reinstalled the proper LibreOffice and now the script runs under my user context and is able to access the executeables it needs.