[BASH + Telnet] - Computers



Search Tech-Forums - link takes you to our Forum's search page.

Note: The following is only a text archive!


To view the actual forum discussion, please visit our website at http://www.tech-forums.net

Pages:1



BASH + Telnet

(Click here to view the original thread with full colors/images)



Posted by: Greg

I want to write a bash script that will telnet into my modem and perform a set of commands, but I'm not really sure where to start in writing this script. Is this even possible? Any help is appreciated.

Thanks,
~Greg



Posted by: The General

Hmm... I know you could write a script to telnet into your modem. And I know you could write a script that would execute a set of commands.

I just don't know if it would work to have them in one. :(

horndude would know, I think.

[/end useless post] :o



Posted by: Greg

Just to clarify, when I say "telnet into my modem and perform a set of commands" I mean the commands would be performed on the modem through telnet. I don't really need to have any commands executed on my computer.

I'm glad to see you're still around here, and thanks for the response.

~Greg



Posted by: Greg

Ah, yes! I got it. I found [url=http://steve-parker.org/sh/hints.shtml]this website[/url] which had an example that I based mine off of.

I always hate those web activity logs for some reason, even though I know nobody else can see them :p The purpose of this script is remove the log from my modem and replace it with a link to /dev/null so it can't be regenerated.


I start this script:[code]#!/bin/bash
echo -n "Password: "
./telnet-commands | telnet[/code]which executes this script:[code]#!/bin/bash

stty_orig=`stty -g`
stty -echo
read pass
stty $stty_orig

echo "open 192.168.100.1 23"
sleep 1
echo "admin"
sleep 1
echo ${pass}
sleep 1
echo "cd /var/tmp"
sleep 1
echo "rm log_web_activity"
sleep 1
echo "ln -s /dev/null log_web_activity"
sleep 1
echo "exit"
[/code]and pipes it into telnet.

I'm happy, no more doing it by hand :)



Posted by: Enterpriser

OMG Thanks I was looking for something similar. Thank you once again.



Posted by: Greg

Glad to see it helped someone, I love futzing around with Bash scripts :)

I'm still pretty bad at writing them, but it's always fun.



Posted by: The General

^ OMG there's someone else in Bakersfield who uses Linux and likes Star Trek. Are you sure you aren't me? lol :p



Posted by: void

You do realise that telnet doesn't encrypt. For remote login, use SSH, its more secure.

If you used SSH you could write

[CODE]ssh username@ipaddress ./telnet_commands.sh[/CODE]

to excute a command or shell script on the remote computer. With the script being

[CODE]
#!/bin/bash
cd /var/tmp
rm log_web_activity
ln -s /dev/null log_web_activity[/CODE]

A good tutorial for SSH is [URL=http://www.suso.org/docs/shell/ssh.sdf]here[/URL]



Posted by: simple

the ssh tutorial is really nice. thanks for that. c ya!!



Posted by: Enterpriser

[QUOTE]^ OMG there's someone else in Bakersfield who uses Linux and likes Star Trek. Are you sure you aren't me? lol [/QUOTE] You are not alone brother.



Posted by: Greg

[QUOTE][i]Originally posted by void [/i]
[B]You do realise that telnet doesn't encrypt. For remote login, use SSH, its more secure.[/B][/QUOTE]If my Actiontec brand DSL modem had SSH I would already be using it :p





vBulletin Copyright ©2000 - 2003, Jelsoft Enterprises Limited.


PPC Management
vB Easy Archive Final - Created by Xenon