LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > MEPIS
User Name
Password
MEPIS This forum is for the discussion of MEPIS Linux.

Notices


Reply
  Search this Thread
Old 11-22-2006, 10:24 AM   #1
joany
LQ Newbie
 
Registered: Nov 2006
Posts: 15

Rep: Reputation: 0
How Do I Create A Startup Script?


How do I create a startup script to run an application in background during/after booting up? The application in question is already installed. I presently use a desktop icon to launch it immediately after booting up, but I really would rather have it launch itself automatically. Does this have anything to do with "daemons" and such?? Please provide a step-by-step example of how to do this, since I am quite new to Linux and need a lot of hand holding at this stage!

Thanx
 
Old 11-22-2006, 10:34 AM   #2
fordeck
Member
 
Registered: Oct 2006
Location: Utah
Posts: 520

Rep: Reputation: 61
What is the application?

What distro are you using?
 
Old 11-22-2006, 12:01 PM   #3
joany
LQ Newbie
 
Registered: Nov 2006
Posts: 15

Original Poster
Rep: Reputation: 0
Startup Script

fordeck,

I'm using Mepis, which I believe is a variation of Debian, and the application I want to launch is VMware-Toolbox.
 
Old 11-22-2006, 01:27 PM   #4
fordeck
Member
 
Registered: Oct 2006
Location: Utah
Posts: 520

Rep: Reputation: 61
I'm not real familiar with Mepis. However I believe you could append the VMware-Toolbox statement into your user's ~/.profile file so that every time you login it is run.

Last edited by fordeck; 11-22-2006 at 01:29 PM.
 
Old 11-22-2006, 02:12 PM   #5
joany
LQ Newbie
 
Registered: Nov 2006
Posts: 15

Original Poster
Rep: Reputation: 0
fordeck,

Thanks for getting back to me. I opened a terminal and typed "locate .profile" and got hits on a number of files in the form *.profile, including one named "/usr/share/base-files/dot.profile"

When I open the file in a text editor, there is a header that says:

"# ~/.profile: executed by Bourne-compatible login shells."

Is this the file I should try to append? What is the proper syntax for a line of script that starts an application from this file? For example, if the terminal command to start the application is "vmware-tools," is that all I need to append to the script? Or should the syntax be: "vmware-tools start" in the script?

I'm sorry for asking such stupid questions, but as I said earlier, I need a lot of help at this stage.

Thanks in advance for your help ...
 
Old 11-22-2006, 04:21 PM   #6
fordeck
Member
 
Registered: Oct 2006
Location: Utah
Posts: 520

Rep: Reputation: 61
The .profile I spoke of would be in your user's home directory for example:

/home/joany/.profile

This file is ran everytime you login. You could append something like this to the bottom of .profile:

Code:
if [ -x /<path-to-vmware-tools>/vmware-tools ]; then
           /<path-to-vmware-tool>/vmware-tools
fi
However this approach could cause problems. Like I said earlier .profile gets executed everytime you login. A better approach would be to create a PID or process id file when vmware-tools starts, and have the script check for its existence. I'll have to see if I can create something that would do that.

Last edited by fordeck; 11-22-2006 at 04:22 PM.
 
Old 11-23-2006, 09:48 AM   #7
joany
LQ Newbie
 
Registered: Nov 2006
Posts: 15

Original Poster
Rep: Reputation: 0
fordeck,

Thanks for your time and trouble. I log in as "username", but unfortunately, I cannot locate a file named /home/username/.profile on my system.

It may be that Mepis uses a different naming convention for the profile file than the distro you're using. I'll try adding the lines of code you suggested in your last post into the /usr/share/base-file/dot.profile file and see what happens. Having the code run every time I log in should not be a problem.

As you might have guessed I'm running Mepis on a virtual machine (VMware) instead of from a full install, so there's no harm in trying this out. I'm presently taking Mepis for an extended "test drive" before doing a full install. So I'll back up my virtual file system and if things get out of hand and "blow up," I can easily restore everyting back to normal from the back up copy.

Thanks again...
 
Old 11-23-2006, 10:10 AM   #8
fordeck
Member
 
Registered: Oct 2006
Location: Utah
Posts: 520

Rep: Reputation: 61
Your right, I don't use Mepis so maybe they do it differently. You could also create one in your home directory and see if that works. The file you mentioned above /usr/share/base-file/dot.profile is probably a template file for users personal .profile files. You probalbly already know this but just in case. Files that begin with a "." are hidden files and can be listed by:

ls -a

or you can view the contents like this:

cat ~/.profile

Last edited by fordeck; 11-23-2006 at 10:18 AM.
 
Old 11-24-2006, 12:55 PM   #9
joany
LQ Newbie
 
Registered: Nov 2006
Posts: 15

Original Poster
Rep: Reputation: 0
fordeck,

You may be quite right about the /usr/share/base-file/dot.profile being only a "template" file. I'll try creating a new hidden file named /home/username/.profile containing the lines of code you suggested in your 11-22-06 5:22PM post. I'm at a friend's house and will get back to testing Mepis on my computer next Monday. I'll post the results early next week.

Thanks once again and cheers.
 
