LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Scripting at start up (https://www.linuxquestions.org/questions/linux-software-2/scripting-at-start-up-421055/)

elrohir_telperi 03-02-2006 04:47 PM

Scripting at start up
 
hello,

I would like to have a few pointers on scripting, be it shell scripting or etc, whichever appropriate.

I would like to do the following automatically when i log on:

telnet 192.168.1.1 (my DSL router)
admin (username)
admin (password)
cd /proc/sys/net/ipv4/netfilter
echo 2048 > ip_conntrack_max
echo 50 > ip_conntrack_generic_timeout
echo 5 > ip_conntrack_tcp_timeout_close
echo 120 > ip_conntrack_tcp_timeout_close_wait
echo 1200 > ip_conntrack_tcp_timeout_established
echo 120 > ip_conntrack_tcp_timeout_fin_wait
echo 60 > ip_conntrack_tcp_timeout_time_wait
echo 10 > ip_conntrack_udp_timeout

I have tried putting these into .bash_profile, but it will only proceed up to the first line, and stops when the router asks for username/password.

Any help is appreciated, thanks.


best regards

gilead 03-02-2006 05:44 PM

It would be better to have the DSL box do that for you. I'm assuming that DSL supports sysctl, so you can modify /etc/sysctl.conf to do it for you:
Code:

net.ipv4.netfilter.ip_conntrack_max = 2048
net.ipv4.netfilter.ip_conntrack_generic_timeout = 50
etc.

Then just have sysctl read the new values with sysctl -p. Or, just add them to one of your startup scripts:
Code:

echo 2048 > /proc/sys/net/ipv4/netfilter/ip_conntrack_max
etc.


elrohir_telperi 03-03-2006 06:40 AM

Nope, my DSL router (it's a D-Link) does not support sysctl.

Maybe I should rephrase my question:

how to I use scripting to automate telnet login to my router?

gilead 03-03-2006 01:49 PM

I see DSL here so often meaning Damn Small Linux that it never occurred to me :) Have you tried something like the following expect script from http://linuxgazette.net/issue50/tag/34.html?
Code:

#!/usr/bin/expect -f
# Sample telnet automation
## call with autotel host username password

set host [lindex $argv 0]
set rcfile [open ~/.autotel/$host  r ]
gets $rcfile user
gets $rcfile pass
spawn telnet  "$host"
expect "login:"
send "$user\r"
expect "word:"
send "$pass\r"
interact

You'd need to change the last line from interact to send your echo statements, but it looks like it can do what you need.


All times are GMT -5. The time now is 06:15 AM.