Sponsored Content
Top Forums UNIX for Advanced & Expert Users Create a script to setup the network card Post 302355722 by Corona688 on Wednesday 23rd of September 2009 01:41:06 PM
Old 09-23-2009
Quote:
Originally Posted by anargi
Hello!

Trying to build a script which will do the following:

1.) Due to continued stalling after each reboot will consider the uptime of the server and if it is less than 30 sec to load the following settings on your network.

essentially

2.) What interests me primarily is to make a script which only runs to enter the following settings on your network.

--ip
--netmask
--default gw
--key
--essid

or in one way or another.

Code:
...
if [ uptime <= 30sec ] ; then
...

shell comparisons do not work that way. Shell operations don't have a <= operator either, it's called "-le" for "less than or equal". Nor are you feeding the output of the uptime command into the comparison, you're just giving it the name of the command. And uptime doesn't report the system uptime in any manner the shell could sensibly compare it anyway, at least on my system.

My system has the file /proc/uptime which the system uptime can be read from in seconds. It has two decimal places, which will need to be removed for the shell to understand it as a number.

Code:
# We don't care about G, but if we only specify one variable here, it'll cram both numbers into one variable.
read A G < /proc/uptime
# Remove decimal point
A="${A/.*/}"
if [ "$A" -lt 30 ]
then
echo setup network card

        ifconfig wlan0 192.168.1.101 netmask 255.255.255.0 up
        route add default gw 192.168.1.1
        iwconfig wlan0 essid linksys
        iwconfig wlan0 key 123abcd123
fi

Also, you don't need semicolons at the end of a command unless you want to put more than one command on the same line.

Do you have static DNS servers set up in /etc/resolv.conf ?
 

10 More Discussions You Might Find Interesting

1. IP Networking

network card

I have a UnixWare 2 server that has an ISA 3Com NIC that has just a BNC connector on it. I want to remove this and install an ISA 3Com NIC that has a BNC/RJ45 connector. What steps do I have to go through to successfully complete this? Thye are almost the exact same cards except for the... (1 Reply)
Discussion started by: cparks
1 Replies

2. Shell Programming and Scripting

Multiple Network Card Status Script

I have multiple Sun Solaris 8 systems running multiple network cards. (Mix of quad and gig cards.) What I would like to do is create a monitor script to ensure high availability of these cards. Has anyone ever had a situation like this? I was thinking of using the ping command, but am... (1 Reply)
Discussion started by: Krusty
1 Replies

3. IP Networking

Network Setup

I am moving a SUN 250 server from one location to another. The IP address has to change in order to make the server visible in the new building. The system administrator has given me the new IP address for the server, the DNS server IP and the default gateway IP. First question, is this all the... (2 Replies)
Discussion started by: pkappaz
2 Replies

4. UNIX for Dummies Questions & Answers

Installing network card

1) i am trying to install realtek network card in caldrea linux, but i am not able to find the interface, 2)i download drivers for network card and i am not able to read the floopy in linux, pls help me out. (1 Reply)
Discussion started by: gops
1 Replies

5. UNIX for Advanced & Expert Users

Network Card Help

I have been having trouble with my sis900 neytwork card in slacwkare linux. I tried to modprobe the sis900, it didnt give me any errors but it didnt load it. so I put in a realtek 8139 network card and tried it too. These are the errors i get with the two cards when trying to do insmod on either of... (3 Replies)
Discussion started by: The Fridgerator
3 Replies

6. UNIX for Advanced & Expert Users

network card problem

hi, everyone: alpha 600 au true64 Unix 4.0f my network cart is set "Auto-Negotiate".After operate system startup,the network will be disconnected by itself at sometime. I found some prompt in /usr/adm/messages. "tu0 :transmit FIFO underflow:threshold raised to :256 byteŁ¬link up... (1 Reply)
Discussion started by: q30
1 Replies

7. Solaris

network setup

on sparc solairs 2.8 which files i need to configure for network setup: /etc/hosts /etc/defaultrouter /etc/netmasks /et/resolv.conf what els?. by the way, how do i configure for rsh?. like for doing "rsh remotehostname date"?. (2 Replies)
Discussion started by: S26+
2 Replies

8. IP Networking

network setup???

Hello everybody, I am a new unix user (Solaris 10). I was wondering if anybody can help me figure out how to connect to the network in my work place. I know my IP address, subnet mask, gateway, primary and secondary DNS addresses but I don't know how to enter these settings into my Solaris. ... (3 Replies)
Discussion started by: arash05
3 Replies

9. UNIX for Dummies Questions & Answers

How can I tell which network card is which?

I have three network cards in my unix box. I need to figure out which card corresponds to an assigned IP address. If there some command in unix I can use to make an ethernet interface blink? Any advice would be appreciated. (6 Replies)
Discussion started by: mojoman
6 Replies

10. Red Hat

Regarding Network Interface Card

Dear All , While taking backups in one Linux Server , we find one alert came with regard to Network Interface Card. Pl find the below alert. Network Interface Card performance for NIC:eth1 has exceeded Major threshold. Bytes sent and received per second (Average)= 105540.303101... (6 Replies)
Discussion started by: jegaraman
6 Replies
NETSCRIPT-2.2.conf(5)						File Formats Manual					     NETSCRIPT-2.2.conf(5)

NAME
/etc/netscript/network.conf - interface, firewalling, and QoS configuration file. /etc/netscript/if.conf - interface setup shell script file /etc/netscript/qos.conf - QoS setup shell script file /etc/netscript/ipfilter.conf - IP chains filtering shell script file /etc/netscript/srvfilter.conf - server IP filter shell script file DESCRIPTION
This manpage is a place holder until something better is written when the netscript itself has stopped changing rapidly. Please see the README file in the /etc/netscript directory, and READ the configuration files if you need to change them. Apart from net- work.conf, all of them contain sh (1) shell script functions which are there so that various things can be altered or hooked in at the right place. Network.conf contains the full network setup details, including special interface setup for the likes of ciped/pppd/wanconfig, and is fully commented with examples given. UPGRADE PATH FROM KERNEL 2.2.X The firewall/IP filtering stuff in ipfilter.conf is the part that changed radically with the move to iptables and a far better way of set- ting up the IP filtering rules, however the QoS and interface startup/shutdown in if.conf have changed but are backwards compatible with the old 2.2.x ipchains version of netscript for the interface address configuration settings. You will have to set up the filtering again to use iptables by directly using the iptables commands. Also, the kernel 2.2.x version scripts are set up so that iptables is only run on a 2.4.x kernel, otherwise IP forwarding is disabled if beforehand you set IPFWDING_KERNEL to FILTER_ON in network.conf. This means that when you upgrade a box to a 2.4.x router kernel, you should then be able to reboot it and log into remotely and upgrade netscript to the version that will support 2.4.x. In this situation, if you have set old IPFWDING_KERNEL setting to FILTER_ON beforehand in network.conf, all IP forwarding through the box will also be disabled. This means that you can safely remotely upgrade a firewall. SEE ALSO
netscript(8), ipchains(8), iproute(8), brcfg(8). AUTHOR
This manual page was written by Matthew Grant <grantma@anathoth.gen.nz>, for the Debian GNU/Linux system (but may be used by others). BUGS
The author is lazy. He needs to write btter man pages... November 23, 2000 NETSCRIPT-2.2.conf(5)
All times are GMT -4. The time now is 12:03 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy