Help on executing a bash script via shell()

asked 2019-06-27 13:10:50 +0100

Neill_R1 gravatar image

updated 2020-07-11 20:26:51 +0100

Alex Kemp gravatar image

I wish to run this script as sudo from BASIC

cat /home/neill/Documents/
## dpkg -l > /home/neill/Documents/pkg.txt
dpkg -l > $1

neill@HDD-Mint-64:~$ echo "mypassword " | sudo -S /home/neill/Documents/ /home/neill/Documents/pkg.txt
[sudo] password for neill: neill@HDD-Mint-64:~$

Edit (Opaque): Put script text into preformatted text attribute for readability reasona. No changes to content.

edit retag flag offensive close merge delete


The problem you have is not to run a shell script from a macro since this is easy having a running non-interactive shell script through Shell(<full_path_to_script> <args>). Your problem is that your script looks like to be interactive (and that cannot be handled - afaik - by shell()).

Thus consider to modify your sudo configuration to call the script with NOPASSWD.

Opaque gravatar imageOpaque ( 2019-06-27 14:32:37 +0100 )edit

My problem also included the inability to shel()l out to an external process such as Firefox. An system update then caused problems with cinnamon crashing (this was caused by me wrongly allow mesa package to be installed (Linux Mint 19). I have done a reinstall of the OS and now find that the problem with shell() out to Firefox no longer exists. I think i have discovered a better way to enter the password and will get back to report on how this works or doesn't.

Neill_R1 gravatar imageNeill_R1 ( 2019-06-30 11:46:45 +0100 )edit