under my directory, /home/lucas/bin
I have the following script term_multiscreen
:
[lucas@lucas-ThinkPad-W520]~$ sudo cat bin/term_multiscreen
#!/bin/bash
# Initializes Nvidia Optimus for multi-screen functionality.
xorg_process=$(ps aux | grep 'Xorg' | grep -v grep | awk '{print $2}')
sudo kill -15 $xorg_process
sudo rmmod nvidia
sudo tee /proc/acpi/bbswitch <<<OFF
# xrandr --output VIRTUAL1 --off
[lucas@lucas-ThinkPad-W520]~$
When I cd ~/bin
, it runs fine with sudo term_multiscreen
. When I am outside that directory, it returns command not found
. I also have /home/lucas/bin
in my $PATH
. What am I doing wrong?
BTW here are my permissions:
[lucas@lucas-ThinkPad-W520]~$ ls -la bin/
total 44
drwxr-xr-x 2 lucas lucas 4096 May 6 15:43 .
drwxr-xr-x 71 lucas lucas 4096 May 6 15:43 ..
-rwx--x--x 1 root root 137 Mar 2 03:26 init_multiscreen
-rw-r--r-- 1 lucas lucas 0 Mar 2 03:24 init_optimus~
-rwx--x--x 1 root root 260 Mar 2 05:54 term_multiscreen
[lucas@lucas-ThinkPad-W520]~$
BTW I am on Ubuntu 13.10
kill -15 $(ps -o pid= -C $prog_name)
- or, if you've gotpgrep
-kill -15 $(pgrep $prog_name)
. Also, you should probably look at this: github.com/Bumblebee-Project/bbswitch – mikeserv May 7 '14 at 6:34killall -15 $prog_name
. (killall
comes with thepsmisc
package.) – Dubu May 7 '14 at 7:17sudo
that usessudo
itself, where necessary? – Dubu May 7 '14 at 7:19sudo
in the script will automatically ask you for your password (or not even that, if you used sudo shortly before). If you always usesudo <scriptname>
, then the whole script is called in the superuser context and thesudo
calls within the script are not necessary anymore. – Dubu May 7 '14 at 9:45sudo
is unnecessary. Thanks for pointing it out! (I caught this just before you posted, so my other comment was deleted...) – Lucas May 7 '14 at 9:59