Writing a bash script to turn on and off the USB ports on a raspberry pi 4. Using uhubctl.
#!/bin/bash
# Script to turn on and off power to usb port
# Uses uhubctl
#
time_w=5
#cd uhubctl
uhubctl -a off -l 1-1
#
sleep "$time_w"
#
uhubctl -a on -l 1-1
#
echo "All done"
I can run this sudo uhubctl -a off -l 1-1
from the command line without issue.
But if I run the script with sudo bash USB_Power.sh
I get the following error.
!o compatible smart hubs detected at location 1-1
Run with -h to get usage info.
All done
sudo
)? Also what happens if you just runsudo USB_Power.sh
? Is this the only version of the script on your system?sudo
and I also run the script assudo
This is the only version of the script on the system. When I run the command is executes just fine - but when I run it as the script it just doesn't work.