Linux bash script:
function Print()
{
echo $1
}
Print "OK"
This script runs successfully, when executed directly, and gives an error running with sudo:
alex@alex-linux:~/tmp$ ./sample-script
OK
alex@alex-linux:~/tmp$ sudo ./sample-script
[sudo] password for alex:
./sample-script: 1: Syntax error: "(" unexpected
Why?
do you have
#!/bin/bash
as the first line of the script? this may be needed
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With