The permissions of the script are irrelevant. Setuid and setgid bits are ignored on scripts on Linux and most other unices.
You can configure sudo to allow you to run this script without specifying a password, with the
NOPASSWD tag. Make sure that
sudo doesn't require to be connected to a terminal: turn off the
requiretty option. Note that the
NOPASSWD-tagged rule must come before any other rule that would let you run the command with a password prompt, because the first match applies. So run
kjo ALL = NOPASSWD: /path/to/nc-logs-truncate
kjo ALL = (ALL) ALL
Change the first line of the script to
#!/bin/zsh -f, otherwise zsh will load
~/.zshenv which isn't desirable here.
Now that I've answered your literal question, this is probably not the best method. A simple
chown kjo ~/.juniper_networks/network_connect/ncsvc.log would ensure that the log file belongs to you so you can truncate it at will.
Better, move the log file instead of truncating it: it's often useful to keep recent logs around (for example to compare working logs to non-working logs if nc fails). Give yourself write permission on the directory (you might own it already) and
mv -f ~/.juniper_networks/network_connect/ncsvc.log ~/.juniper_networks/network_connect/ncsvc.log.0
Alternatively, make a more unixy NC package, tell
ncsvc to write its logs in
/var/log, and include its log in the