Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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
share|improve this question
    
This is not Ubuntu specific. –  con-f-use Aug 25 '12 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. –  Eliah Kagan Aug 25 '12 at 18:28

1 Answer 1

up vote 0 down vote accepted

Remove the double quotes here run_hdmi "$2"

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.