Old 11-27-2006, 05:53 AM   #10
joany
LQ Newbie
 
Registered: Nov 2006
Posts: 15

Original Poster
Rep: Reputation: 0
fordeck,

Following your suggestion, I created a file named /home/username/.profile and wrote the following lines of code using a text editor:

if [ -x /usr/bin/vmware-tools ]; then
/usr/bin/vmware-tools
fi

I verified that the .profile file had been saved in the proper folder, then I rebooted the machine and logged in as username. Unfortunately, it seems that the script I wrote in the .profile file failed to execute during the sign-on sequence, because vmware-tools wasn't running and I had to start it manually.
 
Old 11-27-2006, 10:00 AM   #11
fordeck
Member
 
Registered: Oct 2006
Location: Utah
Posts: 520

Rep: Reputation: 61
One other possibility might be to use "/etc/rc.d/rc.local". This path is relative to a Fedora installation. Your rc.local might be in another location. The rc.local file is executed after all other runlevel scripts have run at bootup. Again this file only runs at system bootup. Also it would probably be a good idea to run vmware-tools in the background so one small modification to the code:

Code:
if [ -x /usr/bin/vmware-tools ]; then
/usr/bin/vmware-tools &
fi
The ampersand added to run it in the background.
 
Old 11-27-2006, 04:20 PM   #12
joany
LQ Newbie
 
Registered: Nov 2006
Posts: 15

Original Poster
Rep: Reputation: 0
fordeck,

Thanks once again for your trouble. I agree that it would be preferable to run vmware-tools in the background, and I'll add the "&" to the code to do that.

I did some research and learned that by default, VMware is supposed to automatically launch while the Linux guest OS boots. But it seems that Mepis doesn't fully support all of VMware's features, which is why I'm having this problem. It could be that Mepis uses different startup files than the other distros.

I won't have time to try out your most recent suggestion until tomorrow -- I'll post the result then.

Cheers

Last edited by joany; 11-28-2006 at 07:25 AM.
 
Old 11-28-2006, 07:21 AM   #13
joany
LQ Newbie
 
Registered: Nov 2006
Posts: 15

Original Poster
Rep: Reputation: 0
Okay...

I located a file named /etc/rc.local. The file header states that the script is executed, "At the end of each multiuser run level."

There is another file named /etc/init.d/rc.local. The script contained in that file calls /etc/rc.local, so I thought the logical choice was to insert the script that launches vmware-tools into /etc/rc.local. Using root privileges, I edited /etc/rc.local, saved the file, rebooted, and logged in under username. As before, vmware-tools was not running after I logged in and I had to start it manually.

Finally, I said, "What the heck," and inserted the script to launch vmware-tools into /etc/init.d/rc.local, saved the file, rebooted and logged in. Same result: Vmware-tools was not running.

At this point, I'm not at all sure that my script is even being accessed during boot-up or logging in. Is there some way to display some sort of message or banner that would verify that the script I added is actually being read? That could help pinpoint whether there is a problem with the script itself or if the script simply is being ignored.

This has been quite educational for me, even though we haven't solved the problem!
 
Old 11-28-2006, 12:58 PM   #14
joany
LQ Newbie
 
Registered: Nov 2006
Posts: 15

Original Poster
Rep: Reputation: 0
... Continued

It seems that with Mepis, any executable files that are saved in the folder /home/username/.kde/Autostart will start automatically when "username" logs in.

Now my question is how can I create a script file (from scratch) that launches itself from that folder? Can one use any text editor (like GEDIT) to create such a script file, or is a special editor required? How should I save such a file; i.e., what is the convention for naming executable script files?

I used GEDIT to create a file named "vmware" with script code in it. Then I saved this file into the Autostart folder. However, when I logged in, GEDIT launched itself and displayed the text in the "vmware" file, instead of executing the script that I wrote in the file.

I think I'm close to finding the solution to this problem and I'm sure the solution will turn out to be fairly simple, but I could definitely use some more help at this point.
 
Old 11-29-2006, 10:15 AM   #15
fordeck
Member
 
Registered: Oct 2006
Location: Utah
Posts: 520

Rep: Reputation: 61
Joany,

Sorry for the delay, I think your on the right track. I think all you would have to do in /home/username/.kde/Autostart is create a symbolic link to vmware-tools. For example:

Code:
ln -s /usr/bin/vmware-tools /home/username/.kde/Autostart/vmware
This will create the symbolic link, similar to a shortcut in windows. I haven't tested this yet but I will and I'll get back to you.
 
  


Reply

Tags
autostart, boot, script


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
'cannot stat' script in /etc/rc.d/, try to run script at startup quintan Linux - Software 1 11-21-2005 02:53 AM
How to call a script from a system startup script? jonatito Linux - Newbie 7 11-11-2005 09:40 PM
newbie - how to create a startup script gogogadgetearl Linux - Software 2 10-02-2005 08:14 PM
Trying to create a startup script for tuxnes emulator Kilahchris Linux - Software 1 10-28-2004 05:27 AM
How To Create a DOS Startup Disk in linux? hari_seldon99 Linux - Software 2 07-01-2004 02:23 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > MEPIS

All times are GMT -5. The time now is 07:16 PM.

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