Automatically detecting profile

This is a discussion on Automatically detecting profile within the Linux Programming forums, part of the Platform Specific Boards category; Hello, I used newbtconf(8) to create networked and offline profiles. Upon bootup I have to type the appropriate profile, which ...

  1. #1
    Registered User
    Join Date
    Sep 2003
    Posts
    224

    Automatically detecting profile

    Hello,
    I used newbtconf(8) to create networked and offline profiles. Upon bootup I have to type the appropriate profile, which I don't like, and sometimes when I leave the laptop alone, the default configuration file is selected, which is sometimes not what I want. Then I have to change where /etc/etc.current is pointing to. Is there a way in /etc/rc.conf to detect whether or not the network cable is plugged (and possibly whether my wireless card is in, when NetBSD supports it) and based on that set the appropriate variables?

    Thanks,
    Yasir

  2. #2
    Obsessed with C chrismiceli's Avatar
    Join Date
    Jan 2003
    Posts
    501
    Well, assuming you know shell scripting, because I don't, you could do this. When you plug in your network card (wireless one), a device is created in /dev right? So check to see if that device exist, and if it does, point the sym link according, and if not accordingly also. Right?
    Help populate a c/c++ help irc channel
    server: irc://irc.efnet.net
    channel: #c

  3. #3
    Registered User
    Join Date
    Sep 2003
    Posts
    224
    NetBSD doesn't support my wireless card, yet. I want to do this for my Ethernet card. I only want to load the networked profile when the cable is plugged in.

  4. #4
    Obsessed with C chrismiceli's Avatar
    Join Date
    Jan 2003
    Posts
    501
    Well, if you network cable is plugged in, you should have a connection, right? So just ping something, get the result, and point your symlinks accordingly.
    Help populate a c/c++ help irc channel
    server: irc://irc.efnet.net
    channel: #c

  5. #5
    Registered User
    Join Date
    Sep 2003
    Posts
    224
    I don't have a network connection now, but doesn't ping need for me to have an IP address?

  6. #6
    .
    Join Date
    Nov 2003
    Posts
    307
    Yes, it does.

  7. #7
    Registered User
    Join Date
    Sep 2003
    Posts
    224
    So I can't use ping to determine whether the network cable is plugged in. Just because a network cable is plugged in doesn't determine I automatically have an IP address. What I want to do is get an IP address if the network cable is plugged in, and if the cable isn't plugged, don't attempt to get an IP address.

  8. #8
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,659
    Try out "ifconfig -a" or "ifconfig [interface]". I believe you won't have an "inet" line under an adapter with no link - can't test it here at home however.

    gg
    Last edited by Codeplug; 12-21-2004 at 12:58 PM.

  9. #9
    Registered User
    Join Date
    Sep 2003
    Posts
    224
    That looks promising, but wouldn't the same thing be displayed if the cable was plugged in and didn't have an IP address as compared to when a cable wasn't plugged in. Sorry, I can't test it home right now either.

  10. #10
    Registered User
    Join Date
    Feb 2004
    Posts
    1
    If all you need is to bring your nic up when the cable is plugged in, then maybe ifplugd is what you need. It's a daemon that detects when your cable is plugged in and brings it up, much like windows.

  11. #11
    Registered User
    Join Date
    Sep 2003
    Posts
    224
    I am looking for a solution that will call the appropriate script upon boot up, not anytime after (although that would be nice). I do not think that first solution will work because, according the output to the console upon boot up, daemons are started after the appropriate rc.conf file is run. But I'll try it out when I have access to an Ethernet port.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Do cpp Files get Included Automatically in VS?
    By bengreenwood in forum C++ Programming
    Replies: 2
    Last Post: 05-20-2009, 04:12 PM
  2. Replies: 0
    Last Post: 07-02-2007, 12:32 AM
  3. Bluetooth Dial-up network profile with AT commands
    By BrownB in forum Networking/Device Communication
    Replies: 0
    Last Post: 06-29-2005, 02:47 AM
  4. Dev-C++ Profile Analysis
    By Orborde in forum C++ Programming
    Replies: 0
    Last Post: 05-28-2005, 01:37 AM
  5. setting file associations automatically
    By 149 in forum Windows Programming
    Replies: 2
    Last Post: 01-04-2003, 06:03 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21