0

I have a simple script, but for some reason it fails when running the command as a variable. Any ideas as to why? (I am trying to change device setting of pipewire with a script)

cmd2="pactl set-card-profile 'bluez_card.B8_F8_BE_79_40_C0' 'headset-head-unit-msbc'"
$cmd2  
#Command above Fails with "Failure: No such entity"

pactl set-card-profile 'bluez_card.B8_F8_BE_79_40_C0' 'headset-head-unit-msbc'
#command above works fine. (if I modify the bluez to blue99 it fails as cmd2 did)
geoffr98
  • 73
  • 1
  • 9
  • 1
    See [BashFAQ #50](https://mywiki.wooledge.org/BashFAQ/050). This is normal and expected. Commands can be safely stored as arrays or as functions -- not as strings. – Charles Duffy Sep 30 '21 at 15:34

1 Answers1

0

Don't know why this worked.. but removing the ' fixed it..

cmd2="pactl set-card-profile bluez_card.B8_F8_BE_79_40_C0 headset-head-unit-msbc"
$cmd2
geoffr98
  • 73
  • 1
  • 9
  • BashFAQ #50 explains why. However, it would be much better to switch to an approach that allows all possible commands to work, as described in the linked duplicate and in the aforementioned FAQ. – Charles Duffy Sep 30 '21 at 16:27
  • Thanks for the comments.. learning more every day! – geoffr98 Oct 05 '21 at 15:33