My main machine is set-up so that I configure the network details (IP etc) by command line. However I'm trying to create an bash script to run those commands upon system startup. Problem I have is that the commands require root access and I want it to be fully automatic.
Now I figure I need to add the bash script into system script so the system runs it as root but not sure how to do that? I though of maybe it adding it to a directory where other start-up scripts are run like /etc or /init.d but it can't be that simple can it?
On a side note I'm also trying to make it actually test that the connection is running before saying Network Is Up. I can do this with Ping, but how do I access the return so that it can report if the ping failed (and network is down).
Can't really utilize sudo as that would still require the password to be entered at some point. I want it to start and run automatically (without any user input needed) upon system boot.
You could add your script to /etc/init.d and then add symlinks in runlevel directories (/etc/rc?.d). Or you could append your script to rc.local if your system uses one.
I've left out the ping section for the moment until I can get it working first.
I attempted to follow your advise agn but it doesn't seem to work. Here is what I got so far.
Named my script network-launch. Copied it to /etc/init.d.
I then used the command
in both /etc/init.d/rc3.d and /etc/init.d/rc5.d (command line with networking and gnome with networking respectively). I tried also changing the start to S03 are a variety of other combinations of S and K with different numbers putting it before and after the K and S network symlink.
After some quick diagnostics I discovered that upon system boot the eth0 (my network card) was not being actived. So I changed the script to add the following line to the start
And then re-run the symlink creation commands to create new links after remove the old ones.
However this is still not working. It doesn't appear the script is being run at all since even with the addition of the new line to bring eth0 up; eth0 is still not up after system boot.
Oh and I'm running OpenSuse 11.2 with network manager disabled (hence the use of command line).
First of all init.d scripts have a fairly specific format if you want the script to play well with the operating system. Here is an outline of the format. Look at other files in init.d to get a fuller understanding.
Next, you need to decide what run level your init script is started at and what run level your init script is stopped at. They may be different.
I suggest you start your script at runlevel 2. This means that you need symbolic link from your init.d script to a file named SxxYourScriptName in the rc2.d directory.
In Bash shell - the ps -ef shows only the /bin/bash but the script name is not displayed ? Is there any way to get the script names for the process command ?
--- Post updated at 08:39 AM ---
in KSH (Korn Shell), my command output shows the script names but when run in the Bash Shell... (3 Replies)
I'm new to utilities like socat and netcat and I'm not clear if they will do what I need.
I have a "compileDeployStartWebServer.sh" script and a "StartBrowser.sh" script that are started by emacs/elisp at the same time in two different processes.
I'm using Cygwin bash on Windows 10.
My... (3 Replies)
Hi guys,
i'm beginner with Unix, I tried my best, but I Really don't know how to finish it :D.
here's my problem : I have to do something like Student system - student's name | subjects | mark |credits.
after starting script it will ask you for Student's name, then which subject, then the... (2 Replies)
Hello,
The problem I met is the conflict between the default command /usr/bin/sometools, which is an very old version at system setup, and an updated one I have installed in $HOME/download-software/sometools
How do I tell a third program to use the customized sometools instead of the default... (6 Replies)
I want to find all bash scripts on my system.
What I have so far is this:
find / -type f \( -perm -u=x -o -perm -g=x -o -perm -o=x \) | xargs -I{} head -1 {} |grep bashThis will find all executables, read the first line and diplay it, if it contains "bash". Almost done, but I also need the... (8 Replies)
# check host value regex='^(||1|2|25)(\.(||1|2|25)){3}$' if ')" != "" ]; then if ]; then echo host $host not found exit 4 fi elif ]; then echo $host is an invalid host address exit 5 fi
espeacailly the top regex part?
---------- Post updated at 06:58 PM ---------- Previous update was... (1 Reply)
Hello all,
I'm attempting to write a basic application that appends an arbitrary list of txt files to one txt file.
So, for example, if the application is run like so:
appendFileToFile file1.txt file2.txt file3.txt the system command should, hopefully be, cat >> testfile.txt
I'm... (4 Replies)
Hi
we are calling kill -9 $pid command from bash script it gives below output, but we need to hide the output. i tried /dev/null but ni luck. is there any alternate way to schive this.
../kill_scr.sh: line 42: 1891 Killed /tmp/anr_rest_mul_wc.sh
Soalris 10.
... (2 Replies)
A Newbie here,
I am working on a script and am having problems with the else part of the script. I can't get the users who are not logged into the system to display on the screen with their username and the text "The user is not logged in". I am sure it is something simple and stupid, but I... (5 Replies)
hi,
i have a script that runs on bash and would like to run it on a machine that has csh and bash. the default setting on that machine is csh. i dont want to change my code to run it with a csh shell. is there any way i can run the script (written in bash) on this machine? in other words is there... (3 Replies)