Computer Forums

Member Login

Remember Me? Sign Up! | Forgot Password
 
Slogan
 
Closed Thread
Old 02-06-2007, 07:16 PM   #1 (permalink)
Greg's Avatar
 
Indeed.

Join Date: Dec 2004

Posts: 1,554

Greg is on a distinguished road

Default BASH + Telnet

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
__________________
Greg is offline  
Old 02-06-2007, 07:57 PM   #2 (permalink)
 
Banned

Join Date: Sep 2005

Posts: 5,191

The General

Default

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
The General is offline  
Old 02-06-2007, 10:30 PM   #3 (permalink)
Greg's Avatar
 
Indeed.

Join Date: Dec 2004

Posts: 1,554

Greg is on a distinguished road

Default

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
__________________
Greg is offline  
Old 02-06-2007, 11:24 PM   #4 (permalink)
Greg's Avatar
 
Indeed.

Join Date: Dec 2004

Posts: 1,554

Greg is on a distinguished road

Default

Ah, yes! I got it. I found this website 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 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
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"
and pipes it into telnet.

I'm happy, no more doing it by hand
__________________
Greg is offline  
Old 02-06-2007, 11:34 PM   #5 (permalink)
 
Banned

Join Date: Jun 2006

Location: United States of America

Posts: 109

Enterpriser is an unknown quantity at this point

Default

OMG Thanks I was looking for something similar. Thank you once again.
Enterpriser is offline  
Old 02-06-2007, 11:51 PM   #6 (permalink)
Greg's Avatar
 
Indeed.

Join Date: Dec 2004

Posts: 1,554

Greg is on a distinguished road

Default

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.
__________________
Greg is offline  
Old 02-07-2007, 12:13 AM   #7 (permalink)
 
Banned

Join Date: Sep 2005

Posts: 5,191

The General

Default

^ OMG there's someone else in Bakersfield who uses Linux and likes Star Trek. Are you sure you aren't me? lol
The General is offline  
Old 02-07-2007, 05:19 AM   #8 (permalink)
void's Avatar
 
True Techie

Join Date: Oct 2005

Posts: 198

void

Default

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
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
A good tutorial for SSH is here
void is offline  
Old 02-07-2007, 10:41 AM   #9 (permalink)
simple's Avatar
 
True Techie

Join Date: Jan 2006

Location: Earth

Posts: 171

simple

Default

the ssh tutorial is really nice. thanks for that. c ya!!
__________________
<A HREF=http://ubanimator.com><IMG SRC=http://img182.imageshack.us/img182/5168/userbar511415cb2.gif><A>
simple is offline  
Old 02-07-2007, 06:04 PM   #10 (permalink)
 
Banned

Join Date: Jun 2006

Location: United States of America

Posts: 109

Enterpriser is an unknown quantity at this point

Default

Quote:
^ OMG there's someone else in Bakersfield who uses Linux and likes Star Trek. Are you sure you aren't me? lol
You are not alone brother.
Enterpriser is offline  
 
Closed Thread

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On