[Mono-aspnet-list] URGENT HELP C# + DEBIAN

aaron.ullal uaaron at hotmail.it
Thu Jul 12 19:33:33 UTC 2012


Hey guys! I urgently need your help  Ok so what im trying to do is this: *
i have a debian server and i saved its mac address on a txt file in the usr
folder. What i want to do is that every time i start the machine the script
i'm trying to do should check the current mac address and compare it to the
one saved on the txt file. If they don't match than the machine should
shutdown.
 *I'm not very familiar with debian so i programmed the script in c#..it
looks like this

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Net.NetworkInformation;

namespace Get_macaddress
{
    class Program
    {
        static void Main(string[] args)
        {
            string newmc = Convert.ToString(GetMacAddress());	//current mac
address
            string mc = File.ReadAllText(@"/usr/mc.txt");	//mac address
saved on a txt file previously

            if (newmc != mc)					//shutdown if the mac addresses dont match
            {
                System.Diagnostics.Process.Start("shutdown.exe", "-s -t 0"); 
            }


        }
        static string GetMacAddress()
        {
            string macAddresses = "";
            foreach (NetworkInterface nic in
NetworkInterface.GetAllNetworkInterfaces())
            {
                // Only consider Ethernet network interfaces, thereby
ignoring any
                // loopback devices etc.
                if (nic.NetworkInterfaceType !=
NetworkInterfaceType.Ethernet) continue;
                if (nic.OperationalStatus == OperationalStatus.Up)
                {
                    macAddresses += nic.GetPhysicalAddress().ToString();
                    break;
                }
            }
            return macAddresses;
        }

    }
}

THAN what i created a txt file containing the code and i renamed in
shutdown.cs and transferred it on debian machine. 
*When i run the mcs shutdown.cs command i get this error : CS0234: The type
or namespace name 'NetworkInformation' does not exist i the namespace
'System.Net'. Are you missing an assembly reference?*


I don't know what to do guys as i said i'm not very familiar with debian nor
with mono honestly..if you guys could help me out would be fantastic.

--
View this message in context: http://mono.1490590.n4.nabble.com/URGENT-HELP-C-DEBIAN-tp4650386.html
Sent from the Mono - ASP.NET mailing list archive at Nabble.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ximian.com/pipermail/mono-aspnet-list/attachments/20120712/fc55dc5e/attachment.html>


More information about the Mono-aspnet-list mailing list