1

I wrote the bash script below (called hdmi_output) and it's working in most parts as I expect it.

For example, I run hdmi_output run firefox and Firefox is started on the external monitor.

But sometimes I want to run programs with arguments and this doesn't work anymore. E.g. when running hdmi_output run "firefox -P -no-remote", I get this:

/usr/bin/vglrun: 296: exec: **firefox -P -no-remote: not found

I wrote it in quotes to be treated as one variable, but it doesn't seem to work.

Can anyone help me to improve the script, maybe shift command should be used?

#!/bin/bash

start_hdmi() {
...
...
}

run_hdmi() {
    DISPLAY=:8 LD_LIBRARY_PATH=/usr/lib/nvidia-current:$LD_LIBRARY_PATH optirun "$@"
}

if [[ "$@" == "start" ]]; then
    start_hdmi
elif [[ "$#" == "2" && "$1" == "run" ]]; then
    run_hdmi "$2"
else
    echo "$0 start|run <program>"
fi
2
  • This is not Ubuntu specific. Commented Aug 25, 2012 at 15:19
  • @con-f-use bash scripting questions are almost always considered on topic here; I see no reason why this should be one of the very rare exceptions. Furthermore, some details here vary from one Unix-like OS to another, making this even more clearly on-topic for our site. Commented Aug 25, 2012 at 18:28

1 Answer 1

0

Remove the double quotes here run_hdmi "$2"

4
  • cool, that was easy :) Is it also possibe to not use quotes when running the script? Commented Aug 25, 2012 at 14:37
  • Obviously, no. Because the script will take only the name of a program then. Commented Aug 25, 2012 at 14:48
  • For sure, but with further modifications of the script it would be possible, wouldn't it? Commented Aug 25, 2012 at 14:49
  • May be.) Modify. Commented Aug 25, 2012 at 14:50

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.