Fedora Linux Support Community & Resources Center
  #1  
Old 19th January 2012, 10:21 AM
glennzo Online
Un-Retired Administrator
 
Join Date: Mar 2004
Location: Salem, Mass USA
Age: 57
Posts: 14,699
linuxfirefox
A simple bash scripting question.

With a statement to begin.

I wrote a short script to install the gnome weather extension under Fedora 16. The last 2 commands in the script are:
PHP Code:
gsettings set org.gnome.shell.extensions.weather woeid 2487386
gsettings set org
.gnome.shell.extensions.weather unit fahrenheit 
These commands do not seem to be executed because the settings are not changed, but, the script doesn't complain and there are no visible errors. If I execute these commands as regular user "glenn" from the command line they seem to work and the settings are changed. This leads me to the question.

Do I need to use something like
Code:
exec gsettings set org.gnome.shell.extensions.weather woeid 2487386
in the script or is there another method to execute these commands properly?
__________________
Glenn
The Bassinator © ®

[SIGPIC][/SIGPIC]
Laptop: Toshiba Satellite / Intel Core 2 Duo 1.73 GHz / 2GB / 160GB / Intel Mobile 945GM/GMS/GME/943/940GML Integrated Graphics
Desktop: BioStar MCP6PB M2+ / AMD Phenom 9750 Quad Core / 4GB / 1TB SATA / 500GB SATA / EVGA GeForce 8400 GS 1GB
Reply With Quote
  #2  
Old 19th January 2012, 10:32 AM
Dangermouse Offline
Administrator - (On Leave)
 
Join Date: Aug 2007
Location: London Postbox (the red one)
Age: 48
Posts: 3,864
linuxfirefox
Re: A simple bash scripting question.

Hi Glenn,
when running the settings are they being run as root or as user?(you need user)


(su - $(logname) -c "gsettings set org.gnome.shell.extensions.weather woeid 248738")
Reply With Quote
  #3  
Old 19th January 2012, 10:46 AM
glennzo Online
Un-Retired Administrator
 
Join Date: Mar 2004
Location: Salem, Mass USA
Age: 57
Posts: 14,699
linuxfirefox
Re: A simple bash scripting question.

Hello Dave. The script requires sudo password since I'm doing "yum install".. So if I use your example code above those 2 commands will be executed as "glenn" ??
__________________
Glenn
The Bassinator © ®

[SIGPIC][/SIGPIC]
Laptop: Toshiba Satellite / Intel Core 2 Duo 1.73 GHz / 2GB / 160GB / Intel Mobile 945GM/GMS/GME/943/940GML Integrated Graphics
Desktop: BioStar MCP6PB M2+ / AMD Phenom 9750 Quad Core / 4GB / 1TB SATA / 500GB SATA / EVGA GeForce 8400 GS 1GB
Reply With Quote
  #4  
Old 19th January 2012, 10:48 AM
Dangermouse Offline
Administrator - (On Leave)
 
Join Date: Aug 2007
Location: London Postbox (the red one)
Age: 48
Posts: 3,864
linuxfirefox
Re: A simple bash scripting question.

Quote:
Originally Posted by glennzo View Post
Hello Dave. The script requires sudo password since I'm doing "yum install".. So if I use your example code above those 2 commands will be executed as "glenn" ??
Yep should be (without the brackets)
Reply With Quote
  #5  
Old 19th January 2012, 10:51 AM
glennzo Online
Un-Retired Administrator
 
Join Date: Mar 2004
Location: Salem, Mass USA
Age: 57
Posts: 14,699
linuxfirefox
Re: A simple bash scripting question.

The new code then:
PHP Code:
(su - $(logname) -"gsettings set org.gnome.shell.extensions.weather woeid 2487386")
(
su - $(logname) -"gsettings set org.gnome.shell.extensions.weather unit fahrenheit"
This switches to "glenn" and executes the code? Thank you so much Dave
__________________
Glenn
The Bassinator © ®

[SIGPIC][/SIGPIC]
Laptop: Toshiba Satellite / Intel Core 2 Duo 1.73 GHz / 2GB / 160GB / Intel Mobile 945GM/GMS/GME/943/940GML Integrated Graphics
Desktop: BioStar MCP6PB M2+ / AMD Phenom 9750 Quad Core / 4GB / 1TB SATA / 500GB SATA / EVGA GeForce 8400 GS 1GB
Reply With Quote
  #6  
Old 19th January 2012, 11:58 AM
sea Online
"Shells" (of a sub world)
 
Join Date: May 2011
Location: Confoederatio Helvetica (Swissh)
Age: 34
Posts: 3,312
linuxfirefox
Re: A simple bash scripting question.

Odd enough, and dont know if this was successfull bcause of a 'bug'.
But with the previous scripts i had an autostyle gnome3 section, and some parts were just called as you first had, but for some reason it got applied. However havent used since Gnome 3.0.x...

Anyway, the script 'was ment' to be called as 'normal' (current) user, not as root.
Code:
# | Download the extension
	git clone https://github.com/simon04/gnome-shell-extension-weather.git
# | change to folder, and make installation
	cd gnome-shell-extension-weather
	./autogen.sh --prefix=/usr
	make
	sudo make install
# | 
# | shell weather extension
    seaheader "Autostyle: Weather extension"
	gsettings set org.gnome.shell.extensions.weather unit celsius
	gsettings set org.gnome.shell.extensions.weather show-comment-in-panel false
	gsettings set org.gnome.shell.extensions.weather position-in-panel center 
	gsettings set org.gnome.shell.extensions.weather city Bülach
Quote:
Originally Posted by Glennzo
Hello Dave. The script requires sudo password since I'm doing "yum install".. So if I use your example code above those 2 commands will be executed as "glenn" ??
If you're executing the sudo yum install, just the next line will (should) be executed as 'current' user again.

Only if you have reloaded the script as root, or having the code block to be run as root might cause an issue you're having. Or if you wrote an 'improper' one liner. By improper i mean, more than required is run as root.
__________________
Laptop: Toshiba satellite p50-a-11 CPU: Intel i7 8*2400 MHz GPU: GeForce GT 745M RAM: 8192 MB Distro: Fedora (Rawhide) DE: Awesome
Text User Interface (TUI) // Windows 8+ & Fedora 20+ Dualboot
Reply With Quote
Reply

Tags
bash, question, scripting, simple

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Bash Scripting Question cdgary Using Fedora 6 7th January 2012 03:39 PM
Bash scripting question Reekwind Programming & Packaging 10 16th December 2008 03:31 PM
Bash scripting question MaldiGola Using Fedora 5 7th September 2006 05:13 PM
Simple shell scripting question the poi Programming & Packaging 1 19th May 2006 08:33 PM
A question with bash scripting pinenut Using Fedora 3 1st March 2006 08:06 PM


Current GMT-time: 23:42 (Tuesday, 02-09-2014)

TopSubscribe to XML RSS for all Threads in all ForumsFedoraForumDotOrg Archive
logo

All trademarks, and forum posts in this site are property of their respective owner(s).
FedoraForum.org is privately owned and is not directly sponsored by the Fedora Project or Red Hat, Inc.

Privacy Policy | Term of Use | Posting Guidelines | Archive | Contact Us | Founding Members

Powered by vBulletin® Copyright ©2000 - 2012, vBulletin Solutions, Inc.

FedoraForum is Powered by RedHat