[SOLVED] How to Run (not Run in Terminal) bash script with sudo in it?
FedoraForum.org - Fedora Support Forums and Community
Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2006
    Posts
    312

    How to Run (not Run in Terminal) bash script with sudo in it?

    Hello everyone,

    I have written a tiny script which switches between 2 CPU frequency throttling governors. Now I need to assign it to a shorcut key though "Preferences->Keyboard Shortcuts".

    Here is the script:

    Code:
    #!/bin/bash
    if [ `cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor` = 'ondemand' ]
    then
    sudo cpufreq-set -g performance
    else
    sudo cpufreq-set -g ondemand
    fi
    As you can see this script involves sudo. I know that usually running commands with sudo requires "Run in Terminal" option for a shortcut, but in "Keyboard Shortcuts->Add" there is no option to run command in terminal. When I double click on the script and choose "Run in Terminal", then it functions as it should.

    How can I make this script execute by doing "Run" and not "Run in Termnal"?
    Last edited by premudriy; 6th July 2010 at 03:05 AM.

  2. #2
    Join Date
    Nov 2008
    Location
    ~
    Age
    32
    Posts
    175

    Re: How to Run (not Run in Terminal) bash script with sudo in it?

    run it with konsole
    Code:
    konsole -e "/your/script/"

  3. #3
    Join Date
    Dec 2006
    Posts
    312

    Re: How to Run (not Run in Terminal) bash script with sudo in it?

    That worked perfectly! Thank you!

Similar Threads

  1. launcher with sudo, without a terminal
    By colifa in forum Using Fedora
    Replies: 3
    Last Post: 6th December 2012, 02:39 PM
  2. Convert bash script to perl script
    By homey in forum Programming & Packaging
    Replies: 1
    Last Post: 2nd September 2006, 04:24 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •