Need Help with Simple Script

Questions about applications and software
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
garda

Need Help with Simple Script

Post by garda »

Hi,

I need to write a script which, when executed, invokes the following commands in consecutive fashion to activate Bluetooth:

- (sudo) modprobe bluetooth
- (sudo) modprobe hci_usb
- (sudo) hciconfig hci0 up
- (sudo) /etc/init.d/bluetooth start

Also another one to deactivate Bluetooth and unload the modules:

- (sudo) /etc/init.d/bluetooth stop
- (sudo) hciconfig hci0 down
- (sudo) modprobe -r hci_usb bluetooth

Can anyone show me what the script should be like?
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
SiKing
Level 5
Level 5
Posts: 571
Joined: Mon Sep 29, 2008 10:57 pm
Location: Las Vegas
Contact:

Re: Need Help with Simple Script

Post by SiKing »

I would imagine it should look something like:

Code: Select all

#!/bin/bash
sudo modprobe bluetooth
sudo modprobe hci_usb
sudo hciconfig hci0 up
sudo /etc/init.d/bluetooth start
Once you have the script, you will want to give it execute permissions with chmod +x <name>.
garda

Re: Need Help with Simple Script

Post by garda »

Thanks for the hint. :)

Your script works just fine except it can't be triggered through a desktop shortcut. I need Bluetooth be easily accessible on a shared computer at home since some people here use it sometimes but I can't afford to have the module loaded everytime as it causes processor utilization to soar by around 25% (sometimes even more). Hence, I'm in need of a way to toggle it without having to touch terminal because these users here don't see it convenient. If you, or anyone else, know how to achieve what I'm after , please let me know some more.
Locked

Return to “Software & Applications”