Quote:
Originally Posted by kponenation
Hi,
I have a script that sends me an email of the ip address that is currently used. The script runs perfectly when the pc is up and running. I would like to run it when it boots up so I don't have to run it manually.
I've tried calling the script from /etc/rc.local and update-rc.d defaults. But I would get an email with blank IP address. I'm guessing it's because the box doesn't have an IP assigned to it when the script gets run.
I would like to know where I need to call my script so that ifconfig will return the IP address.
Thanks in advance.
James
|
if it's running in rc.local, the network should already be configured (being that rc.local is supposed to run after everything else).
If you want it to run at boot time, a slightly more proper way of doing it would be to put your script in /etc/init.d, then link to that script in the correct rcX.d directory (corresponding to your runlevel) with an S99 prefixed to the link name, i.e. S99myscript would be a link to /etc/init.d/myscript.
That said, it *should* work in rc.local. Are you sure paths are correct? It's possible a path var has not been set for the user that runs rc.local scripts (especially for things like /sbin or /usr/local/bin), so include full paths to all programs, i.e. "/sbin/ifconfig" rather than just "ifconfig".
lastly, you could put this in a cron script for your user that compares the output of ifconfig to some file & sends a mail when it changes, though that's kinda kludgey.