LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Fedora
User Name
Password
Fedora This forum is for the discussion of the Fedora Project.

Notices


Reply
  Search this Thread
Old 01-15-2010, 09:57 AM   #1
Mordocai
LQ Newbie
 
Registered: Jan 2010
Distribution: Fedora
Posts: 10

Rep: Reputation: 0
Startup Script Output


I am using fedora 12 to attempt to create a liveCD that will boot up, output the MAC addresses of the system, and then pause. I have a script that does this, but when I add it to /etc/rc.d/rc.local it does not output to the screen, though it does run. I am using run level 3. Is there any way to do this? Worst case scenario, we'll just have to type a command to run it after the CD boots.

P.S. This may seem pointless, but it is because one of our departments needs to record the MAC addresses of every new system, while a different one installs an OS. They come with windows but it takes forever to start up for the first time.

EDIT: And yes, the BIOS shows the ethernet MAC address, but we also need the bluetooth and wireless

Last edited by Mordocai; 01-15-2010 at 09:58 AM. Reason: Forgot to add something
 
Old 01-15-2010, 10:54 AM   #2
affinity
Member
 
Registered: Nov 2009
Distribution: Slackware64
Posts: 132

Rep: Reputation: 20
Can you post the script? I'm not sure about the pause, but using the echo command would display the output. You could make the script mount a thumb drive and store the output to a file on it. If you wanted it to be organized you could have the script create a directory on the thumb drive using an identifier for that computer, it's host name or something else that is unique, and then store the MAC addresses in a file in that directory.
 
Old 01-15-2010, 11:07 AM   #3
Mordocai
LQ Newbie
 
Registered: Jan 2010
Distribution: Fedora
Posts: 10

Original Poster
Rep: Reputation: 0
Well, the current method is to just write the mac address down with all the other info on the PC(Serial number, model number, etc) and then enter it all into spreadsheets. Everything works properly if simply executed, i'm just hoping to make it automatic since most of the people doing this have little to no knowledge of linux.

EDIT: The reason i know it runs is that the script successfully downloads macFetch-online.sh from the server.

NOTE: I'm not sure if i need to add the iwconfig output to the file in order for the script to work. I am currently testing in virtual machines, and have not tested on a machine with wireless yet.

This is what the rc.local looks like:
Code:
#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.
/MacFetch/macFetch-startup.sh
touch /var/lock/subsys/local
This is the code that the startup file has in it:

Code:
#!/bin/bash

#try to grab the networked script
cd /MacFetch/
wget -q  http://<path-to-server>/macFetch-online.sh 

#Check and see if it worked
if [ -f /MacFetch/macFetch-online.sh ]; then
	chmod +x /MacFetch/macFetch-online.sh
	/MacFetch/macFetch-online.sh
else
	/MacFetch/macFetch-local.sh
fi
This is the code that is supposed to run:
Code:
#!/bin/bash



#Set the temporary file used for this script
FILE="networkInformation.txt"
BLUEFILE="bluetoothInfo.txt"

#Get the network info and put into the file
ifconfig | grep HWaddr > $FILE
iwconfig | grep HWaddr >> $FILE
hcitool dev | grep hci > $BLUEFILE

#Formatting
echo "Interfaces     MAC Addresses"

#Go through every line in the file
#Find the interface name and MAC address
#Output with formatting
while read line
	do

		ETH=`echo $line | cut -d \  -f 1`
		HWADDR=`echo $line | cut -d \  -f 5`
		echo $ETH "         " $HWADDR

	done < $FILE

#Do the same for bluetooth
while read line
	do
		IF=`echo $line | cut -d \  -f 1`
		HWADDR=`echo $line | cut -d \  -f 5`
		echo $IF "         " $HWADDR

	done < $BLUEFILE

#remove the files
rm -f $FILE $BLUEFILE

read -n 1 -p "Press any key to continue..."

Last edited by Mordocai; 01-15-2010 at 11:45 AM.
 
Old 01-15-2010, 11:55 AM   #4
affinity
Member
 
Registered: Nov 2009
Distribution: Slackware64
Posts: 132

Rep: Reputation: 20
What I would do if you are physically going to each computer to run the script is make a bootable thumb drive with the script already stored on it. Set it up so that it automatically logs into a default account without having to use a password, and then have the script stored in the /home directory. That way the person doing this could literally just plug the drive in, turn on the computer, and then execute the script. Have you thought about doing this remotely after all the computers are already running? It would save a lot of time, and be much simpler, if it was possible for you to execute the script on all the computers in the network from another computer and have it store the data in an organized fashion. Then you could just execute the script once and give the files to whoever has to put them into a spreadsheet.

As for the script itself, ifconfig will list the HWaddr of all the interfaces, including wireless. The iwconfig command only displays information about the current connection itself.
 
1 members found this post helpful.
Old 01-15-2010, 12:33 PM   #5
Mordocai
LQ Newbie
 
Registered: Jan 2010
Distribution: Fedora
Posts: 10

Original Poster
Rep: Reputation: 0
Well, I'm rather low on the food chain here, and was assigned this project. They opted to use CDs so that they could make many copies cheaper than buying a lot of flash drives. I will, however, look into seeing if we can get the mac addresses remotely. The thing is, even our build system, Altiris, is set up to use the MAC addresses. Therefore, we have to have them before we can do much of anything. In any case, the basic functionality appears to be fine, i was just wondering whether I could get the script to start up at boot time, that way they put in the CD, turn on the computer, and come back a minute later and the MAC addresses are up on the screen. If this isn't possible, it isn't a big deal. I do know, however, that I saw it done on knoppix, but I don't know how.
 
Old 01-15-2010, 01:04 PM   #6
affinity
Member
 
Registered: Nov 2009
Distribution: Slackware64
Posts: 132

Rep: Reputation: 20
The script can be run at boot time the way you had it set up, your original problem was having it pause for the output. I would have the script itself on the disc so it doesn't have to fetch it off the server. Then, as to your original problem, I would have the script be the very last thing that is run using the echo statement to print each result. If all goes well you would see the MAC addresses above the login prompt.
 
Old 01-15-2010, 03:03 PM   #7
Mordocai
LQ Newbie
 
Registered: Jan 2010
Distribution: Fedora
Posts: 10

Original Poster
Rep: Reputation: 0
Okay, I figured out that the script was in fact running, but it was "hidden" by the graphical loading screen. To get around this I set up an autologin and set the user's .bash_profile to run the script on login.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Output to a text file at startup? drydo Debian 3 11-23-2009 11:11 AM
How to review init output after startup slackwarefan Slackware 5 09-21-2009 08:59 PM
Make a script that uses the output from another script as the variables? Oakems Programming 11 06-18-2009 05:21 PM
Correct output from script appears only when script is run interactively kaplan71 Linux - Software 2 01-15-2009 11:47 AM
Ubuntu - How to see output during startup? SlowCoder Linux - Newbie 2 10-01-2007 01:53 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Fedora

All times are GMT -5. The time now is 06:09 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration