0

I have a simple script use to install a package under cust privilege like this (command changed for security) installScript.sh

#!/bin/bash
patch -i <package-name> << EOF
n
EOF

the purpose of this script is for automate enter N (No) when prompt "Are you sure? (Y/n)" for testing purpose. The permission of this file is

-rwxrwxrwx. 1 cust root  66 Jul 25 15:06 installScript.sh

However, When I execute this command using

./installScript.sh
or 
sh /home/cust/installScript.sh

I get the permission denied. But by executing patch command manually, I can get things working out normally without any issues. Is there anything that need to be configured?

2
  • This might help: Patch: auto answer no
    – Cyrus
    Commented Jul 26, 2023 at 1:49
  • 1
    If the script starts with #!/bin/bash it is wrong to use sh to execute it. Use bash or better still just run it directly Commented Aug 27, 2023 at 14:32

1 Answer 1

1

It's a permission problem with your group being "root".
You'll have to sudo ./installScript.sh

Or, you can sudo chown cust:cust ./installScript.sh and not need sudo to run.

Also, you could use xdotool for the input.

#!/bin/bash
patch -i <package-name> &&
xdotool keydown n

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .