dude67 Posted September 1, 2007 Report Share Posted September 1, 2007 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? Quote Link to comment Share on other sites More sharing options...
scarecrow Posted September 1, 2007 Report Share Posted September 1, 2007 To run a system-wide startup script, you should put it into /etc/rc.local Else, if you want to run it as plain user, putting it in ~.xinitrc usually suffices. Quote Link to comment Share on other sites More sharing options...
daniewicz Posted September 1, 2007 Report Share Posted September 1, 2007 if you are a KDE user, you can place the script in ~/.kde/Autostart Quote Link to comment Share on other sites More sharing options...
dude67 Posted September 1, 2007 Author Report Share Posted September 1, 2007 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? Quote Link to comment Share on other sites More sharing options...
Greg2 Posted September 1, 2007 Report Share Posted September 1, 2007 In Mandriva, /etc/rc.local is a symbolic link to /etc/rc.d/rc.local, and rc.local is a script, so just add your necessary lines to the /etc/rc.d/rc.local script. Quote Link to comment Share on other sites More sharing options...
dude67 Posted September 1, 2007 Author Report Share Posted September 1, 2007 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? Quote Link to comment Share on other sites More sharing options...
ianw1974 Posted September 1, 2007 Report Share Posted September 1, 2007 If it's in /etc/rc.local it will be ran by root. So no, isn't a problem. Quote Link to comment Share on other sites More sharing options...
dude67 Posted September 2, 2007 Author Report Share Posted September 2, 2007 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? Quote Link to comment Share on other sites More sharing options...
theYinYeti Posted September 3, 2007 Report Share Posted September 3, 2007 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. Quote Link to comment Share on other sites More sharing options...
dude67 Posted September 3, 2007 Author Report Share Posted September 3, 2007 Thanks Yves, I'll do that. So according to you advice, it's going to add these three lines to my /etc/rc.d/rc.local cd /home/dude67/Programmes/ftpd-topfield-0.7.4/ ./ftpd -D -P 2021 & cd - I'll post back the results. Quote Link to comment Share on other sites More sharing options...
dude67 Posted September 4, 2007 Author Report Share Posted September 4, 2007 Thanks all, that did the trick. It will load whenever I reboot my system. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.