Linux.com

Author Message
Joined: Apr 18, 2008
Posts: 13
Other Topics
Posted Apr 18, 2008 at 3:57:33 PM
Subject: execute a script on start up
im using kubuntu 7.10 and i would want to run a command when my computer starts. how can i do that with linux ? furthermore, what if that command i wanted to run needs "sudo"? for example i have this: just for example : open xorg.conf [quote] sudo kate /etc/X11/xorg.conf [/quote] the command uses "sudo" because the file is owned by root. thanks!
Back to top Profile Email Website
tophandcwby
Joined Apr 10, 2008
Posts: 81

Other Topics
Posted: Apr 18, 2008 5:22:04 PM
Subject: execute a script on start up
Are you trying to edit your /etc/X11/xorg.conf every time your computer boots? Or, are you just trying to edit the /etc/X11.xorg.conf until you get it running correctly?
Back to top Profile Email Website
Synthead
Joined Apr 17, 2008
Posts: 12
Location:Seattle

Other Topics
Posted: Apr 18, 2008 10:49:00 PM
Subject: execute a script on start up
It sounds like you're trying to get around a problem that would require you to edit a config ... what is the issue? You could put it in /etc/rc.conf on some distros You could put it in ~/.xinitrc at X startup time There are others ...

www.archlinux.org

Back to top Profile Email Website MSN Yahoo! AOL Instant Messenger
r2b2
Joined Apr 18, 2008
Posts: 13

Other Topics
Posted: Apr 19, 2008 12:40:37 AM
Subject: execute a script on start up
sorry, the xorg editing thing is just an example where i wanted to run a command during startup. wait, i found it! here's what im trying to execute during startup : [quote] sudo smbmount //192.168.1.2/Music /home/dbott/music -o username=dbott,password=mysecretpassword,uid=1000,mask=000 [/quote] i would like the samba share to mount automatically so that users wont execute this script anymore, and it requires sudo , which is not applicable to non admin users... [Modified by: r2b2 on April 19, 2008 12:41 AM]
Back to top Profile Email Website
tophandcwby
Joined Apr 10, 2008
Posts: 81

Other Topics
Posted: Apr 19, 2008 1:14:57 AM
Subject: execute a script on start up
Rather than using a startup script, you need to create an entry in your /etc/fstab. A quick google showed the following link http://www.cyberciti.biz/faq/configure-a-system-to-automount-a-samba-share-with-etcfstab/
Back to top Profile Email Website
r2b2
Joined Apr 18, 2008
Posts: 13

Other Topics
Posted: Apr 19, 2008 3:07:40 AM
Subject: execute a script on start up
yeah thats another thing,., but what about commands like ,for example start an application that requires sudo?
Back to top Profile Email Website
tophandcwby
Joined Apr 10, 2008
Posts: 81

Other Topics
Posted: Apr 19, 2008 12:03:59 PM
Subject: execute a script on start up
When using debian and maybe ubuntu since it is derived from debian, to run a script at boot time, write the script and locate it at /etc/rc.local During the boot up process the script in /etc/init.d/rc.local checks for /etc/rc.local and if it's executable, runs it. This script will be run with root privilege so sudo is not needed. If you wanted to run a command in the script with another users privilege it would look something like sudo -u tom /path/to/command To learn more about start up scripts, run the command man boot-scripts
Back to top Profile Email Website
r2b2
Joined Apr 18, 2008
Posts: 13

Other Topics
Posted: Apr 21, 2008 7:06:01 AM
Subject: execute a script on start up
[quote=tophandcwby]When using debian and maybe ubuntu since it is derived from debian, to run a script at boot time, write the script and locate it at /etc/rc.local During the boot up process the script in /etc/init.d/rc.local checks for /etc/rc.local and if it's executable, runs it. This script will be run with root privilege so sudo is not needed. If you wanted to run a command in the script with another users privilege it would look something like sudo -u tom /path/to/command To learn more about start up scripts, run the command man boot-scripts[/quote] Here's what i did based on what i understand on the above post: I think i got it wrong because it is not working. 1. create a file called mountSamba and located it in /home/rvk Contents of /home/rvk/mountSamba (this will mount the samba share to my desktop) [quote] smbmount //samba/common /home/rvb/Desktop/samba/ -o username=rvb,uid=1000,mask=000 [/quote] 2. Make the file executable : [quote] sudo chmod +x /home/rvk/mountSamba [/quote] 3. Locate it in /etc/rc.local (as suggested above) Contents of /etc/rc.local : [quote] #!/bin/sh -e # # rc.local # # This script is executed at the end of each multiuser runlevel. # Make sure that the script will "exit 0" on success or any other # value on error. # # In order to enable or disable this script just change the execution # bits. # # By default this script does nothing. # the file that contains the command for mounting samba /home/rvk/mountSamba exit 0 [/quote] Then i rebooted the system. I was expecting that the samba will be automatically mounted on my desktop folder when the system starts, but to no avail. Please tell me if i did something in the above steps. Thanks!
Back to top Profile Email Website
tophandcwby
Joined Apr 10, 2008
Posts: 81

Other Topics
Posted: Apr 21, 2008 1:48:33 PM
Subject: execute a script on start up
Did you make /etc/rc.local executable? Did you make //samba/common a shared file on the windows machine?
Back to top Profile Email Website
Tableless layout Validate XHTML 1.0 Strict Validate CSS Powered by Xaraya