Some progress in that I can now run 'sudo ./runcnc.sh' from a Terminal, it will ask for my Password, turn OFF Network & Sound, run linuxCNC, and when I Quit linuxCNC it enables Network & Sound.
I used 'sudo chown root:root runcnc.sh' and chmod u+s runcnc.sh'. I have even tried the former on the Desktop link to runcnc.sh but this does not disable the Network nor does it ask for a password.
I've appended a typical log to the end of the script. i.e. some run parameters using (LOG, .....) and the three time stamps.
Code:
cat runcnc.sh
#!/bin/bash
# sudo chown root:root runcnc.sh
# sudo chmod u+s runcnc.sh
# normal command use 'sudo -n cnc ...'
# log file for date stamps and elapse time
# gnc file may append commentary and data using (LOG, ...)
sudo -u cnc echo "run linuxcnc after disabling audio and ethernet"
service network-manager stop
sudo -u cnc amixer set Master mute
sudo -u cnc start=$(date)
sudo -u cnc linuxcnc /home/cnc/linuxcnc/configs/EAI07TPCPWM/EAI07TPCPWM.ini
sudo -u cnc sleep 1s
sudo -u cnc stop=$(date)
service network-manager restart
sudo -u cnc amixer set Master unmute
# read ngc file from axis log, 2nd entry using \' as break
sudo -u cnc ngcf=$(mawk -F\' '/recent/ {print $2}' /home/cnc/.axis_preferences)
sudo -u cnc logf=$(echo $ngcf | cut -d. -f 1)
sudo -u cnc ext=".log"
sudo -u cnc logf=$logf$ext
sudo -u cnc echo "Start Time:" $start >> $logf
sudo -u cnc echo "End Time: " $stop >> $logf
# pulled this gem off the web from Bill Gale:
sudo -u cnc duration=$(date -ud@$(($(date -ud"$stop" +%s)-$(date -ud"$start" +%s))) +%T)
sudo -u cnc echo "Duration: " $duration >> $logf
cat scallop.log
0.375000 tool dia, 1.500000 shell rad, 0.450000 shell height, 96.000000 shell angle
7.384615 ridges, 0.123252 edge mod, 0.045000 height mod, 0.562500 nose rad
0.400000 border, 0.370000 ring, 0.180000 lip, 2.450000 outer rad
Run Date: Mon Mar 16 09:15:37 EDT 2020
Start Time: 16:40:36
End Time: 17:05:05
Duration: 00:24:29