Results 1 to 6 of 6
I have a linux device connected to my pc in local network. That device doesn't have cron implemented, and I need to run some script on it every morning. So ...
- 04-26-2007 #1Just Joined!
- Join Date
- Oct 2006
- Posts
- 29
Telnet script
I have a linux device connected to my pc in local network. That device doesn't have cron implemented, and I need to run some script on it every morning. So I thought maybe I could use linux on pc and schedule a cron which would connect to this device and run this script.
So I would need the script to login to telnet to something like 10.0.0.1
using username root,password password and execute /var/script/example.sh.
Not sure how exactly to pull it off, but I am pretty sure it is possible. I've seen something with using echo to enter login info but I am not sure what exact syntax should be.
- 04-26-2007 #2Just Joined!
- Join Date
- Apr 2007
- Posts
- 2
The only way I can think to do this, coming from my fairly limited experience mind you, would be to write a program that initializes a connection to 10.0.0.1 and then waits for the server to output back to your program, then replies as necessary with login information, then opens the file and sends it line by line, but Im a little hazy as to what exactly you are going to be doing with it so I cant really say for sure, but that's my best suggestion.
If you need help writing a program to handle that connection that is definitely something I can help you with, just let me know.
- 04-26-2007 #3Linux Engineer
- Join Date
- Apr 2006
- Location
- Saint Paul, MN, USA / CentOS, Debian, Solaris, SuSE
- Posts
- 1,117
Hi.
cheers, drlExpect is a program that "talks" to other interactive programs accord-
ing to a script. Following the script, Expect knows what can be
expected from a program and what the correct response should be. An
interpreted language provides branching and high-level control struc-
tures to direct the dialogue. In addition, the user can take control
and interact directly when desired, afterward returning control to the
script.
-- excerpt from man expect, q.v.Welcome - get the most out of the forum by reading forum basics and guidelines: click here.
90% of questions can be answered by using man pages, Quick Search, Advanced Search, Google search, Wikipedia.
We look forward to helping you with the challenge of the other 10%.
( Mn, 2.6.n, AMD-64 3000+, ASUS A8V Deluxe, 1 GB, SATA + IDE, Matrox G400 AGP )
- 04-26-2007 #4Just Joined!
- Join Date
- Oct 2006
- Posts
- 29
@file37, I need it to do exactly what I mentioned in first post. Telnet to local machine, enter root's login detailes, run one script and quit.
@drl, thx I'll check out expect.
- 04-26-2007 #5Just Joined!
- Join Date
- Apr 2007
- Posts
- 6
I would also use expect to script a ssh/telnet session but it can be done
like so:
./telnet.sh | telnet
------------------------------
#!/bin/sh
host=10.0.0.1
port=23
login=root
passwd=password
cmd="/var/script/example.sh"
echo open $host $port
sleep 1
echo $login
sleep 1
echo $passwd
sleep 1
echo $cmd
sleep 1
echo exit
- 04-27-2007 #6Just Joined!
- Join Date
- Oct 2006
- Posts
- 29
Thx sangoma, that works out great. But I'll try to learn about expect in any case.


Reply With Quote