Click here to Skip to main content
15,891,935 members

Ifconfig in shell script, not able to run on startup of Linux RedHat

Revision 2
I want to run shell script which has "ifconfig" command written and placing output to another file.

Actually we dont know the ip address of the machine, we have deployed Linux on it. we want to know IP address of that machine once it gets boot up. so on boot up it will create one file with ifconfig output, so we can read ip address.

code:

hostname=$(hostname)

#mount shared drive
mount -t cifs -o username= ,password= //111.111.111.111/MLC /mnt

#delete file if it already exists locally
if [ -f /$hostname.txt ];
then
rm -f /$hostname.txt
fi

#delete file if it exists in the share
if [ -f /mnt/$hostname.txt ];
then
rm -f /mnt/$hostname.txt
fi

#create new file
touch $hostname.txt
#redirect ip details to the file
ifconfig>$hostname.txt
#copy to the mounted share
cp /$hostname.txt /mnt/$hostname.txt
#unmount
umount /mnt



i am able to run other commands in startup, but not only ipconfig command.

does anybody help me?

Thanks
Posted 2-Oct-12 0:45am by YogeshDewangan@dell.
Tags: