I am writing a simple DHCP server application that gets ip from a server at boot up ! i wrote a shell script to run the java program that obtains ip from server on another machine...
The problem is when i have obtained the ip i store it in a file ! using awk i retrieve the ip and i'm trying to execute the command ifconfig eth0 x.x.x.x !! as it needs admin privileges it is currently not working.. i need to figure out a way such that at boot up without asking the password the program should run.... please help me!!!

Recommended Answers

All 4 Replies

Look at putting the code you want executed in /etc/init.d/ . That is the traditional location of startup scripts and they are run as root.

/etc/rc.local is a good place to put simple scripts that you want executed at boot-time. Lines in rc.local are executed as root (unless specified otherwise) and after all the other startup scripts have run.

Yes, I stand corrected. /etc/rc.local is a better location.

Not "corrected"! Enhanced! :)

You CAN create an init script and drop it into /etc/init.d
But if it's just a script that you want to run once, at boot time, /etc/rc.local is the super-simple way to do it.

I suspect the OP might have issues with this though, if he doesn't have root privileges...

dinesh17: Do you have 'root' or 'sudo' access on the system in question? You mention having trouble running the script manually. You *should* be able to run it from the command line as root, or with 'sudo'.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.