LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-28-2004, 06:49 PM   #1
samot
LQ Newbie
 
Registered: Apr 2004
Posts: 9

Rep: Reputation: 0
shell script?


I'm ruinning a program called freepops...What I want is for it to start whenever I log into my account...How would I do this? A shell script? If so, how do I write said script? All I need to do is run the command freepopsd -p2001 However, it must be run as root, even when I login as a different user. ANy help would be apperciated!
Thanks
-Tomas Novickas
 
Old 10-28-2004, 07:23 PM   #2
samot
LQ Newbie
 
Registered: Apr 2004
Posts: 9

Original Poster
Rep: Reputation: 0
BTW--I'm running SUSE
 
Old 10-28-2004, 08:17 PM   #3
twantrd
Senior Member
 
Registered: Nov 2002
Location: CA
Distribution: redhat 7.3
Posts: 1,440

Rep: Reputation: 52
Just add the path of the binary with arguments (/whereever/freepopsd -p2001) to your .bashrc or whatever shell you are using. Not sure if that will work but try.

-twantrd
 
Old 10-28-2004, 08:32 PM   #4
btmiller
Senior Member
 
Registered: May 2004
Location: In the DC 'burbs
Distribution: Arch, Scientific Linux, Debian, Ubuntu
Posts: 4,290

Rep: Reputation: 378Reputation: 378Reputation: 378Reputation: 378
That would run it as his user account, though, not as root. The program could be made SUID root, or if it needs to be run regularly, why not run it from cron?
 
Old 10-29-2004, 05:03 PM   #5
samot
LQ Newbie
 
Registered: Apr 2004
Posts: 9

Original Poster
Rep: Reputation: 0
cron's not what i need because the program only needs to be started once--when I log in or even when the ocmputer starts (that would be better, I think)
 
Old 10-29-2004, 05:09 PM   #6
wapcaplet
LQ Guru
 
Registered: Feb 2003
Location: Colorado Springs, CO
Distribution: Gentoo
Posts: 2,018

Rep: Reputation: 48
Put the command you need to run in a script, and copy the script into /etc/init.d. Make it executable by doing (as root):

Code:
chmod +x /etc/init.d/yourscript
I believe the first line of the script needs to be:

Code:
#!/sbin/runscript
for it to work this way. Anything in the /etc/init.d folder is executed when your computer boots up (I'm not sure if SuSE uses a different location; it might be /etc/rcS or something similar); you can run it manually just by typing /etc/init.d/yourscript from a root console.

Last edited by wapcaplet; 10-29-2004 at 05:11 PM.
 
Old 10-29-2004, 06:18 PM   #7
samot
LQ Newbie
 
Registered: Apr 2004
Posts: 9

Original Poster
Rep: Reputation: 0
the program needs to run as root to start properly--will this method do this? actually, i wasn't able to get the script to work:
ws116159:~ # /etc/init.d/freepopsstartup
bash: /etc/init.d/freepopsstartup: /sbin/runscript: bad interpreter: No such file or directory

any ideas?
 
Old 10-29-2004, 06:26 PM   #8
samot
LQ Newbie
 
Registered: Apr 2004
Posts: 9

Original Poster
Rep: Reputation: 0
I made the file have the .sh extension to it, but when I restart my computer, it dosen't start freepops.
 
Old 10-29-2004, 07:02 PM   #9
btmiller
Senior Member
 
Registered: May 2004
Location: In the DC 'burbs
Distribution: Arch, Scientific Linux, Debian, Ubuntu
Posts: 4,290

Rep: Reputation: 378Reputation: 378Reputation: 378Reputation: 378
Do you have an /sbin/runscript binary? The shebang (#!) is followed by the name of the interpreted to run the script, e.g. #!/bin/bash for a bash script. To make the program run as root, you'll need to set it SUID root, but the kernel will not honor the SUID bit on shell scripts. If it's in Perl you could use suidperl, otherwise you'll have to write a wrapper for it (this is a simple task), but I need to ask, what do you need to run as root at login time (as opposed to boot time or periodically). if you tell us what you're trying to do, maybe someone can suggest a better way to do it.
 
Old 10-29-2004, 07:46 PM   #10
twantrd
Senior Member
 
Registered: Nov 2002
Location: CA
Distribution: redhat 7.3
Posts: 1,440

Rep: Reputation: 52
I saw on sourceforge.net (at least i think so) that there was a program that converts shell scripts to C code in which you then compile the C code to make an executable. Darn, forgot what it was called. I'll try looking for it...

-twantrd
 
Old 10-30-2004, 01:44 PM   #11
samot
LQ Newbie
 
Registered: Apr 2004
Posts: 9

Original Poster
Rep: Reputation: 0
actually, i'm trying to run it at boot time--i figured that would be the best. What I'm trying to run is a program called freepops. It checks various webmail services (gamil, aolmail, yahoo, etc) and turns it into POP3 so a normal email program can read it. I need it to start at boot time, as root, and I have to apss it certain paremeters (i.e. -p2001)
Thanks for any help!
-Tomas Novickas
 
Old 10-30-2004, 01:51 PM   #12
samot
LQ Newbie
 
Registered: Apr 2004
Posts: 9

Original Poster
Rep: Reputation: 0
apparently, and i quote:
n posix environments like Debian GNU/Linux you can start FreePOPs at boot time as a standard service. In this case the command line switches are stored in /etc/default/freepops, in some rpm based systems you should find the same file as /etc/sysconfig/freepops.

What does this mean? What is a standard service and how do I set it to start??? I think I understand the command line switches, though--I would jsut add my parameters to that file?
Thanks Again
-T
 
Old 10-30-2004, 03:13 PM   #13
btmiller
Senior Member
 
Registered: May 2004
Location: In the DC 'burbs
Distribution: Arch, Scientific Linux, Debian, Ubuntu
Posts: 4,290

Rep: Reputation: 378Reputation: 378Reputation: 378Reputation: 378
The startup scripts for services are stored in /etc/init.d or /etc/rc.d/init.d depending ondistro -- you can you chkconfig to activate a script to run at a particular runlevel (Debian uses runlevel 2 for multiuser mode, and many distros like SuSE use runlevel 3). If you don't want to mess with the runlevel scripts, you can just add the command to your rc.local (usually /etc/rc.local but SuSE might put it somewhere else).
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Shell script inside shell script treotan Linux - General 4 02-19-2009 06:34 AM
Shell Scripting: Getting a pid and killing it via a shell script topcat Programming 15 10-28-2007 02:14 AM
shell script problem, want to use shell script auto update IP~! singying304 Programming 4 11-29-2005 05:32 PM
Directory listing - Calling shell script from a CGI script seran Programming 6 08-11-2005 11:08 PM
[SHELL SCRIPT] Write at the right of the shell window Creak Linux - General 2 04-02-2004 03:00 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:46 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration