Fedora Linux Support Community & Resources Center
  #1  
Old 15th November 2011, 12:51 AM
PavedWave Offline
Registered User
 
Join Date: Nov 2011
Posts: 20
linuxfirefox
Startup script.. I know its basic...

My first post on these forums so I'd like to say hello all.

Im fairly new to linux, have learnt to do a lot in it but still need to learn some basic things I haven't done before.

Yes, I've tried searching it, have attempted making it work and am getting nowhere..

Here goes,
I'm trying to create a startup script to run "echo low > /sys/class/drm/card0/device/power_profile" (sets the graphics card to a low power mode).

As I understand I should create a file in init.d, chmod +x to make it executable... and it's not working.

Please note this is the only line I entered in the script, am I missing something? Or my other guess is that it is not working because it needs to be run after log in?

Thanks for bearing with me

Also a question, why is there generally a "#! /bin/sh" as the first line in a script, as I understand the # makes it so the line isn't read?

Last edited by PavedWave; 15th November 2011 at 12:54 AM.
Reply With Quote
  #2  
Old 15th November 2011, 01:01 AM
drnetsys Offline
Registered User
 
Join Date: Jan 2011
Location: Louisburg NC
Posts: 127
linuxfirefox
Re: Startup script.. I know its basic...

#! /bin/bash or csh or sh is so that no matter what shell you are using it knows what shell it was written in . # makes it as a comment in all lines but the first.
Reply With Quote
  #3  
Old 15th November 2011, 01:02 AM
marko Online
Registered User
 
Join Date: Jun 2004
Location: Laurel, MD USA
Posts: 6,064
solarisfirefox
Re: Startup script.. I know its basic...

Quote:
Originally Posted by PavedWave View Post
My first post on these forums so I'd like to say hello all.

Im fairly new to linux, have learnt to do a lot in it but still need to learn some basic things I haven't done before.

Yes, I've tried searching it, have attempted making it work and am getting nowhere..

Here goes,
I'm trying to create a startup script to run "echo low > /sys/class/drm/card0/device/power_profile" (sets the graphics card to a low power mode).

As I understand I should create a file in init.d, chmod +x to make it executable... and it's not working.

Please note this is the only line I entered in the script, am I missing something? Or my other guess is that it is not working because it needs to be run after log in?

Thanks for bearing with me

Also a question, why is there generally a "#! /bin/sh" as the first line in a script, as I understand the # makes it so the line isn't read?
The first line is an exception to the # as comment rule, when the shell reads the file and see's #! as the first two characters on line 1, it interprets the rest of the line as an executable to run (here it would be /bin/sh )
If you don't do that, the shell won't run that script. There is a way to run a script without the #! and that is to pass the script filename to the shell as an argument:
Quote:
sh somescript
But this won't work for an init script. Just put the #!/bin/sh on as the first line and your script should work

for more reference see:
http://en.wikipedia.org/wiki/Shebang_(Unix)
Reply With Quote
  #4  
Old 15th November 2011, 01:16 AM
PavedWave Offline
Registered User
 
Join Date: Nov 2011
Posts: 20
linuxfirefox
Re: Startup script.. I know its basic...

Thanks for the quick response,

well my script is now

#!/bin/sh
echo low > /sys/class/drm/card0/device/power_profile

But once booted i still need to run it manually in terminal...

Any Ideas

UPDATE:
after creating /etc/rc.d/rc.local and entering the same into it that now works.
Now, just out of curiosity any idea why this is working but not the file i created called /etc/rc.d/init.d/gpudown

Thanks for the help

Last edited by PavedWave; 15th November 2011 at 01:39 AM.
Reply With Quote
  #5  
Old 15th November 2011, 01:58 AM
scott32746 Offline
Registered User
 
Join Date: Jun 2007
Location: Lake Mary, Florida
Age: 50
Posts: 1,088
windows_xp_2003firefox
Re: Startup script.. I know its basic...

Hello,

Once you create your script in /etc/init.d it need to be link to a run level.
do
ls -ld /etc/rc*.d

Once you decide what rc ( run level ) .d you want to use need to link it with a S99 in front of it
Any number should work.

example:
cd /etc/rc?.d
ln -s /etc/init.d/test S99test

I would think you would want to use /etc/rc5.d
Reply With Quote
  #6  
Old 15th November 2011, 02:04 AM
PavedWave Offline
Registered User
 
Join Date: Nov 2011
Posts: 20
linuxfirefox
Re: Startup script.. I know its basic...

Okay that makes perfect snes, I thought I had read about something to do with that, but most didn't mention it so i ignored it.

I'm assuming the default local one I created gets the run level 5 by default? Thanks for the help all, enjoying the learning curve!
Reply With Quote
Reply

Tags
basic, script, startup

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
script to use at startup pmorg Programming & Packaging 2 22nd July 2011 04:48 AM
smb startup script crab_com Using Fedora 0 18th February 2009 04:47 AM
startup script? shafted Using Fedora 1 10th December 2007 12:50 AM
Basic bash script dalvarez Programming & Packaging 11 30th November 2007 04:30 PM
startup script jyrppa Using Fedora 2 7th March 2005 02:00 PM


Current GMT-time: 00:19 (Sunday, 26-10-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
Khasab Photos on Instagram - Mobaye Travel Photos on Instagram - Kokopo