You are not logged in.

#1 2025-11-17 19:36:56

efog4
Member
Registered: 2025-10-09
Posts: 25

[solved] Quick question on scripting with interative(?) programs

I am not completely sure of the terminology but some commands just run straight from your terminal (ex: ip) whereas others expect you to run a process first, run the commands you desire, then exit the process (example: iwctl) from my research i believe the latter are called interactive programs, but i am unsure. My question is simply how do you go about scripting with the framework of something like bluetoothctl; specifically im getting into dmenu (specifically a clone for wayland) and want to start working on a script to let me control my audio interfaces.

do i need to use something like expect to accomplish this?
https://man.archlinux.org/man/expect.1.en

or is additional configuration unnecessary and are there commands that exist outside of bluetoothctl that i should be using instead?

testyy() {
bluetoothctl
connect <mac_address>
quit
}

running this function does not seem to work how it works when each is inputted by a human into commandline

Last edited by efog4 (2025-11-17 20:22:15)

Offline

#2 2025-11-17 20:18:18

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 75,086

Re: [solved] Quick question on scripting with interative(?) programs

"expect" can lead a dialog w/ the process (waiting for and interpreting responses) but in your case you can typically just use heredocs as input and documented in https://man.archlinux.org/man/bluetoothctl.1#AUTOMATION

Offline

#3 2025-11-17 20:30:30

efog4
Member
Registered: 2025-10-09
Posts: 25

Re: [solved] Quick question on scripting with interative(?) programs

hey!

ah yes,  "here document" ; i dont think i would have ever found this through search enginning

thanks, seth

Offline

Board footer

Powered by FluxBB