Jump to content

How to run scripts automatically on boot [solved]


Recommended Posts

There is something I would like to run automatically whenever I restart my system.

 

I know practically nothing about writing or running scripts, but this is what I am forced to run each time I boot my system:

				   $ cd /home/dude67/Programmes/ftpd-topfield-0.7.4/
			   $ ./ftpd -D -P 2021

I was searching through this forum and thought this would go nicely as a script; something like this (please correct the code as I'm not sure if this is enough)

#!/bin/bash
			 cd /home/dude67/Programmes/ftpd-topfield-0.7.4/
			 ./ftpd -D -P 2021

If this is correct (or corrected by someone), how do I get it to run automatically everytime i boot my system?

Link to comment
Share on other sites

OK, thanks guys.

 

But how do I do that? I mean, do I save this script with just these few lines as a file (named something like ftpdToppy) in either of these two locations

/etc/rc.local

or

~/.kde/Autostart

 

And does it matter what the name of the file is?

Link to comment
Share on other sites

Thanks Greg, I'll do that. That sounds simple enough.

 

Just one question: how do I refer to one particular location for a file to be executed?

This is what I normally do, after I have booted my Mandriva:

 

	 # cd /home/dude67/Programmes/ftpd-topfield-0.7.4/
 # ./ftpd -D -P 2021

And will this be a problem: if I'm not mistaken, I should run ftpd as root?

Link to comment
Share on other sites

Thanks Ian!

 

As I'm no expert on the subject, I'd still like to know how does this work if something should be run in a particular folder?

 

I need to run "./ftpd -D -P 2021" as a root in this folder "/home/dude67/Programmes/ftpd-topfield-0.7.4/".

 

How do I do that? What are the lines I need to add to the /etc/rc.local -script?

Link to comment
Share on other sites

The "cd /home/dude67/Programmes/ftpd-topfield-0.7.4/" line you put before ./ftpd will ensure the latter will execute in this directory.

I recommend you append an ampersand at the end of your ./ftpd line (unless the -D is already there to bring ftpd to background), and you add a third line to your rc.local script:

cd -

which, AFTER ftpd has started, ensures the working directory returns to what it was before, in case you (or install scripts) have more lines to append to this file.

 

Yves.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...